通过改变环境变量切换 CUDA 版本
2019-07-26 本文已影响0人
阿o醒
ORIGINAL_CUDA_HOME=$CUDA_HOME
ORIGINAL_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-9.0(or your version)
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
# your code here
CUDA_HOME=$ORIGINAL_CUDA_HOME
export LD_LIBRARY_PATH=$ORIGINAL_LD_LIBRARY_PATH
unset ORIGINAL_CUDA_HOME
unset ORIGINAL_LD_LIBRARY_PATH