Search code examples
pythontensorflowcudascreencuda-driver

ImportError: libcuda.so.1: cannot open shared object file


When I run my code with TensorFlow directly, everything is normal.

However, when I run it in a screen window, I get the following error.

ImportError: libcuda.so.1: cannot open shared object file: No such file or directory

I have tried the command:

source /etc/profile

But it doesn't work.

Cause I use ssh to connect to the servers, the screen is necessary.

How can I fix it?


Solution

  • Try to put libcuda.so.1 path to LD_LIBRARY_PATH environment variable.

    For example, if your libcuda.so.1 location is /usr/lib64/nvidia/libcuda.so.1 (source: GitHub issue), you need this:

    export LD_LIBRARY_PATH=/usr/lib64/nvidia/:$LD_LIBRARY_PATH