如何在 Windows 7 64 位上使用 theano 设置 cuDnn

how to setup cuDnn with theano on Windows 7 64 bit

我已经在我的机器上安装了 Theano 框架并启用了 CUDA,但是当我在我的 python 控制台中 "import theano" 时,我收到以下消息:

>>> import theano
Using gpu device 0: GeForce GTX 950 (CNMeM is disabled, CuDNN not available)

现在 "CuDNN not available",我从 Nvidia 网站下载了 cuDnn。我还更新了环境中的 'path',并在 '.theanorc.txt' 配置文件中添加了 'optimizer_including=cudnn'。

然后,我再次尝试,但失败了:

>>> import theano
Using gpu device 0: GeForce GTX 950 (CNMeM is disabled, CuDNN not available)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda2\lib\site-packages\theano\__init__.py", line 111, in <module>
    theano.sandbox.cuda.tests.test_driver.test_nvidia_driver1()
  File "C:\Anaconda2\lib\site-packages\theano\sandbox\cuda\tests\test_driver.py", line 31, in test_nvidia_driver1
    profile=False)
  File "C:\Anaconda2\lib\site-packages\theano\compile\function.py", line 320, in function
    output_keys=output_keys)
  File "C:\Anaconda2\lib\site-packages\theano\compile\pfunc.py", line 479, in pfunc
    output_keys=output_keys)
  File "C:\Anaconda2\lib\site-packages\theano\compile\function_module.py", line 1776, in orig_function
    output_keys=output_keys).create(
  File "C:\Anaconda2\lib\site-packages\theano\compile\function_module.py", line 1456, in __init__
    optimizer_profile = optimizer(fgraph)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 101, in __call__
    return self.optimize(fgraph)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 89, in optimize
    ret = self.apply(fgraph, *args, **kwargs)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 230, in apply
    sub_prof = optimizer.optimize(fgraph)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 89, in optimize
    ret = self.apply(fgraph, *args, **kwargs)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 230, in apply
    sub_prof = optimizer.optimize(fgraph)
  File "C:\Anaconda2\lib\site-packages\theano\gof\opt.py", line 89, in optimize
    ret = self.apply(fgraph, *args, **kwargs)
  File "C:\Anaconda2\lib\site-packages\theano\sandbox\cuda\dnn.py", line 2508, in apply
    dnn_available.msg)
AssertionError: cuDNN optimization was enabled, but Theano was not able to use it. We got this error:
Theano can not compile with cuDNN. We got this error:

>>>

有人可以帮助我吗?谢谢。

应该有一种方法可以通过仅设置 Path 环境变量来实现,但我永远无法让它工作。唯一对我有用的是手动将 CuDNN 文件复制到 CUDA 安装中的相应文件夹中。

例如,如果您的 CUDA 安装在 C:\CUDA\v7.0 中,并且您将 CuDNN 解压缩到 C:\CuDNN,您将按如下方式复制:

  • C:\CuDNN\lib\x64\ 的内容将被复制到 C:\CUDA\v7.0\lib\x64\
  • C:\CuDNN\include\ 的内容将被复制到 C:\CUDA\v7。0\include\
  • C:\CuDNN\bin\ 的内容将被复制到 C:\CUDA\v7。0\bin\

之后它应该可以工作了。

除了您所做的所有工作之外,我还更新了主文件夹中 .theanorc.txt 的以下内容,之后它就可以正常工作了。

[lib] 
#cnmem=1.0 
cudnn=1.0