How to run Tensorflow GPU in Pycharm?
First Make sure CUDA and CuDNN has been installed successfully and Configuration should be verified.
CUDA driver version should be sufficient for CUDA runtime version.
Once done, Open PyCharm
Goto File->Settings-> Project Interpreter
Select the appropriate Environment which has tensorflow-gpu installed
Select Run->Edit Configuration->Environment Variables
Since the code is searching for libcublas.so.10.0 ,
Assume like path you find "libcublas.so.10.0" is something like "/home/Alex/anaconda3/pkgs/cudatoolkit-10.0.130-0/lib/"
Add the lib path as LD_LIBRARY_PATH in environment variables as
Name : LD_LIBRARY_PATH
Value : /home/Alex/anaconda3/pkgs/cudatoolkit-10.0.130-0/lib/
Save it and then try to import tensorflow
Alex G
Updated on April 11, 2020Comments
-
Alex G about 4 years
I want to run Tensorflow GPU in Pycharm on Linux Mint.
I tried some guides like these
I run this code
import tensorflow as tf sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
I have got this error
Traceback (most recent call last): File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.10.0: 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 "/home/alex/PycharmProjects/TfTestGPU/test.py", line 1, in <module> import tensorflow as tf File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module> from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/alex/anaconda3/envs/TfTestGPU/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help. Process finished with exit code 1
-
qinlong about 5 yearsFirst, check the environment variable configuration. Second, check the versions of the tensorflow, cuda, cudnn, according to tensorflow.org/install/source.
-