Tensorflow GPU Python 3.5. Eclipse has error: ImportError: libcudart.so.8.0: cannot open shared object file:

丶灬走出姿态 提交于 2019-12-13 17:24:05

问题


I installed Tensorflow GPU v1.0 on Python 3.5 Anaconda envrionment. All seems fine. I can run Juputer notebook and in terminal, the following lines. It tells GPU is running fine:

import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))



====Output
Python 3.5.3 |Continuum Analytics, Inc.| (default, Mar  6 2017, 11:58:13) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened    CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))


…

I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0 1 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0:   Y Y 
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 1:   Y Y 
…

But, in Eclipse, I set environment by select Ananconda/env//bin/python. Above 2 GPU validation lines gives error:

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

I tried Tensorflow CPU in another Anaconda environment, Jupyter, terminal, Eclipse, all GOOD!

What's missing in Eclipse for tensorflow GPU? Any extra step to make Eclipse work for Tensoflow GPU v1.0.

========Error Message========

File "/home/<username>/anaconda3/envs/dl-conda-py35/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/<username>/anaconda3/envs/dl-conda-py35/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

But the file: libcudart.so.8.0 exist.

$ls /usr/local/cuda/lib64/libcudart.so.8.0
/usr/local/cuda/lib64/libcudart.so.8.0

I Setup Eclipse Python interpreter same way as Tensorflow CPU (CPU has no problem). But GPU tensorflow has problem.


回答1:


interestingly, I followed ruoho ruotsi instructions. When I start eclipse with sudo ./yourEclipse/eclipse, it can't still find cuda, but without sudo,it can.

update: if I use sudo to launch eclipse, I have to add LD_LIBRARY_PATH=:/usr/local/cuda/lib64 in eclipse by setting Run configurations -> environment variables.




回答2:


You have a similar problem to this cuda7.5 question. Have a quick glance.

I recommend adding the CUDA lib folder to your PYTHONPATH when running the IDE.

PYTHONPATH=$PYTHONPATH:/usr/local/cuda/lib64 ./myEclipseFolder/eclipse

In a nutshell, because you can work from the command line but not from the Eclipse IDE, you have to configure the Eclipse python interpreter correctly and point it to the correct CUDA lib & bin paths. This is not required for TensorFlow CPU, which doesn't rely on libcudart.so Good luck!

Update -- added Liclipse/PyDev screenshot:

Update 2: Running the code above this is the message I get, TF GPU is working:




回答3:


In this case, I think that the first thing would be running it from the command line... after that, my suggestion is starting Eclipse from that same shell and then checking if all environment variables when you launch it match the ones from the shell.

As a note, the PYTHONPATH is a special variable in PyDev made up from the files you add in the interpreter and in source folders in projects, so, to check the PYTHONPATH my suggestion is creating a program with:

import sys
print('\n'.join(sorted(sys.path)))

and run that from the command line and from inside Eclipse to compare what may be different (and fix the configuration on PyDev accordingly).



来源:https://stackoverflow.com/questions/42914325/tensorflow-gpu-python-3-5-eclipse-has-error-importerror-libcudart-so-8-0-can

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!