297 字
1 分钟
960 次阅读
Ubuntu24.04安装多版本CUDA
进入官方下载页,确认版本无误后开始下载安装

按空格取消第一个选项(驱动)的勾选,然后选择Install,下一步会出现yes or no选择no

等待出现以下代码表示安装成功
============ Summary ============
Driver: Not SelectedToolkit: Installed in /usr/local/cuda-12.8/
Please make sure that - PATH includes /usr/local/cuda-12.8/bin - LD_LIBRARY_PATH includes /usr/local/cuda-12.8/lib64, or, add /usr/local/cuda-12.8/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.8/bin***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 570.00 is required for CUDA 12.8 functionality to work.To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file: sudo <CudaInstaller>.run --silent --driver
Logfile is /var/log/cuda-installer.log然后我们需要配置环境变量以确保两个cuda的共存
sudo vim ~/.bashrc添加以下内容来设置
alias cuda128='export PATH=/usr/local/cuda-12.8/bin:$PATH; export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64:$LD_LIBRARY_PATH'
alias cuda129='export PATH=/usr/local/cuda-12.9/bin:$PATH; export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:$LD_LIBRARY_PATH'修改以下内容选择你需要默认的cuda版本,如果要12.8就替换掉下面的12.9
export PATH=/usr/local/cuda-12.9/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:$LD_LIBRARY_PATH验证
nvcc --versioncuda128 #用于切换到CUDA12.8版本nvcc --versioncuda129 #用于切换到CUDA12.9版本nvcc --version
Ubuntu24.04安装多版本CUDA
https://nvcc-v.com/2025/07/20/ubuntu-multi-cuda-setup/ KEEP EXPLORING