支持 GPU 的 theano

问题描述

我按照此处的说明安装了 cuda 和 cudnn: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html

之后我用python3.8设置了conda环境并安装了theano 1.0.4。 然后我在我的主目录中创建一个 .theanorc:

[global]
floatX = float32
device = cuda0
force_device = True
optimizer_including=cudnn

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

[dnn]
include_path=/usr/local/cuda-11.3/include
library_path=/usr/local/cuda-11.3/lib64

[cuda]
root=/usr/local/cuda-11.3/

因为一开始theano抱怨找不到cudnn.h,我把所有cudnn的东西都链接到了/usr/local/cuda-11.3/目录中。

在我尝试在 python 会话中导入 theano 之后,我得到了:

Can not use cuDNN on context None: cannot compile with cuDNN. We got this error:
b"/home/hadron/myutils/anaconda3/envs/myenv/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /usr/local/cuda-11.3/lib64/libcudnn.so: undefined reference to `memcpy@GLIBC_2.14'\ncollect2: error: ld returned 1 exit status\n"

现在我被困在这里了。任何人都可以帮忙吗? 这是 nvidia-smi 的输出

(myenv) hadronmachine:~$ nvidia-smi 
Mon Apr 19 10:43:37 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
|  0%   38C    P8     7W / 210W |     72MiB /  8119MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1080      G   /usr/lib/xorg/Xorg                 70MiB |
+-----------------------------------------------------------------------------+

我正在运行 ubuntu 20.04 并且 uname -a 的输出是:

Linux hadron01 5.4.0-53-generic #59-Ubuntu SMP Wed Oct 21 09:38:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

最终我想运行带有 GPU 支持的 Pymc3,它使用 Theano 作为后端

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)