我有一台装有GeForce 940 MX的笔记本电脑。我想让Tensorflow在gpu上运行。我从他们的教程页面安装了所有内容,现在当我导入Tensorflow时,我得到了
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:119] Couldn't open CUDA library libcuda.so.1. LD_LIBRARY_PATH:
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: workLaptop
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: Permission denied: could not open driver version path for reading: /proc/driver/nvidia/version
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1092] LD_LIBRARY_PATH:
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1093] failed to find libcuda.so on this system: Failed precondition: could not dlopen DSO: libcuda.so.1; dlerror: libnvidia-fatbinaryloader.so.367.57: cannot open shared object file: No such file or directory
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
>>>
之后我认为它只是切换到在cpu上运行。
编辑:在我完成所有事情之后,从头开始。现在我明白了:>>> import tensorflow
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:119] Couldn't open CUDA library libcuda.so.1. LD_LIBRARY_PATH: :/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:165] hostname: workLaptop
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:189] libcuda reported version is: Not found: was unable to find libcuda.so DSO loaded into this program
I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:193] kernel reported version is: Permission denied: could not open driver version path for reading: /proc/driver/nvidia/version
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1092] LD_LIBRARY_PATH: :/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1093] failed to find libcuda.so on this system: Failed precondition: could not dlopen DSO: libcuda.so.1; dlerror: libnvidia-fatbinaryloader.so.367.57: cannot open shared object file: No such file or directory
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
答案 0 :(得分:6)
libcuda.so.1是特定于NVIDIA驱动程序版本的文件的符号链接。它可能指向错误的版本,或者可能不存在。
# See where the link is pointing.
ls /usr/lib/x86_64-linux-gnu/libcuda.so.1 -la
# My result:
# lrwxrwxrwx 1 root root 19 Feb 22 20:40 \
# /usr/lib/x86_64-linux-gnu/libcuda.so.1 -> ./libcuda.so.375.39
# Make sure it is pointing to the right version.
# Compare it with the installed NVIDIA driver.
nvidia-smi
# Replace libcuda.so.1 with a link to the correct version
cd /usr/lib/x86_64-linux-gnu
sudo ln -f -s libcuda.so.<yournvidia.version> libcuda.so.1
现在以相同的方式,从libcuda.so.1创建另一个符号链接到LD_LIBRARY_PATH directory中同名的链接。
您可能还会发现需要在名为libcuda.so的/ usr / lib / x86_64-linux-gnu中创建指向libcuda.so.1的链接
答案 1 :(得分:5)
万一仍然有人遇到这种情况。首先,请确保添加--runtime=nvidia
参数以运行容器。
docker run --runtime=nvidia -t tensorflow/serving:latest-gpu
其中tensorflow/serving:latest-gpu
是Docker映像的名称。
答案 2 :(得分:1)
在我刚刚解决的情况下,它是将GPU驱动程序更新为最新版本并安装了cuda工具包。首先,添加了ppa并安装了GPU驱动程序:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-390
添加ppa后,它会显示驱动程序版本的选项,并且390是显示的最新“稳定”版本。
然后安装cuda工具包:
sudo apt install nvidia-cuda-toolkit
然后重新启动:
sudo reboot
它将驱动程序更新为比第一步最初安装的390更新的版本(它是410;这是AWS上的p2.xlarge实例)。
答案 3 :(得分:-1)
如果在Docker上使用Tensorflow,则必须具有nvidia-docker 2.0版本。否则,加载libcuda.so.1时将出错。 链接到在Ubuntu 18.04上进行安装的教程: https://medium.com/@sh.tsang/docker-tutorial-5-nvidia-docker-2-0-installation-in-ubuntu-18-04-cb80f17cac65