Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I import tensorflow

I installed the tensorflow following the instructions from the tensorflow webpage, using the following commands:

sudo apt-get install python-pip python-dev
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.12.0rc0-cp27-none-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL

Then I run python and type in:

import tensorflow

I got these error messages:

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 have google this problem and found answers like https://github.com/tensorflow/tensorflow/issues/1244 and https://github.com/NVIDIA/DIGITS/issues/8 But none of them is helpful to my problem. My python is of version 2.7.6. I was installing the CPU-only version for Linux. When I first installed tensorflow in the above-mentioned way, it worked correctly and I managed to run some tutorial examples. But today I tried to install the anaconda, which is another useful computing toolbox. When I installed it, I found that there was no tensorflow anymore. So I installed tensorflow again using conda. But then the above-mentioned error happens. Now I have removed the anaconda, and removed the environmental path added by anaconda. But the import error stays unsolved. I'm confused about what happened. Thank you all for your kind help!!!!

like image 739
pfc Avatar asked Apr 15 '26 06:04

pfc


1 Answers

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

This suggests that the GPU version of tensorflow is being imported. Maybe you have another version of tensorflow installed? If you install all python packages with pip you can check by listing the installed packages.

like image 119
ben Avatar answered Apr 16 '26 20:04

ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!