0、升级内核为5.15.0-88-generic:
0.1 配置下载源:
在/etc/apt/sources.list.d目录下新建list文件,添加内容:
deb http://mirrors.aliyun.com/ubuntu/ focal-updates amin restricted
0.2 下载
sudo apt-get install linux-image-5.15.0-88-generic
sudo apt-get install linux-headers-5.15.0-88
1、安装nvidia驱动
1.1 查看推荐的驱动版本
apt install ubuntu-drivers-common
ubuntu-drivers devices
1.2.安装指定版本
sudo apt install nvidia-driver-535-server
1.3.重启
reboot
1.4. 检查驱动是否安装成功,并检查支持的cuda版本
nvidia-smi
2、安装cuda
2.1 查看查看ubantu版本:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy
2.2 选择对应的版本的cuda:
2.3 下载安装文件,并安装:
wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run
sudo sh cuda_12.2.0_535.54.03_linux.run
2.4 配置CUDA环境变量:
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
2.5 查看是否安装成功:
nvcc -V
3、下载pytorch验证GPU是否可用
pip install torch
import torch
if torch.cuda.is_available():
print("GPU is available")
else:
print("GPU is not available")