Ranj
Ranj

Reputation: 788

Why do I get an ImportError when I import TensorFlow?

I'm trying to install tensorflow and now I'm stuck with the following warning:

ranj@ranj-Aspire-V3-772G:~$ python3 -c 'import tensorflow as tf; print(tf.__version__)'  # for Python 3Traceback (most recent call last):
  ...
  File "/usr/lib/python3.5/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libnvidia-fatbinaryloader.so.375.39: 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 "<string>", line 1, in <module>
  ...
  File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: libnvidia-fatbinaryloader.so.375.39: 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.

Can someone tell me how I can solve it?

Upvotes: 1

Views: 247

Answers (2)

Ranj
Ranj

Reputation: 788

I finally fixed it in gnome (ctrl+alt+f3) and logged in with my account and then used: "sudo init 3" "sudo -i" Went to downloads dir and installed the nvidia driver: "sh NVIDIAxxx.run" "reboot"

In the gnome I can use python3 and import tensorflow

The problem is now that I cannot login to the os in the normal manner. I still can log into the gmome

Upvotes: 0

kafman
kafman

Reputation: 2860

I'm not sure what exactly caused the error you report, but it seems like an issue with CUDA and/or communication with the NVIDIA card in general. Also, I don't know why the installation of the graphics driver failed as you mention in the comments, but if you want to have GPU support, having a working graphics driver is essential obviously. So either the driver you have currently installed works fine already or then you will have to find out why installing a new version of the driver fails.

You could proceed like this:

  • Make sure your graphics card fulfills the requirements (CUDA compute capability >= 3.0, check the compute capability of your card here).
  • Make sure your installation of cuDNN and CUDA Toolkit works fine. For this, you could follow the instructions here (point 6.2.2).
  • If this works fine, it might just be that Tensorflow cannot find the required CUDA libraries. Check this related Stackoverflow post: GPU tensorflow install issue

As a side note: the tutorial you linked in the comments seems to suggest that you have to build Tensorflow from source using bazel, which is in fact not always necessary. I would recommend you take a look at the official installation instructions - those are pretty comprehensive and consider all the details you require for the installation. So if all fails, consider starting from scratch and follow the official tutorial linked above.

Upvotes: 1

Related Questions