步骤一:
添加环境变量
在~/.bashrc中添加相关cuda路径为/usr/local/cuda
即
sudo vi ~/.bashrc
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda # 不加应该也没问题
export PATH=$PATH:/usr/local/cuda
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
source ~/.bashrc
步骤二:
建立软链接
# 建立软连接,若/usr/local/cuda
sudo ln -s /usr/local/cuda-9.0 /usr/local/cuda
stat cuda # 查看当前软连接的cuda版本
nvcc --version # 查看当前cuda版本
# cuda9.0切换到cuda10.0
rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-10.0 /usr/local/cuda
nvcc --version