Ubuntu 18.04 安装 nvidia 显卡驱动 离线安装
- 1 系统
- 2 查看显卡
- 2.1 更新 pci.ids 文件
- 3 安装显卡驱动 510.54
- 3.1 安装 nvtop
- 4 禁用 nouveau
- 5 安装 cuda 11.6.1
- 5.1 设置环境变量
1 系统
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
# uname -a
Linux k016 4.15.0-202-generic #213-Ubuntu SMP Thu Jan 5 19:19:12 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
2 查看显卡
# lspci | grep -i nvidia
41:00.0 VGA compatible controller: NVIDIA Corporation Device 2204 (rev a1)
41:00.1 Audio device: NVIDIA Corporation Device 1aef (rev a1)
2.1 更新 pci.ids 文件
识别pci设备 厂商名称、设备型号
# update-pciids
Downloaded daily snapshot dated 2023-01-26 03:15:02
# lspci | grep -i nvidia
41:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)
41:00.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
3 安装显卡驱动 510.54
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/510.54/NVIDIA-Linux-x86_64-510.54.run
sudo sh NVIDIA-Linux-x86_64-510.54.run
# nvidia-smi
Mon Jan 30 12:57:50 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.54 Driver Version: 510.54 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:42:00.0 Off | N/A |
| 37% 33C P0 N/A / 350W | 0MiB / 24576MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
3.1 安装 nvtop
# nvtop
Command 'nvtop' not found, but can be installed with:
snap install nvtop
# snap install nvtop
4 禁用 nouveau
# lsmod | grep nouveau
nouveau 1708032 0
mxm_wmi 16384 1 nouveau
wmi 24576 2 mxm_wmi,nouveau
video 49152 1 nouveau
ttm 106496 2 ast,nouveau
drm_kms_helper 172032 3 ast,nvidia_drm,nouveau
i2c_algo_bit 16384 3 igb,ast,nouveau
drm 401408 7 drm_kms_helper,ast,nvidia,nvidia_drm,ttm,nouveau
# echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
# update-initramfs -u
# reboot
lsmod | grep nouveau
5 安装 cuda 11.6.1
wget https://developer.download.nvidia.com/compute/cuda/11.6.1/local_installers/cuda_11.6.1_510.47.03_linux.run
sudo sh cuda_11.6.1_510.47.03_linux.run
- 显卡驱动已经安装,只需要选择
cuda-toolkit
安装
5.1 设置环境变量
vim .bashrc
# CUDA
export PATH=$PATH:/usr/local/cuda-11.6/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.6/lib64
# source .bashrc
# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Thu_Feb_10_18:23:41_PST_2022
Cuda compilation tools, release 11.6, V11.6.112
Build cuda_11.6.r11.6/compiler.30978841_0