如何验证 CNTK 正在使用 GPU?我已经在我的机器上安装了 CNTK-2-0-beta7-0-Windows-64bit-GPU-1bit-SGD 二进制文件。但是,当我尝试从 Python 运行它时:
from cntk.device import set_default_device, gpu
set_default_device(gpu(0))
我得到:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-eca77b3090be> in <module>()
1 from cntk.device import set_default_device, gpu
----> 2 set_default_device(gpu(0))
C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py34\lib\site-packages\cntk\device.py in gpu(device_id)
74 :class:`~cntk.device.DeviceDescriptor`: GPU device descriptor
75 '''
---> 76 return cntk_py.DeviceDescriptor.gpu_device(device_id)
77
78 def use_default_device():
ValueError: Specified GPU device id (0) is invalid.
今天补充一些信息:
这是运行 NVidia_smi.exe 的结果
C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi.exe
Thu Jan 12 20:38:30 2017
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 369.61 Driver Version: 369.61 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GPU WDDM | 0000:01:00.0 Off | N/A |
| N/A 51C P0 2W / N/A | 864MiB / 1024MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
在 Jupyter Notebook 中重新启动内核后,我得到:
import cntk as C
if C.device.default().type() == 0:
print('running on CPU')
else:
print('running on GPU')
running on CPU
但是今天我能够运行:
from cntk.device import set_default_device, gpu
set_default_device(gpu(0))
import cntk as C
if C.device.default().type() == 0:
print('running on CPU')
else:
print('running on GPU')
running on GPU
GPU应该是GPU机器上的默认值,还是需要显式设置?