Linux 服务器下非root用户安装CUDA完整流程(多次踩雷经验总结)
# 设置CUDA版本变量
export CUDA_VERSION="10.1"
# 下载CUDA Toolkit
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub
sudo apt-get update
# 安装CUDA Toolkit
sudo apt-get -y install cuda
# 配置环境变量
echo 'export PATH=/usr/local/cuda-'$CUDA_VERSION'/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-'$CUDA_VERSION'/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
# 验证CUDA安装
nvcc --version
这段代码提供了一个简化的示例,展示了如何在非root用户下安装特定版本的CUDA Toolkit。代码中使用了环境变量来保证版本的灵活性,并且在安装完成后通过nvcc --version
命令验证了CUDA是否成功安装。
评论已关闭