简体   繁体   中英

Tensorflow-gpu installation issue on ubuntu16.04

I have a linux machine running Ubuntu16.04, NVIDIA GEFORCE1060. I am running python3.6 (installed using anaconda) and CUDA9.1

I was happily coding in tensorlow with CPU with no issues. Then I wanted to install tensorflow-gpu and that's where I am having issues.

First installed cudnn7.1.2 successfully ( make and run mnist-cudnn completed successfully)

pip3 install tensorflow_gpu-1.7.0-cp36-cp36m-manylinux1_x86_64.whl


import tensorflow as tf

I am getting the following errors

Traceback (most recent call last):
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/bony/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/bony/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/bony/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/home/bony/anaconda3/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/bony/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.

Any help to resolve this and get me going on tensorflow-gpu will be appreciated

  • I have the same issue with you on Ubuntu 16.04
  • This my solution
  • First,on the official web page part of NVIDIA requirements to run TensorFlow with GPU support we can know :

    • CUDA® Toolkit 9.0.
    • cuDNN v7.0.
    • GPU card with CUDA Compute Capability 3.0 or higher for building from source and 3.5 or higher for our binaries
  • So uninstall Cuda9.1.

    • If you do not know how to uninstall,you can install Synaptic Package Manager in Ubuntu Software,and Search cuda and select Mark for complete removal
    • Apply
    • Reload Synaptic Package Manager
    • Select Cuda-9.0 Mark for install
    • Apply
  • Install cnDNN v7.0

    • I had download cuDNN v7.0.5 Developer Library for Ubuntu16.04 (Deb) ,because it is the latest version cuDNN v7.0 for Cuda-9.0
  • Install cuda-command-line-tools

    sudo apt-get install cuda-command-line-tools

    • If can not find cuda-command-line-tools

      sudo apt-cache search cuda-command-line-tool

      And select install cuda-command-line-tool-9.0

  • Follow official document,add its path to your LD_LIBRARY_PATH environment variable

    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:+${LD_LIBRARY_PATH}:}/usr/local/cuda/extras/CUPTI/lib64

  • I am using Anaconda3, i use conda command create environment include py3.5 name py35.

  • So,i use source activate py35 and use pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.7.0-cp35-cp35m-linux_x86_64.whl .
  • You can select tensorflow-gpu which one support you python version.

  • Validate your installation

    • Run a short TensorFlow program import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
    • If the system outputs Hello, TensorFlow! , then you are ready to begin writing TensorFlow programs.

在此处输入图片说明 Good luck to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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