4

I used the spyder or terminal to run the mnist_deep.py program , it can run normally, but when i run the program using pycharm, it will cause an error.The Project Interpreter is 2.7.12(~/anaconda2/bin/python). Error Type: 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

davabo
  • 41
  • 1
  • 3
  • Please edit your question to post the [minimal code that reproduces the problem that you're asking about](http://stackoverflow.com/help/mcve). – koceeng Mar 07 '17 at 00:58

2 Answers2

5

It's preferable to do a system-wide configuration instead of editing ~/.bashrc. Create a .conf file in /etc/ld.so.conf.d/:

sudo nano /etc/ld.so.conf.d/nvidia.conf

Add this:

/usr/local/cuda-8.0/lib64
/usr/local/cuda-8.0/lib  # you probably don't need this line; check
                         # if the directory exists

Then run sudo ldconfig. Hope this brings you joy.

crypdick
  • 16,152
  • 7
  • 51
  • 74
  • 1
    I've been looking for something like this since months. Thanks a lot for this. And yes, starting from cuda-8.0 and above, you might not require the second line. – End-2-End May 17 '18 at 08:04
1

In my case, I had installed tensorflow-gpu on a machine without a GPU. Uninstalling it fixed the problem

pip uninstall tensorflow-gpu
pip install tensorflow --ignore-installed

Without the 2nd step, I was getting an error No module named tensorflow (ref)

Shadi
  • 9,742
  • 4
  • 43
  • 65