Rexroth
Rexroth

Reputation: 109

How to import GPU tensorflow in Spyder IDE (without anaconda)?

I've recently installed tensorflow with GPU support on my Ubuntu 16.04 successfully and I was able to successfully run some tests in Terminal. Later I decided it would be easier to have an IDE for writing python code, and I'd just import numpy and tensorflow into IDE and run everything there. Having installed Tensorflow successfully I didn't want to create another Anaconda version of everything so I just installed Spyder2 directly from Ubuntu software. However, when I try importing tensorflow in Spyder2

import tensorflow as tf

it failed with following message:

ImportError: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python      
/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python    
/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python 
/pywrap_tensorflow.py", line 24, in swig_import_helper_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)

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


Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python    
interpreter from there.

I could import numpy no problem but not tensorflow. I'm new to Linux; what is it that I'm missing here? Or do I need anaconda in order to use Spyder and Tensorflow? Thanks!

Upvotes: 2

Views: 1823

Answers (1)

John Wakefield
John Wakefield

Reputation: 527

These environment variables must be set to let TensorFlow know where to find Cuda:

LD_LIBRARY_PATH=/usr/local/cuda/lib64
CUDA_PATH=/usr/local/cuda

Upvotes: 1

Related Questions