我已按照说明在系统文件夹中(而不是作为用户)从源代码(git 版本)安装 Theano 和 GPUArray。GPUArray 测试运行良好,没有错误。
问题是如果我以 root 身份运行,Theano 仅适用于 GPU。运行示例来测试 gpu:
(python35) rll@ip-30-92:~$ THEANO_FLAGS=device=cuda python temp.py
ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/theano/gpuarray/__init__.py", line 179, in <module>
use(config.device)
File "/usr/local/lib/python3.5/dist-packages/theano/gpuarray/__init__.py", line 166, in use
init_dev(device, preallocate=preallocate)
File "/usr/local/lib/python3.5/dist-packages/theano/gpuarray/__init__.py", line 73, in init_dev
context.cudnn_handle = dnn._make_handle(context)
File "/usr/local/lib/python3.5/dist-packages/theano/gpuarray/dnn.py", line 83, in _make_handle
cudnn = _dnn_lib()
File "/usr/local/lib/python3.5/dist-packages/theano/gpuarray/dnn.py", line 70, in _dnn_lib
raise RuntimeError('Could not find cudnn library (looked for v5* or v6*)')
RuntimeError: Could not find cudnn library (looked for v5* or v6*)
[Elemwise{exp,no_inplace}(<TensorType(float64, vector)>)]
Looping 1000 times took 3.201078 seconds
Result is [ 1.23178032 1.61879341 1.52278065 ..., 2.20771815 2.29967753
1.62323285]
Used the cpu
如果以 root 身份运行,它可以工作,尽管仍然存在与 cuDNN 无法识别设备相关的错误:
(python35) rll@ip-30-92:~$ sudo THEANO_FLAGS=device=cuda python3 temp.py
Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
b'/tmp/try_flags_bg7m03hd.c:4:19: fatal error: cudnn.h: No such file or directory\ncompilation terminated.\n'
Mapped name None to device cuda: TITAN X (Pascal) (0000:01:00.0)
[GpuElemwise{exp,no_inplace}(<GpuArrayType<None>(float64, vector)>), HostFromGpu(gpuarray)(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.390976 seconds
Result is [ 1.23178032 1.61879341 1.52278065 ..., 2.20771815 2.29967753
1.62323285]
Used the gpu
这台机器上有 2 个 Titan X。在 TensorFlow 上运行良好。我没有使用 .theanorc 文件,但我同时设置了:
(python35) rll@ip-30-92:~$ echo $LD_LIBRARY_PATH
/usr/local/cuda-8.0/lib64
(python35) rll@ip-30-92:~$ echo $CUDA_ROOT
/usr/local/cuda-8.0/
我按照说明做了所有事情,尽管有一些警告,但没有错误。
我不认为这是 compile dir 的权限错误.theano
,因为如果我 chown .theano
dir 行为是相同的。
我怎样才能解决这个问题?