I am trying to import pycuda-2021.1 in a python script. My OS is Ubuntu 18.04. I have cuda toolkit 11.2 installed and my nvidia driver version is 460.27.04. My python interpretor is Python 3.8. When I execute
import pycuda.driver as cuda
I seem to be able to do so without executing the python script under sudo. However, when using sudo, this leads to the following error:
ImportError: libcurand.so.10: cannot open shared object file: No such file or directory
How can I resolve this issue?
I've found a solution myself, by refering to this post: 完美解决ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory (this post is in Chinese). Basically, the solution is to execute the following command:
sudo ldconfig /path/to/your/cuda/lib64
which in my case should be
sudo ldconfig /usr/local/cuda-11.2/lib64