简体   繁体   English

使用GCloud(GCE VM)并在CUDA中安装tensorflow-gpu软件包的Python错误

[英]Python Error using GCloud ( GCE VM ) and installing tensorflow-gpu package with CUDA

Trying to install tensorflow-gpu with cuDNN/CUDA for NVIDIA Tesla K80 on us-central1-w on Ubuntu 16.04 with 25 gb of disk space. 尝试在具有25 gb磁盘空间的Ubuntu 16.04上的us-central1-w上为NVIDIA Tesla K80安装带有cuDNN / CUDA的tensorflow-gpu Any idea why I'm getting the below error ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory , when trying to launch the GPU in Python 2.7? 知道为什么我得到以下错误ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory尝试在Python 2.7中启动GPU时ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory吗? What code will fix this? 什么代码可以解决这个问题? Is there an easier workaround? 有没有更简单的解决方法?

Download CUDA 下载CUDA

sudo su

curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
dpkg -i ./cuda-repo-ubuntu1604_8.0.61-1_amd64.deb
apt-get update
apt-get -y install cuda-8.0
nvidia-smi -pm 1 
nvidia-smi

Install cuDNN v6.0 安装cuDNN v6.0

CUDNN_TAR_FILE="cudnn-8.0-linux-x64-v6.0.tgz"
wget http://developer.download.nvidia.com/compute/redist/cudnn/v6.0/${CUDNN_TAR_FILE}
tar -xzvf ${CUDNN_TAR_FILE}
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/lib64/libcudnn*

Export Paths 导出路径

echo 'export CUDA_HOME=/usr/local/cuda' >> ~/.bashrc
echo 'export PATH=$PATH:$CUDA_HOME/bin' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$CUDA_HOME/lib64' >> ~/.bashrc
source ~/.bashrc

Install Python 2.7 support for Tensorflow w/GPUs 为带有GPU的Tensorflow安装Python 2.7支持

sudo apt-get -y install python-dev
sudo apt-get -y install python-pip 
sudo pip install --upgrade pip
sudo apt-get -y install libcupti-dev 
sudo -H pip install tensorflow-gpu
sudo -H pip install --upgrade tensorflow-gpu

python # Launch Python

From Python >>> prompt, run: 在Python >>>提示符下,运行:

import tensorflow as tf

Error output in Python: Python中的错误输出:

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <modu
le>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74,
 in <module>
    raise ImportError(msg)
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py",    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

References: 参考文献:

Gist Startup Script https://gist.github.com/mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45 Gist启动脚本 https://gist.github.com/mjdietzx/0ff77af5ae60622ce6ed8c4d9b419f45

Using a GPU & TensorFlow on Google Cloud Platform https://medium.com/google-cloud/using-a-gpu-tensorflow-on-google-cloud-platform-1a2458f42b0 在Google Cloud Platform上使用GPU和TensorFlow https://medium.com/google-cloud/using-a-gpu-tensorflow-on-google-cloud-platform-1a2458f42b0

The Tensorflow Linux version has now moved to CUDA 9.0. Tensorflow Linux版本现已移至CUDA 9.0。 You either need to install an older version or use CUDA 9+ 您需要安装旧版本或使用CUDA 9+

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

If you are installing TensorFlow with GPU support using one of the mechanisms described in this guide, then the following NVIDIA software must be installed on your system: 如果要使用本指南中描述的机制之一安装具有GPU支持的TensorFlow,则必须在系统上安装以下NVIDIA软件:

CUDA® Toolkit 9.0. CUDA®工具包9.0。 For details, see NVIDIA's documentation. 有关详细信息,请参阅NVIDIA文档。 Ensure that you append the relevant Cuda pathnames to the LD_LIBRARY_PATH environment variable as described in the NVIDIA documentation. 确保按照NVIDIA文档中的说明将相关的Cuda路径名附加到LD_LIBRARY_PATH环境变量。

The NVIDIA drivers associated with CUDA Toolkit 9.0. 与CUDA Toolkit 9.0关联的NVIDIA驱动程序。 cuDNN v7.0. cuDNN v7.0。 For details, see NVIDIA's documentation. 有关详细信息,请参阅NVIDIA文档。 Ensure that you create the CUDA_HOME environment variable as described in the NVIDIA documentation. 确保按照NVIDIA文档中的说明创建CUDA_HOME环境变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM