【发布时间】:2022-10-15 18:10:50
【问题描述】:
我在当前工作目录中创建了一个 python 虚拟环境。它安装了 cuda-python 以及 tensorflow 和其他软件包。我试图运行 以下脚本检查 tensorflow 是否可以访问 GPU。
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
该脚本在运行时引发以下错误 -
could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
根据我在网上看到的,这个错误是由于没有安装 cudnn 和 cudatoolkit 模块造成的。解决方案是使用 anaconda 安装它们,如下所示。
conda install -c anaconda cudnn
上面的命令似乎是在安装安装了 anaconda 的包,但我没有对该目录的写权限。我确实对设置虚拟环境的当前工作目录具有写权限。
现在,有没有办法将 cudnn 和 cuda 工具包安装到当前工作目录中的虚拟环境中? 我基本上想做的是:
source .environment/bin/activate; pip install cudnn;
【问题讨论】:
标签: python tensorflow pip cudnn