2022年10月12日 星期三

Linux | Nvidia Driver, Cuda安裝與完整移除

這邊筆記幾個常用的Nvidia Driver安裝移除相關指令。


1. 確定要使用的Nvidia Driver與Cuda版本

https://docs.nvidia.com/deploy/cuda-compatibility/index.html
在上述網址找到對應的Driver與Cuda版本

2. 安裝Nvidia Driver


使用 apt search nvidia-driver 去搜尋合適的driver
root@seabios:~# apt search nvidia-driver                                                                                                                                                                    [99/99]
Sorting... Done
Full Text Search... Done
nvidia-384/focal-updates,focal-security 390.154-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-390

nvidia-384-dev/focal-updates,focal-security 390.154-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-390

nvidia-driver-390/focal-updates,focal-security 390.154-0ubuntu0.20.04.1 amd64
  NVIDIA driver metapackage

nvidia-driver-418/focal 430.50-0ubuntu3 amd64
  Transitional package for nvidia-driver-430

nvidia-driver-418-server/focal-updates,focal-security 418.226.00-0ubuntu0.20.04.2 amd64
  NVIDIA Server Driver metapackage

nvidia-driver-430/focal-updates,focal-security 440.100-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-440

nvidia-driver-435/focal-updates 455.45.01-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-455

nvidia-driver-440/focal-updates,focal-security 450.119.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-450

nvidia-driver-440-server/focal-updates,focal-security 450.203.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-450-server

nvidia-driver-450/focal-updates,focal-security 460.91.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-460

nvidia-driver-450-server/focal-updates,focal-security 450.203.03-0ubuntu0.20.04.1 amd64
  NVIDIA Server Driver metapackage

nvidia-driver-455/focal-updates,focal-security 460.91.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-460

nvidia-driver-460/focal-updates,focal-security 470.141.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-470

nvidia-driver-460-server/focal-updates,focal-security 470.141.03-0ubuntu0.20.04.1 amd64
  Transitional package for nvidia-driver-470-server


然後就直接用 apt install nvidia-driver-版號 或其他的版本如server版本

root@seabios:~# apt install nvidia-driver-515-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  dctrl-tools dkms libatomic1:i386 libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgl1:i386
  libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libllvm12:i386 libnvidia-cfg1-515-server libnvidia-common-515-server libnvidia-compute-515-server
  libnvidia-compute-515-server:i386 libnvidia-decode-515-server libnvidia-decode-515-server:i386 libnvidia-encode-515-server libnvidia-encode-515-server:i386 libnvidia-extra-515-server
  libnvidia-fbc1-515-server libnvidia-fbc1-515-server:i386 libnvidia-gl-515-server libnvidia-gl-515-server:i386 libpciaccess0:i386 libsensors5:i386 libstdc++6:i386 libvulkan1:i386 libwayland-client0:i386
  libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-randr0:i386 libxcb-shm0:i386 libxcb-sync1:i386 libxcb-xfixes0:i386 libxcb1:i386
  libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxshmfence1:i386 libxxf86vm1:i386 mesa-vulkan-drivers:i386 nvidia-compute-utils-515-server nvidia-dkms-515-server nvidia-kernel-common-515-server
  nvidia-kernel-source-515-server nvidia-utils-515-server xserver-xorg-video-nvidia-515-server
Suggested packages:
  debtags menu lm-sensors:i386 nvidia-settings nvidia-prime
The following NEW packages will be installed:
  dctrl-tools dkms libatomic1:i386 libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgl1:i386
  libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libllvm12:i386 libnvidia-cfg1-515-server libnvidia-common-515-server libnvidia-compute-515-server
  libnvidia-compute-515-server:i386 libnvidia-decode-515-server libnvidia-decode-515-server:i386 libnvidia-encode-515-server libnvidia-encode-515-server:i386 libnvidia-extra-515-server
  libnvidia-fbc1-515-server libnvidia-fbc1-515-server:i386 libnvidia-gl-515-server libnvidia-gl-515-server:i386 libpciaccess0:i386 libsensors5:i386 libstdc++6:i386 libvulkan1:i386 libwayland-client0:i386
  libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-randr0:i386 libxcb-shm0:i386 libxcb-sync1:i386 libxcb-xfixes0:i386 libxcb1:i386
  libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxshmfence1:i386 libxxf86vm1:i386 mesa-vulkan-drivers:i386 nvidia-compute-utils-515-server nvidia-dkms-515-server nvidia-driver-515-server
  nvidia-kernel-common-515-server nvidia-kernel-source-515-server nvidia-utils-515-server xserver-xorg-video-nvidia-515-server
0 upgraded, 63 newly installed, 0 to remove and 1 not upgraded.
Need to get 335 MB/374 MB of archives.
After this operation, 1392 MB of additional disk space will be used.
Do you want to continue? [Y/n]



3. 安裝各版本Cuda

https://developer.nvidia.com/cuda-toolkit-archive

上述網址下載想要的Cuda版本,照著網頁指示安裝即可


安裝完後確認一下版本

# /usr/local/cuda/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0


4. 完整移除Nvidia Driver



執行下方指令完整移除Nvidia Driver
sudo apt-get remove --purge '^nvidia-.*'
sudo apt-get remove --purge '^libnvidia-.*'
sudo apt-get remove --purge '^cuda-.*'


5. 安裝nvitop


我覺得這套 nvitop nvtop 好用很多,可以在下列網址安裝




沒有留言: