3

I was working with the tensorflow(GPU version) module in Pycharm. If I run a script from terminal, it works as expected. However when I run the script from pycharm, it says:

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

How do I resolve this?

enter image description here

enter image description here

Pycharm interpreter shows tensorflow as a package.

In the terminal, when I check for the version of tensorflow, it was the same as in pycharm (0.10.0rc0)

humble
  • 2,016
  • 4
  • 27
  • 36

1 Answers1

2

Looks like your CUDA_HOME or LD_LIBRARY_PATH configured correctly in the console, but not in PyCharm. You can check and compare their values, in console do

echo $CUDA_HOME
echo $LD_LIBRARY_PATH

In PyCharm (say, in your main script):

import os
print(os.environ.get('CUDA_HOME'))
print(os.environ.get('LD_LIBRARY_PATH'))

You can configure them for the given Run Configuration in Environment Variables section.

Better approach would be configuring those environment variables globally, so every process in the system would have an access to them. To do that you have to edit /etc/environment file and add original values, which you got from console.

Here are very similar problems: one, two, three.

grundic
  • 4,641
  • 3
  • 31
  • 47
  • Running in terminal gives me 1) /usr/local/cuda ,2)/usr/local/cuda/lib64 Running in pycharm gives 1) None ,2)/home/raghav/Downloads/pycharm-community-2017.1.3/bin: . Could you please guide me – humble Jun 09 '17 at 10:47
  • @rjmessibarca, what OS do you use? – grundic Jun 09 '17 at 10:57
  • I use ubuntu 16 @grundic – humble Jun 09 '17 at 11:01
  • Then you can set environment variables in `.bashrc` file as describe [here](http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu). Or you can configure them in PyCharm `Run Configuration`: Run -> Edit Configurations... -> Environment Variables and set same values as you got from console. – grundic Jun 09 '17 at 11:07
  • I was able to add using Run > Edit Configurations ... How do I add for all the python files? Also does the output of LD_LIBRARY_Path also need to be same? – humble Jun 09 '17 at 11:13
  • @rjmessibarca to configure it globally you have to add it to `~/.bashrc` file or to `/etc/environment`. You can read more [here](https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables). It's better to re-login after you finish your configuration, so PyCharm would have a chance to reload variables. – grundic Jun 09 '17 at 11:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/146253/discussion-between-rjmessibarca-and-grundic). – humble Jun 09 '17 at 11:20