Python tensorflow 的 libcublas.so.8.0 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44865253/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 00:32:49  来源:igfitidea点击:

libcublas.so.8.0 error with tensorflow

pythonubuntutensorflow

提问by Shimron F

I am currently trying to run a project from GitHub: https://github.com/nilboy/pixel-recursive-super-resolution

我目前正在尝试从 GitHub 运行一个项目:https: //github.com/nilboy/pixel-recursive-super-resolution

After installing ubuntu on VM, I installed python with tensorflow 2.7 using the pip command.

在 VM 上安装 ubuntu 后,我使用 pip 命令安装了带有 tensorflow 2.7 的 python。

When I try to run the training session with python I get this error:

当我尝试使用 python 运行培训课程时,出现此错误:

ImportError: libcublas.so.8.0: cannot open shared object file: No such file or directory

导入错误:libcublas.so.8.0:无法打开共享对象文件:没有这样的文件或目录

I could't find anything exactly the same, only this error: ImportError: libcudart.so.8.0: cannot open shared object file

我找不到完全相同的东西,只有这个错误: ImportError: libcudart.so.8.0: cannot open shared object file

I am using Yoga 13, so I don't have an NVIDIA GPU and I am trying to run this project on the CPU. Can you help identify the tensorflow problem?

我正在使用 Yoga 13,所以我没有 NVIDIA GPU,我正在尝试在 CPU 上运行这个项目。你能帮助识别张量流问题吗?

Source: https://www.tensorflow.org/install/install_linux

来源:https: //www.tensorflow.org/install/install_linux

回答by u7772176

You need to install Cuda 8.0 and configure the environment as below:

您需要安装 Cuda 8.0 并配置如下环境:

export PATH="$PATH:/usr/local/cuda-8.0/bin"
export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64"

回答by nexoma

may be preinstalled tensorflow-gpu, so

可能预装了tensorflow-gpu,所以

pip3 install tensorflow --ignore-installed

pip3 安装 tensorflow --ignore-installed

as this helped me from stackoverflow

因为这帮助我摆脱了 stackoverflow

回答by Simbarashe Timothy Motsi

It may be an issue with the CUDA version installed. try
$ sudo apt-get install cuda-8-0

可能是安装的 CUDA 版本有问题。试试
$ sudo apt-get install cuda-8-0

回答by James L.

Tensroflow/Keras requirements

Tensroflow/Keras 要求

In my opinion the tricky steps are installing Nvidia drivers and Cuda-8. If you follow the instructions you're gonna have a bad time. Instead install it thru apt:

在我看来,棘手的步骤是安装 Nvidia 驱动程序和 Cuda-8。如果你按照说明你会过得很糟糕。而是通过apt以下方式安装它:

sudo apt-get install nvidia-384 #can type nvidia then hit "tab" to view all available options
sudo apt-get install cuda-8-0

If that doesn't work...good luck. You can try this:

如果那不起作用……祝你好运。你可以试试这个:

Check that you do not have cuda-9: ls /usr/local

检查您是否没有 cuda-9: ls /usr/local

Install Cuda 8.0.

安装 Cuda 8.0。

Reboot

重启

Run export LD_LIBRARY_PATH=/usr/local/cuda-8.0/extras/CUPTI/lib64:$LD_LIBRARY_PATHbut replace /usr/local/cuda-8.0/extras/CUPTI/lib64with the relevant output from echo $LD_LIBRARY_PATH

运行export LD_LIBRARY_PATH=/usr/local/cuda-8.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH但替换/usr/local/cuda-8.0/extras/CUPTI/lib64为相关输出echo $LD_LIBRARY_PATH

Check that it worked nvcc --versionprints out CUDA version

检查它是否有效nvcc --version打印出 CUDA 版本

回答by Umair Qadir

I got the same error while running Tensorflow with GPU support in Python and solved it like this:

我在 Python 中运行具有 GPU 支持的 Tensorflow 时遇到了同样的错误,并像这样解决了它:

$ export PATH="$PATH:/usr/local/cuda-8.0/bin" 
$ export LD_LIBRARY_PATH="/usr/local/cuda-8.0/lib64"

