1

I configured theano to be connected to the GPU and I installed all the required libraries.

I used the following code from the documentation to check if the GPU work:

THEANO_FLAGS='floatX=float32,device=cuda0,gpuarray.preallocate=1' python GPU.py

code:

from theano import function, config, shared, sandbox
import theano.tensor as T
import numpy
import time

vlen = 10 * 30 * 768  # 10 x #cores x # threads per core
iters = 1000

rng = numpy.random.RandomState(22)
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
f = function([], T.exp(x))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in xrange(iters):
    r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
    print('Used the cpu')
else:
    print('Used the gpu')
# End gpu_test.py

but I got this error:

Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
b'/tmp/try_flags_47onlbh0.c:4:19: fatal error: cudnn.h: No such file or directory\ncompilation terminated.\n'
Preallocating 7554/7952 Mb (0.950000) on cuda0
Mapped name None to device cuda0: GeForce RTX 2080 (0000:17:00.0)
[GpuElemwise{exp,no_inplace}(<GpuArrayType<None>(float32, vector)>), HostFromGpu(gpuarray)(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.245761 seconds
Result is [ 1.23178029  1.61879349  1.52278066 ...,  2.20771813  2.29967761
  1.62323296]
Used the cpu

Any idea about the problem?

talonmies
  • 70,661
  • 34
  • 192
  • 269
Minions
  • 5,104
  • 5
  • 50
  • 91
  • 1
    You have to install cuDNN, you have to install the development version of cuDNN, and it needs to be installed in a place that theano can find it. You know that theano development stopped over a year ago, right? – Robert Crovella Jul 16 '19 at 19:20
  • I have to install it, or it has been stopped? my theano version is: `Theano==1.0.3+2.g3e47d39ac.dirty` and I'm using cuda-10.0 – Minions Jul 16 '19 at 20:13

1 Answers1

0

The error is telling you what is missing: fatal error: cudnn.h: No such file or directory\ncompilation terminated. It means that your cuda is not getting the cudnn.h file.

I faced the same problem and followed the following steps mentioned in the documentation for solving the problem. It worked!

The following steps describe how to build a cuDNN dependent program. In the following sections the CUDA v9.0 is used as example:

Your CUDA directory path is referred to as C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

Copy the following files of your downloaded cuDNN into the CUDA Toolkit directory.

  • Copy yourinstallpath\cuda\bin\cudnn64_7.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin.
  • Copy yourinstallpath\cuda\ include\cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\include.
  • Copy yourinstallpath\cuda\lib\x64\cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\lib\x64.

Set the following environment variables to point to where cuDNN is located. To access the value of the CUDA_PATH environment variable, perform the following steps:

Open a command prompt from the Start menu. Type Run and hit Enter. Issue the control sysdm.cpl command. Select the Advanced tab at the top of the window. Click Environment Variables at the bottom of the window. Ensure the following values are set: Variable Name: CUDA_PATH Variable Value: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0

Include cudnn.lib in your Visual Studio project. Open the Visual Studio project and right-click on the project name. Click Linker > Input > Additional Dependencies. Add cudnn.lib and click OK.