CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

ValueError: Specified GPU device id (0) is invalid

Open youssefhb opened this issue 9 years ago • 27 comments

Hi, i have built CNTK GPU successfully, and i can run the FeedForwardNet.py example. However when i try to run the same example using GPU (try_set_default_device(cntk.device.gpu(0))) I get the following error :

Traceback (most recent call last): File "FeedForwardNet.py", line 82, in try_set_default_device(cntk.device.gpu(0)) File "/CNTK/bindings/python/cntk/internal/swig_helper.py", line 69, in wrapper result = f(*args, **kwds) File "/CNTK/bindings/python/cntk/device.py", line 94, in gpu return cntk_py.DeviceDescriptor.gpu_device(device_id) ValueError: Specified GPU device id (0) is invalid.

Build info:

	Built time: May  1 2017 22:44:50
	Last modified date: Mon May  1 12:04:32 2017
	Build type: release
	Build target: GPU
	With 1bit-SGD: no
	With ASGD: no
	Math lib: mkl
	CUDA_PATH: /usr/local/cuda-8.0/
	CUB_PATH: /usr/local/cub-1.4.1
	CUDNN_PATH: /usr/local/cudnn-5.1
	Build Branch: master
	Build SHA1: 4b9f8739c72068d70279f91b4b59923b2ae1fc3a (modified)

+-----------------------------------------------------------------------------+ | NVIDIA-SMI 375.39 Driver Version: 375.39 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 675M Off | 0000:01:00.0 N/A | N/A | | 0% 59C P0 N/A / N/A | 357MiB / 1984MiB | N/A Default | +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 Not Supported | +-----------------------------------------------------------------------------+

Anyone has faced this issue ? Thanks.

youssefhb avatar May 01 '17 21:05 youssefhb

I had exactly the same error on my freshly installed https://cntk.ai/PythonWheel/GPU/cntk-2.0rc2-cp35-cp35m-win_amd64.whl , Windows 7 x64, Anaconda 3 4.1.1 (64 bit). Check updates for your video driver, it works for me.

Sadler2 avatar May 02 '17 05:05 Sadler2

I have the same problem. It's random for me. Usually, it works, but when I have MS Edge open, it usually does not work.

Ark-kun avatar May 19 '17 10:05 Ark-kun

It looks that you have installed the CPU version instead of the GPU version. I would recommend to reinstall the last GPU version and check that CNTK is using GPUs:

import cntk
cntk.logging.set_trace_level(2)
cntk.all_devices() 

miguelgfierro avatar May 30 '17 13:05 miguelgfierro

From build info, you can see that build target is GPU. GPU is working fine with other libraries. The issue in CNTK side.

youssefhb avatar May 30 '17 14:05 youssefhb

If you print cntk.all_devices() do you get CPU or GPU?

miguelgfierro avatar May 30 '17 14:05 miguelgfierro

it's just empty.

youssefhb avatar May 30 '17 14:05 youssefhb

That's odd. At least you should get CPU. I would try to install the last release RC3. I just installed this version today in a windows GPU VM and it worked.

miguelgfierro avatar May 30 '17 15:05 miguelgfierro

I'll try the latest release. Hope it will resolve my issue. Thank you.

youssefhb avatar Jun 01 '17 08:06 youssefhb

@youssefhb is this issue resolved?

ke1337 avatar Jul 13 '17 08:07 ke1337

I'm closing this issue due to lack of response. Assume this is resolved for the latest 2.0 release. Feel free to reopen this issue if needed. Thanks!

cha-zhang avatar Jul 31 '17 16:07 cha-zhang

I have install CNTK-2-0-Windows-64bit-GPU on windows 10, when I run cntk.all_devices() I get CPU, how to activate GPU. any answers

ghost avatar Oct 25 '17 01:10 ghost

Usually this is a CUDA issue. Please install cuda samples and run device query sample to make sure CUDA works.

ke1337 avatar Oct 25 '17 05:10 ke1337

looks like even if I install the cuda I dont have GPU that CUDA-capable. I followed this

2.1. Verify You Have a CUDA-Capable GPU To verify that your GPU is CUDA-capable, open the Control Panel ( Start > Control Panel ) and double click on System. In the System Properties window that opens, click the Hardware tab, then Device Manager. Expand the Display adapters entry. There you will find the vendor name and model of your graphics card. If it is an NVIDIA card that is listed in http://developer.nvidia.com/cuda-gpus, your GPU is CUDA-capable. The Release Notes for the CUDA Toolkit also contain a list of supported products

ghost avatar Oct 25 '17 17:10 ghost

I also dont have a NIVIDIA graphic card on my machine.

ghost avatar Oct 25 '17 18:10 ghost

I am still having this issue. My GPU card is GeForce GT 540M (capability 2.1) Can you reopen the issue and give support to solve it please? I've already try many things without success. CNTK installed on Windows 7 64 bit via Python (3.6) wheel files - the GPU version of course.

More details

C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi.exe
Sun Jun 03 15:16:14 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 391.35                 Driver Version: 391.35                    |
|-------------------------------+----------------------+----------------------+
| 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 GT 540M    WDDM  | 00000000:01:00.0 N/A |                  N/A |
| N/A   52C    P0    N/A /  N/A |     57MiB /  2048MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

and

python -c "import cntk; cntk.logging.set_trace_level(2); cntk.all_devices()"
-------------------------------------------------------------------
GPU info:

                Device[0]: cores = 96; computeCapability = 2.1; type = "GeForce