For enabling all users you may have to enter these export statements in etc/environments in Ubuntu

为了启用所有用户,您可能必须在 Ubuntu 的 etc/environments 中输入这些导出语句

回答by Estello

On my computer I had :

在我的电脑上,我有:

cudnn5.1,   
cuda8.0

When importing tensorflow, I had the same error ImportError:

导入tensorflow时,出现同样的错误ImportError:

libcublas.so.8.0: cannot open shared object file: No such file or directory

libcublas.so.8.0:无法打开共享对象文件:没有这样的文件或目录

and even

乃至

libcublas.so.9.0: cannot open shared object file: No such file or directory

libcublas.so.9.0:无法打开共享对象文件:没有这样的文件或目录

To overcome this issue I installed tensorflow 1.4instead of 1.6 and did what Umair Qadir suggested.

为了解决这个问题,我安装tensorflow 1.4了 1.6 而不是 1.6 并按照 Umair Qadir 的建议做了。

But then I had another issue :

但后来我有另一个问题:

libcudnn.so.6: cannot open shared object file: No such file or directory

libcudnn.so.6:无法打开共享对象文件:没有这样的文件或目录

This was because I had cudnn5.1 as required but actually it needs cudnn6

这是因为我需要 cudnn5.1 但实际上它需要 cudnn6

Here are the steps to uninstall cudnn5.1 and install cudnn6:

以下是卸载cudnn5.1和安装cudnn6的步骤:

1- Uninstall cudnn 5.1 rm -f /usr/include/cudnn.h rm -f /usr/lib/x86_64-linux-gnu/libcudnn rm -f /usr/local/cuda-/lib64/libcudnn

1-卸载cudnn 5.1 rm -f /usr/include/cudnn.h rm -f /usr/lib/x86_64-linux-gnu/libcudnn rm -f /usr/local/cuda-/lib64/libcudnn

2- Install cudnn6

2- 安装 cudnn6

After having subscribed to nvdia, go to here https://developer.nvidia.com/rdp/cudnn-downloadand download cudnn6 for cuda8 and then go to the folder where you downloaded the cudnn and do :

订阅 nvdia 后,请转到此处https://developer.nvidia.com/rdp/cudnn-download并下载 cuda8 的 cudnn6,然后转到下载 cudnn 的文件夹并执行以下操作:

$ tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
$ sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp -P cuda/lib64/libcudnn /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h 
/usr/local/cuda/lib64/libcudnn*

Now you should have tensorflow

现在你应该有 tensorflow

Try it on typing in the console:

尝试在控制台中输入:

$python
import tensorflow

If you want to work in anaconda and the error persists , try :

如果您想在 anaconda 中工作并且错误仍然存​​在,请尝试:

$jupyter notebook --generate-config

then you can find the name of the directory where you have your config file (Ill call it

然后你可以找到你的配置文件所在目录的名称(我称之为

) and open /jupyter_notebook_config.py and add at the top :

) 并打开 /jupyter_notebook_config.py 并在顶部添加:

import os
c = get_config()
os.environ['LD_LIBRARY_PATH'] = '/usr/local/cuda-8.0/lib64:usr/local/cuda-8.0/lib64/libcudart.so.8.0'
c.Spawner.env.update('LD_LIBRARY_PATH')

Now it should work...

现在它应该工作...

Here are the websites that helped me:

以下是对我有帮助的网站:

https://askubuntu.com/questions/952075/how-to-upgrade-tensorflow-to-v1-3-cudnn-cuda-upgradehttps://developer.nvidia.com/rdp/cudnn-downloadhttps://medium.com/@ikekramer/installing-cuda-8-0-and-cudnn-5-1-on-ubuntu-16-04-6b9f284f6e77tensorflow gpu can not be called from jupyterhub/jupyter notebook, why?

https://askubuntu.com/questions/952075/how-to-upgrade-tensorflow-to-v1-3-cudnn-cuda-upgrade https://developer.nvidia.com/rdp/cudnn-download https:// medium.com/@ikekramer/installing-cuda-8-0-and-cudnn-5-1-on-ubuntu-16-04-6b9f284f6e77无法从 jupyterhub/jupyter notebook 调用 tensorflow gpu,为什么?