Cntk: GPU not detected under Python

Created on 6 Feb 2018  路  5Comments  路  Source: microsoft/CNTK

Hi,

I've compiled CNTK with Python support. GPU is well detected when I run the example in ~/Repos/cntk/Tutorials/HelloWorld-LogisticRegression with command

cntk configFile=lr_bs.cntk makeMode=false deviceId=auto

But in Python, I get

>>> import keras
Using CNTK backend
Selected CPU as the process wide default device.
/home/chris/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/keras/backend/cntk_backend.py:21: UserWarning: CNTK backend warning: GPU is not detected. CNTK's CPU version is not fully optimized,please run with GPU to get better performance.
  'CNTK backend warning: GPU is not detected. '
>>> import cntk as C
>>> C.device.all_devices()
(CPU,)

What could be wrong in my install ?

Thank you

Most helpful comment

try_set_default_device cannot be changed when a network is created. It only works at the beginning of the script.

All 5 comments

Can you try ldd /home/chris/anaconda3/envs/cntk-py27/lib/python2.7/site-packages/cntk/libCntk.Math-*.so, vs the math lib used in BrainScript?

Thanks a lot. The problem was the path in which I made a mistake
export LD_LIBRARY_PATH=$HOME/technologies/cntk/bindings/python/cntk/libs:$LD_LIBRARY_PATH

I am seeing the same problem with Windows installation.

GPU detected with BrainScript example but not in Python

GPU info:

                Device[0]: cores = 1536; computeCapability = 3.0; type = "Quadro K5100M"; total memory = 8192 MB; free memory = 7149 MB
-------------------------------------------------------------------

SET PATH=%cd%\lib\cntk_gpu\cntk;%PATH%

(Pdb) C.device.use_default_device()
Selected CPU as the process wide default device.
CPU
(Pdb) C.device.all_devices()
(GPU[0] Quadro K5100M, CPU)
(Pdb) C.device.gpu(0).id()
0
(Pdb) C.device.cpu()
CPU

Another test.

(Pdb) C.device.try_set_default_device(gpu(0))
*** RuntimeError: Process wide default device cannot be changed since it has been frozen by being implicitly used as the default device in a CNTK API call; Current default = CPU, New default = GPU[0] Quadro K5100M.

[CALL STACK]
    > std::enable_shared_from_this<Microsoft::MSR::CNTK::MatrixBase>::  operator=
    - CNTK::DeviceDescriptor::  TrySetDefaultDevice
    - PyInit__cntk_py (x2)
    - PyCFunction_Call
    - PyEval_GetFuncDesc
    - PyEval_EvalFrameEx (x2)
    - PyEval_GetFuncDesc (x2)
    - PyEval_EvalFrameEx (x2)
    - PyEval_EvalCode
    - PyAST_FromNode (x2)
    - PyCFunction_Call

Like the previous person inside of ipython notebook the GPU can be set.

from cntk.device import try_set_default_device, gpu
try_set_default_device(gpu(0))
import cntk

import cntk as C
print(C.device.all_devices())
print(C.device.try_set_default_device(cntk.device.gpu(0)))
print(C.device.use_default_device())

(GPU[0] Quadro K5100M, CPU)
True
GPU[0] Quadro K5100M

try_set_default_device cannot be changed when a network is created. It only works at the beginning of the script.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pallashadow picture pallashadow  路  5Comments

FreedMana picture FreedMana  路  6Comments

springkim picture springkim  路  4Comments

playgithub picture playgithub  路  3Comments

netvinod picture netvinod  路  3Comments