PyCharm - ImportError: libcurand.so.8.0: cannot open shared object file: No such file or directory
终端 (Terminal) 命令执行正常,PyCharm 中执行报错:ImportError: libcurand.so.8.0: cannot open shared object file: No such file or directory。
1. cat ~/.bashrc
确保环境变量设置正常。
strong@foreverstrong:~$ cat ~/.bashrc
......
# foreverstrong cuda-8.0
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
2. ll /usr/local/cuda*
确保 CUDA - cuDNN 安装正常。
strong@foreverstrong:~$ ll /usr/local/cuda*
lrwxrwxrwx 1 root root 19 Oct 15 20:14 /usr/local/cuda -> /usr/local/cuda-8.0/
/usr/local/cuda-10.0:
total 80
drwxr-xr-x 19 root root 4096 Oct 15 19:54 ./
drwxr-xr-x 12 root root 4096 Oct 15 20:14 ../
drwxr-xr-x 3 root root 4096 Oct 15 19:54 bin/
drwxr-xr-x 5 root root 4096 Oct 15 19:53 doc/
drwxr-xr-x 5 root root 4096 Oct 15 19:54 extras/
drwxr-xr-x 6 root root 4096 Oct 15 20:27 include/
drwxr-xr-x 5 root root 4096 Oct 15 19:53 jre/
drwxr-xr-x 3 root root 4096 Oct 15 20:32 lib64/
drwxr-xr-x 8 root root 4096 Oct 15 19:53 libnsight/
drwxr-xr-x 7 root root 4096 Oct 15 19:53 libnvvp/
drwxr-xr-x 8 root root 4096 Oct 15 19:54 NsightCompute-1.0/
drwxr-xr-x 2 root root 4096 Oct 15 19:53 nsightee_plugins/
drwxr-xr-x 3 root root 4096 Oct 15 19:53 nvml/
drwxr-xr-x 7 root root 4096 Oct 15 19:53 nvvm/
drwxr-xr-x 2 root root 4096 Oct 15 19:54 pkgconfig/
drwxr-xr-x 11 root root 4096 Oct 15 19:54 samples/
drwxr-xr-x 3 root root 4096 Oct 15 19:53 share/
drwxr-xr-x 2 root root 4096 Oct 15 19:53 src/
drwxr-xr-x 2 root root 4096 Oct 15 19:53 tools/
-rw-r--r-- 1 root root 22 Oct 15 19:54 version.txt
/usr/local/cuda-8.0:
total 72
drwxr-xr-x 17 root root 4096 Oct 15 20:14 ./
drwxr-xr-x 12 root root 4096 Oct 15 20:14 ../
drwxr-xr-x 3 root root 4096 Oct 15 20:14 bin/
drwxr-xr-x 5 root root 4096 Oct 15 20:14 doc/
drwxr-xr-x 5 root root 4096 Oct 15 20:14 extras/
drwxr-xr-x 5 root root 4096 Oct 15 20:18 include/
drwxr-xr-x 5 root root 4096 Oct 15 20:14 jre/
drwxr-xr-x 3 root root 4096 Oct 15 20:21 lib64/
drwxr-xr-x 8 root root 4096 Oct 15 20:14 libnsight/
drwxr-xr-x 7 root root 4096 Oct 15 20:14 libnvvp/
drwxr-xr-x 3 root root 4096 Oct 15 20:14 nvml/
drwxr-xr-x 7 root root 4096 Oct 15 20:14 nvvm/
drwxr-xr-x 2 root root 4096 Oct 15 20:14 pkgconfig/
drwxr-xr-x 11 root root 4096 Oct 15 20:14 samples/
drwxr-xr-x 3 root root 4096 Oct 15 20:14 share/
drwxr-xr-x 2 root root 4096 Oct 15 20:14 src/
drwxr-xr-x 2 root root 4096 Oct 15 20:14 tools/
-rw-r--r-- 1 root root 20 Oct 15 20:14 version.txt
strong@foreverstrong:~$
3. PyCharm 没有继承终端设置的环境变量
通过桌面快捷方式打开 PyCharm,PyCharm 没有继承终端设置的环境变量。
3.1. 解决方法 1
在 PyCharm 中针对项目设置环境变量。每创建一个项目,都需要设置一下 PyCharm 环境变量。
Run -> Edit Configurations -> Environment -> Environment Variables 添加 LD_LIBRARY_PATH 内容,即可解决问题
3.2. 解决方法 2
终端打开的 PyCharm 会继承 .bashrc
中设置的环境变量。
PyCharm 安装目录 /home/strong/software/pycharm-2016.3.3,执行 /home/strong/software/pycharm-2016.3.3/bin 目录下的 pycharm.sh 脚本打开 pycharm 继承终端设置的环境变量。
strong@foreverstrong:~$ /home/strong/software/pycharm-2016.3.3/bin/pycharm.sh
strong@foreverstrong:~$
References
[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/