GT 540M"; total memory = 2048 MB; free memory = 1990 MB
-------------------------------------------------------------------

resulting in the error

python -c "import cntk as C; C.device.try_set_default_device(C.device.gpu(0)) "
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\dev\python\Jupiter\Conda\lib\site-packages\cntk\internal\swig_helper.
py", line 69, in wrapper
    result = f(*args, **kwds)
  File "C:\dev\python\Jupiter\Conda\lib\site-packages\cntk\device.py", line 94,
in gpu
    return cntk_py.DeviceDescriptor.gpu_device(device_id)
ValueError: Specified GPU device id (0) is invalid.

[CALL STACK]
    > CNTK::DeviceDescriptor::  GPUDevice
    - PyInit__cntk_py
    - PyCFunction_FastCallDict
    - PyObject_CallFunctionObjArgs
    - PyEval_EvalFrameDefault
    - Py_CheckFunctionResult
    - PyList_Size
    - PyEval_EvalFrameDefault
    - Py_CheckFunctionResult
    - PyObject_CallFunctionObjArgs
    - PyEval_EvalFrameDefault
    - Py_CheckFunctionResult
    - PyEval_EvalCodeEx
    - PyEval_EvalCode
    - PyArena_Free
    - PyRun_StringFlags

Depending on the CNTK, with the last one I get a crash of the anaconda python itself

giuliohome avatar Jun 03 '18 12:06 giuliohome

CUDA 9 has dropped support for capability < 3.0. Please use CNTK 2.3 and install CUDA 8.0 instead.

ke1337 avatar Jun 03 '18 16:06 ke1337

I've dowloaded and tried CUDA 8.0. The Visual Studio Integration (I have vs2015) fails and I have to uncheck that part. Aside from that I have tried many versions of CNTK starting from 2.0 and I couldn't make it work... I will test with CNTK 2.3 again and let you know in case I have any postive result

giuliohome avatar Jun 03 '18 16:06 giuliohome

@KeDengMS This is the CNTK installed

(base) C:\Users\MyHome>pip install https://cntk.ai/PythonWheel/GPU/cntk-2.3-cp36
-cp36m-win_amd64.whl
Collecting cntk==2.3 from https://cntk.ai/PythonWheel/GPU/cntk-2.3-cp36-cp36m-wi
n_amd64.whl
  Downloading https://cntk.ai/PythonWheel/GPU/cntk-2.3-cp36-cp36m-win_amd64.whl
(311.0MB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 311.0MB 18kB/s
Requirement already satisfied: scipy>=0.17 in c:\dev\python\jupiter\conda\lib\si
te-packages (from cntk==2.3) (0.19.1)
Requirement already satisfied: numpy>=1.11 in c:\dev\python\jupiter\conda\lib\si
te-packages (from cntk==2.3) (1.13.3)
Installing collected packages: cntk
Successfully installed cntk-2.3

printing the version as expected

(base) C:\Users\MyHome> python -c "import cntk; print(cntk.__version__)"
2.3

I can't still have the GPU recognized as a valid device

(base) C:\Users\MyHome>python -c "import cntk; cntk.logging.set_trace_level(2);
cntk.all_devices()"
-------------------------------------------------------------------
GPU info:

                Device[0]: cores = 96; computeCapability = 2.1; type = "GeForce
GT 540M"; total memory = 2048 MB; free memory = 1990 MB
-------------------------------------------------------------------

giuliohome avatar Jun 03 '18 17:06 giuliohome

Same issue from a trivial C# console app with Visual Studio 2015 after

PM> Install-Package CNTK.GPU -Version 2.3.0


Attempting to gather dependency information for package 'CNTK.GPU.2.3.0' with respect to project 'ConsoleCNTK', targeting '.NETFramework,Version=v4.6.2'
Gathering dependency information took 1,23 sec
Attempting to resolve dependencies for package 'CNTK.GPU.2.3.0' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'CNTK.GPU.2.3.0'
Resolved actions to install package 'CNTK.GPU.2.3.0'
Retrieving package 'CNTK.GPU 2.3.0' from 'nuget.org'.
  GET https://www.nuget.org/api/v2/package/CNTK.GPU/2.3.0
  OK https://www.nuget.org/api/v2/package/CNTK.GPU/2.3.0 1204ms
Installing CNTK.GPU 2.3.0.
Adding package 'CNTK.GPU.2.3.0' to folder 'C:\CNTK\mySample\ConsoleCNTK\packages'
Added package 'CNTK.GPU.2.3.0' to folder 'C:\CNTK\mySample\ConsoleCNTK\packages'
Added package 'CNTK.GPU.2.3.0' to 'packages.config'
Successfully installed 'CNTK.GPU 2.3.0' to ConsoleCNTK
Executing nuget actions took 5,58 min
Time Elapsed: 00:05:36.3834711

VS exception in C#

Again, DeviceDescriptor.AllDevices() returns only one device [0] of .Type equals to CPU

giuliohome avatar Jun 03 '18 17:06 giuliohome

I'm afraid that CNTK 2.3 does not support GPU with compute capability 2.1 for CUDA (and not even CNTK 2.0) see this line from the source of the branch release/2.3 CNTK: The GPU (%s) has compute capability %d.%d. CNTK is only supported on GPUs with compute capability 3.0 or greater" Exactly this line is the crucial point in Common/BestGpu.cpp: static const int MininumCCMajorForGpu = 3; // cntk supports GPUs with Compute Capability > 3.0

giuliohome avatar Jun 03 '18 19:06 giuliohome