I am using Python 3.8 under Anaconda3 on a Ubuntu 18.04 machine, and I am trying to use cuda toolkit 11.2. I have set "CUDA_HOME" properly such that both echo $CUDA_HOME and sudo echo $CUDA_HOME can return the correct CUDA_HOME value. My python script looks something like this:
import os
print(os.environ.get('CUDA_HOME'))
When I execute python myscript.py, the output is fine. However, when I use sudo python myscript.py, the result is None. How can I resolve this issue?
 
    