美文网首页
CNTK中GPU信息的获取

CNTK中GPU信息的获取

作者: Jtag特工 | 来源:发表于2019-09-27 17:58 被阅读0次

CNTK中GPU信息的获取

device接口

CNTK提供了device接口,可以访问gpu的几个基本参数。

获取所有的设备

首先可以通过cntk.device.all_devices方法来获取当前的设备

>>> C.device.all_devices()
(GPU[0] GeForce GTX 960M, CPU)

获取GPU

知道了系统里有多少设备了之后,就可以通过设备号来通过device.gpu来访问GPU设备了。
例:

>>> C.device.gpu(0)
GPU[0] GeForce GTX 960M

GPU属性

通过device.gpu(id)获取了gpu的引用之后,我们就可以通过device.get_gpu_properties函数来获取属性:

>>> prop = C.device.get_gpu_properties(C.device.gpu(0))
>>> prop
<cntk.cntk_py.GPUProperties; proxy of <Swig Object of type 'CNTK::GPUProperties *' at 0x000001A1195C3420> >

属性有:

  • device_id: 设备号
  • name: 名字
  • version_major: 主版本号
  • version_minor: 副版本号
  • cuda_cores: CUDA核
  • total_memory: 显存大小

例:

>>> prop.name
'GeForce GTX 960M'
>>> prop.version_major
5
>>> prop.version_minor
0
>>> prop.cuda_cores
960
>>> prop.total_memory
2048
>>> prop.device_id
0

如何监控GPU内存的分配与释放

如果想要监控内存使用情况的话,上面的简单的API是不够用的,我们使用trace功能吧:

C.cntk_py.set_gpumemory_allocation_trace_level(1)

例,运行时打印出来的效果是这样的:

Allocating Matrix<float> (Rows = 1, Cols = 5416) buffer on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Allocated DeviceData = 000000050323AA00
Allocating Matrix<float> (Rows = 1, Cols = 8124) buffer on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Allocated DeviceData = 0000000504E17A00
Allocating Matrix<float> (Rows = 1, Cols = 5416) buffer on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Allocated DeviceData = 0000000502A38E00
Freed buffer<float> DeviceData = 0000000502A38E00 on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Freed buffer<float> DeviceData = 0000000504E17A00 on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Freed buffer<float> DeviceData = 000000050323AA00 on DeviceId = 0; GPU Memory Free = 29 MB of 2048 MB
Freed buffer<float> DeviceData = 0000000567440000 on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocating Matrix<float> (Rows = 650, Cols = 8124) buffer on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocated DeviceData = 0000000541BC0000
Freed buffer<char> DeviceData = 0000000502B3E600 on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Allocating Matrix<float> (Rows = 650, Cols = 5416) buffer on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Allocated DeviceData = 0000000543000000
Allocating Matrix<float> (Rows = 1, Cols = 5416) buffer on DeviceId = 0; GPU Memory Free = 65 MB of 2048 MB
Allocated DeviceData = 000000050323AA00
Freed buffer<float> DeviceData = 000000050323AA00 on DeviceId = 0; GPU Memory Free = 65 MB of 2048 MB
Freed buffer<float> DeviceData = 0000000543000000 on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Allocating Matrix<char> (Rows = 1, Cols = 5416) buffer on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Allocated DeviceData = 0000000502B3E600
Freed buffer<float> DeviceData = 0000000541BC0000 on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocating Matrix<float> (Rows = 650, Cols = 8066) buffer on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocated DeviceData = 0000000541BC0000
Allocating Matrix<float> (Rows = 1, Cols = 8066) buffer on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Allocated DeviceData = 0000000504E17A00
Freed buffer<float> DeviceData = 0000000504E17A00 on DeviceId = 0; GPU Memory Free = 78 MB of 2048 MB
Freed buffer<float> DeviceData = 0000000541BC0000 on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocating Matrix<float> (Rows = 3377, Cols = 1) buffer on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocated DeviceData = 00000005050DCA00
Freed buffer<float> DeviceData = 00000005050DCA00 on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB
Allocating Matrix<float> (Rows = 3377, Cols = 8066) buffer on DeviceId = 0; GPU Memory Free = 98 MB of 2048 MB

相关文章

  • CNTK中GPU信息的获取

    CNTK中GPU信息的获取 device接口 CNTK提供了device接口,可以访问gpu的几个基本参数。 获取...

  • pytorch中查看GPU信息

    为什么将数据转移至GPU的方法叫做.cuda而不是.gpu,就像将数据转移至CPU调用的方法是.cpu?这是因为G...

  • Metal - 命令设定 - 反采样

    通过测量应用程序中的GPU统计信息来提高性能。 概述 GPU跟踪有关它们执行的命令信息,例如每个命令何时开始或结束...

  • Metal - GPU - 获取默认GPU

    选择要在其上运行金属代码的系统的默认GPU设备。 概述 要使用Metal框架,首先要获取GPU设备,您的应用程序需...

  • 爬取NCBI中GEO中的数据

    获取GEO中GSE网页的信息 获取GEO中GSM的信息 汇总写成函数 获取附加材料文件

  • 训练的小常识

    1.查看cuda版本 2.监视NVIDIA的GPU使用情况 3.如何获取环境中的GPU 4.区别普通的神经网络和深...

  • 开发前准备

    [Linux查看GPU信息和使用情况] Linux查看显卡信息: 使用nvidia GPU可以: windows下...

  • Win7安装CNTK

    KeyWord: Win7 CNTK Is64BitProcess 1、CNTK默认不支持Win7 自动安装CNT...

  • 查看gpu信息

  • AGX Xavier 性能及运行状态查询

    Jetson AGX Xavier 性能及信息查询 NVPModel 描述: GPU TPC – GPU Text...

网友评论

      本文标题:CNTK中GPU信息的获取

      本文链接:https://www.haomeiwen.com/subject/cmhauctx.html