GPU is not available in Theano


I have constructed the environment as below. CUDA is working well in Visual Studio.
However, I cannot use GPU well in Theano using simple test code.

OS: Windows 10 Home 64bit
GPU: GTX 1080
Visual Studio: Visual Studio 2015
CUDA: CUDA 8.0 & cuDNN 5.1
DNN framework: Theano
Python: Python2.7

Error message is “WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)”.
How to change the settings?


Are you using the latest available NVIDIA driver package? Are you able to run the simple example programs that ship with CUDA?

I’m able to run the simple CUDA example programs in “C:\ProgramData\NVIDIA Corporation\CUDA Samples\v8.0”.

And, I’m using latest available NVIDIA driver package.

Same problem here

OS: Windows 10.0.14393
GPU: GTX 1080
NVIDIA Driver: 375.95
CUDA: 8.0.44
Python: 2.7.12
Theano: 0.9.0dev4

The CUDA samples are working, but importing theano prints:

import theano
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu0 is not available (error: cuda unavailable)

I had tried additional test in another environment as bellow.
Then, I became able to run the sample code. GPU is working well.

OS: Windows 10 Pro 64bit
Visual Studio: Visual Studio 2013
CUDA: CUDA 8.0 & cuDNN 5.1
DNN framework: Theano
Python: Python2.7

Futhermore, if I change VS2013 to VS2015, then same problem occur.
I think there is a possibility that version of Visual studio is cause of this problem.

However, I cannot find root of cause.

I think the problem of “g++” is solved by GCC instruction in Installation of Theano on Windows.

Hello all,

!!! FOUND IT !!!

"Using gpu device 0: GeForce GTX TITAN Black (CNMem is disabled, cuDNN=5105)

My Config :
Visual Studio 2015 on Windows 10_64
Nvidia CUDA, updated with CuDNN
Latest Nvidia driver for NVIDIA GTX TITAN BLACK, Intel i7

Nvidia tests went ok (deviceQuery, bandWidthTest), and mandelbrot sample GPU executable compiled with VS2015. And checked the GPU was used with gpuz.

But for Python with GPU… still impossible. Searched the whole web.

After Winpython 3.5 failures I tried Winpython 2.7 and went through the FULL procedure here, this time.

Moving to the TDM-GCC-6-64 compiler (gcc) maybe helped but didn’t solve it all for me.

I checked all my path variables, make a clean “env.bat” environment file.

My solution (REDEMPTION !!) went from modifying the env.bat (described at url http://…/theano/install_windows.html).

SOLUTION with Python 2.7 :

I was about to throw it all when, by inspiration, I updated the VSFORPYTHON value with VS2015 path (instead of “Visual Studio 2008 Compiler for Python 2.7”) and it worked at LAST !

Here’s the new File env.bat (REM lines removed) with my VSFORPYTHON update :

set VSFORPYTHON=“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC”
set SCISOFT=%~dp0
set PATH=%SCISOFT%\TDM-GCC-6-64\bin;%SCISOFT%\TDM-GCC-6-64\x86_64-w64-mingw32\bin;%SCISOFT%\WinPython-64bit-\scripts;%PATH%
CALL %SCISOFT%\WinPython-64bit-\scripts\env.bat
CALL %VSFORPYTHON%\vcvarsall.bat amd64
cmd.exe /k

NB. Note the PATH and change it with all your own directories if needed.

I have no idea why I had the problem with Winpython 3.5 (maybe thanks to Masaru, because of the wrong Mingw64 package I had instead of TDM-GCC compiler).
I have no idea why the 2015 Visual Studio solution works for compiling python 2.7 and not initial solution from Theano Website.

Up message if it helps you too…

NB. Here was my actual working “.theanorc” file :

floatX = float32
device = gpu

compiler_bindir=“C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin”

cnmem = 0.9