CUDA安装
最快速的办法,进入cuda官网,Linux->x86_64->Ubuntu->24.04->reunfile(local)按照提示两步解决:
Installation Instructions:
wget https://developer.download.nvidia.com/compute/cuda/12.8.1/local_installers/cuda_12.8.1_570.124.06_linux.run
sudo sh cuda_12.8.1_570.124.06_linux.run
但是我出现了一个报错:
WARNING: An NVIDIA kernel module 'nvidia-uvm' appears to be already loaded in your kernel. This may be because it is in use (for example, by an X server, a CUDA program, or the NVIDIA Persistence Daemon), but this may also happen if your kernel was configured without support for module unloading. Some of the sanity checks that nvidia-installer performs to detect potential installation problems are not possible while an NVIDIA kernel module is running.
-> Would you like to continue installation and skip the sanity checks? If not, please abort the installation, then close any programs which may be using the NVIDIA GPU(s), and attempt installation again. (Answer: Abort installation)
ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.
解决方案是将被占用的模块全部关闭:
sudo systemctl isolate multi-user.target
sudo modprobe -r nvidia_uvm
sudo modprobe -r nvidia_drm
sudo modprobe -r nvidia_modeset
sudo modprobe -r nvidia
重新执行驱动安装脚本:
sudo sh cuda_12.8.1_570.124.06_linux.run
最后配置环境变量
- 打开文件:
vim ~/.bashrc
- 在文件末尾添加:
# CUDA 12.8 settings
export PATH=/usr/local/cuda-12.8/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64:$LD_LIBRARY_PATH
保存并退出后:
- 激活环境:
source ~/.bashrc