修复 TensorFlow libcublas.so.8.0: cannot open shared object file 在 Ubuntu 上

问题:

当你在 Python 中运行 import tensorflow 时,你收到以下错误之一:

libcublas_import_errors.txt
ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
ImportError: libcufft.so.8.0: cannot open shared object file: No such file or directory
ImportError: libcurand.so.8.0: cannot open shared object file: No such file or directory

解决方案

使用以下命令安装所需的包:

install_libs.sh
apt-get install libcublas8.0 libcusolver8.0 libcudart8.0 libcufft8.0 libcurand8.0

注意你还需要安装 cuDNN - 请参见此后续文章在 Ubuntu 上为 TensorFlow GPU 应该安装哪个版本的 CuDNN? 了解如何执行此操作的详情。

如果此方法不起作用,你可以(作为快速变通方法)卸载 tensorflow-gpu 并安装 tensorflow - 没有 GPU 支持的版本:

pip_reinstall_tensorflow.sh
pip uninstall tensorflow-gpu
pip install tensorflow

但是,这可能会使你的应用程序慢得多。

对于其他解决方案,请参见 GitHub 上的 TensorFlow bug 跟踪器


Check out similar posts by category: Linux, Python