I'm using Server (SSH) in my local PC with PyCharm for remote development. I installed tensorflow (pip) from local PC with sudo privilege. When I run tensorflow code in terminal (MobaXterm)
python projects/example.py
Code works but can't save results data in server due to permission, but when I run same code with sudo to solve the permission error.
sudo python projects/example.py
I got the tensorflow import error.
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Furthermore, I set remote development environment in PyCharm and got same error using PyCharm. PyCharm always executing code from server with sudo privilege. This problem is only with tensorflow code. Other code (PyTorch, Caffe etc) working fine with sudo in terminal or in PyCharm.
Kindly suggest me some valuable solutions that
I searched for solution about this problem but I'm unable to find any solution.
I suspect that this is because root has a different environment and environment variables than you have as a normal user.
Either perform the sudo
command with the -E
option to preserve your environment or set LD_LIBRARY_PATH
prior to call python in your sudo command as follows:
sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64/ python projects/example.py