SolvedTheano CUDA is installed, but device gpu0 is not available

Hey friends, I'd like to ask for some help,

I recently bought a Nvidia G 970 card, and would like to try theano on this new GPU.

I think I've followed everything stated on theano page (CUDA, enviroment, config, etc.) and also some other blogs.

But, it is still not working.

I am running on:
os = ubuntu 16.04; theano = 0.8.1; language = python3.5; gpu = Nvidia GTX 970;

And I have tested CUDA using its own samples, no problem, the tests all PASS.

But when use theano:
I always get the error msg (no matter on theano.test(), or my own pgm):

['/usr/local/cuda-7.5/bin/nvcc', '-shared', '-O3', '-use_fast_math', '-m64', '-Xcompiler', '-DCUDA_NDARRAY_CUH=mc72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden', '-Xlinker', '-rpath,/home/aaron/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray', '-Xlinker', '-rpath,/usr/local/cuda-7.5/lib', '-Xlinker', '-rpath,/usr/local/cuda-7.5/lib64', '-I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/theano/sandbox/cuda', '-I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/numpy/core/include', '-I/usr/include/python3.5m', '-I/home/aaron/Git/.virtualenvs/ts/include/python3.5m', '-I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/theano/gof', '-o', '/home/aaron/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray/cuda_ndarray.so', 'mod.cu', '-L/usr/lib', '-lcublas', '-lpython3.5m', '-lcudart']
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 1, 'for cmd', '/usr/local/cuda-7.5/bin/nvcc -shared -O3 -use_fast_math -m64 -Xcompiler -DCUDA_NDARRAY_CUH=mc72d035fdf91890f3b36710688069b2e,-DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION,-fPIC,-fvisibility=hidden -Xlinker -rpath,/home/aaron/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray -Xlinker -rpath,/usr/local/cuda-7.5/lib -Xlinker -rpath,/usr/local/cuda-7.5/lib64 -I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/theano/sandbox/cuda -I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/home/aaron/Git/.virtualenvs/ts/include/python3.5m -I/home/aaron/Git/.virtualenvs/ts/lib/python3.5/site-packages/theano/gof -o /home/aaron/.theano/compiledir_Linux-4.4--generic-x86_64-with-Ubuntu-16.04-xenial-x86_64-3.5.1+-64/cuda_ndarray/cuda_ndarray.so mod.cu -L/usr/lib -lcublas -lpython3.5m -lcudart')
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu0 is not available  (error: cuda unavailable)

What should I do?

Thx

19 Answers

✔️Accepted Answer

Dear All,

I have same problem and I solved it with the following task:

Add environment variable:

sudo nano /etc/profile

Add following to the file:

PATH=/usr/local/cuda/bin:$PATH
export PATH

Then execute :

source /etc/profile

Then you can import keras or theano library in python without any problem.
Enjoy!

Other Answers:

try this
sudo ldconfig /usr/local/cuda-7.5/lib64

I had the same issue and was able to solve my issue by doing two things:

  • Install gcc 4.9 and linking/usr/bin/gccto /usr/bin/gcc-4.9 as well as /usr/bin/g++ to/usr/bin/g++-4.9
  • Adding this flag to THEANO_FLAGS='-D_FORCE_INLINES' since apparently a bug in glibc 2.23 causes this issue

also see:
#4430
and
#4369

Related Issues:

34
Theano Ubuntu 16.04 and CUDA
There is no problem with Theano I tried it and we need to work around 2 problems that aren't depende...
15
Theano CUDA is installed, but device gpu0 is not available
Dear All Hey friends I'd like to ask for some help I recently bought a Nvidia G 970 card and would l...
15
Theano Theano Runtime Error - must set MKL_THREADING_LAYER=GNU in environement
After running into this the solution is quite easy to do from within Python like this: Couldn't this...
14
Theano I'm getting an ImportError in Theano in Anaconda
Finally got rid of the warning with: When I import keras or theano after downloading it with Anacond...
9
Theano fatal error: cudnn.h: No such file or directory
Could you add the following to your .theanorc and retry (on Windows) ? Doing import theano from cond...