Theano: fatal error: cudnn.h: No such file or directory

Created on 27 Mar 2017  路  17Comments  路  Source: Theano/Theano

Doing import theano from conda 2.7 (Windows) gives this:

Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
c:\users\nikhil\appdata\local\temp\try_flags_ef1xq6.c:4:19: fatal error: cudnn.h: No such file or directory.
Compilation terminated.

I installed CUDA 8.0 with the installer from Nvidia's website and then copied cudnn into the respective folders at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0. Cudnn.h is in the includes folder at that location, but it can't find it.

Windows

Most helpful comment

Could you add the following to your .theanorc and retry (on Windows) ?

[dnn]

include_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
library_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

All 17 comments

Hello ! Could you show us the content of your .theanorc file ?

Or what theano flags do you use ?

I installed libgpuarray and Theano from the source and got the same issue on Ubuntu 16.04.

I'm using cudnn 6 and cuda 8

My .theanorc file is

[global]
floatX = float32
device=cuda
optimizer=fast_run

[blas]
ldflags = -L/usr/local/lib -lopenblas

[nvcc]
fastmath = True

Could you add the following to your .theanorc and retry (on Windows) ?

[dnn]

include_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
library_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

My new .theanorc is...

[global]
device = cuda

[dnn]
include_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include
library_path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64

and it said it couldn't find cl.exe, which looks like the VS compiler after a quick google search. After saying that it crashes.

Adding it to PATH fixes the "couldn't find" error, but the crash is still there (as in, windows shuts down python and asks if I want to debug or close program.).

E: Installing 2017 Build Tools and trying again...

Maybe you are experiencing same issues as here on Windows: https://github.com/Theano/libgpuarray/issues/264#issuecomment-289185531

Python crashes come sometimes from compatibilities issues with GCC compiler. What I can suggest now is to install conda packages m2w64-toolchain in the same conda environment in which theano is installed, then work with this environment.

REM Activate your conda env in which you installed theano.
REM If you use the default conda env (i.e. root), run `activate root`, 
REM so that conda configures all environment variables correctly.
activate YOUR_CONDA_ENV

REM install m2w64-toolchain
conda install m2w64-toolchain

REM Then test again
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\__init__.py", line 164, in <module>
    use(config.device)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\__init__.py", line 151, in use
    init_dev(device)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\__init__.py", line 66, in init_dev
    avail = dnn.dnn_available(name)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\dnn.py", line 174, in dnn_available
    if not dnn_present():
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\dnn.py", line 157, in dnn_present
    dnn_present.avail, dnn_present.msg = _dnn_check_version()
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\dnn.py", line 130, in _dnn_check_version
    v = version()
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gpuarray\dnn.py", line 326, in version
    profile=False)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\compile\function.py", line 326, in function
    output_keys=output_keys)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\compile\pfunc.py", line 486, in pfunc
    output_keys=output_keys)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\compile\function_module.py", line 1795, in orig_function
    defaults)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\compile\function_module.py", line 1661, in create
    input_storage=input_storage_lists, storage_map=storage_map)
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gof\link.py", line 699, in make_thunk
    storage_map=storage_map)[:3]
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gof\vm.py", line 1114, in make_all
    self.updated_vars,
  File "C:\Users\nikhil\Anaconda2\lib\site-packages\theano\theano\gof\vm.py", line 968, in make_vm
    vm = CVM(
NameError: global name 'CVM' is not defined

Tried that but this happened.

I also installed build tools 2015 and now it hangs slightly longer before crashing (trying normally).

A bit strange. Can you clear the theano cache and then try again ?

theano-cache purge

Did that and now it works, thanks!

why comes a error that "Process finished with exit code -1073741819 (0xC0000005)" when i add [dnn]
include_path=C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0include
library_path=C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0libx64

My 3 cents: got to the point were dnn.dnn_available(name) L66 in C:UsershashMiniconda3libsite-packagestheanogpuarray__init__.py crashes python.

But I have gpu with Compute Capability 2.1 so maybe it should not work,
but a better error, or any error would be awesome.

compute capability 2.1 isn't supported by cudnn. I just tested on a GPU that cudnn don't support, and for me it print a good error:

$ THEANO_FLAGS=device=cuda python -c "import theano"
Can not use cuDNN on context None: Device not supported
Mapped name None to device cuda: GeForce GTX 480 (0000:02:00.0)

But I found that we don't always handle it correctly. I asked @notoraptor to look into that.

Sorry, I wanna know if my video card with compute capability 2.1 works on Theano, using GPU of course

@lauranceair have U solved the problem? I have the same problem as U. I mean after the error "fatal error: cudnn.h: No such file or directory"

The same issue occurs to me:
https://github.com/Theano/Theano/issues/6063

If you just installed Cuda and followed the NVIDIA installing instruction: Restart your machine

For anyone on macOS having this issue, adding these to ~/.theanorc fixed my issue:

[dnn]
include_path=/usr/local/cuda/include
library_path=/usr/local/cuda/lib
Was this page helpful?
0 / 5 - 0 ratings

Related issues

9thDimension picture 9thDimension  路  3Comments

Higgcz picture Higgcz  路  6Comments

aditsanghvi94 picture aditsanghvi94  路  3Comments

grayfall picture grayfall  路  3Comments

junku901 picture junku901  路  4Comments