1

方式一:使用 ubuntu 自身的 ubuntu-drivers 工具

优点:超级无敌简单,不需要额外下载任何东西
缺点:驱动版本很老

                            ....               pon@M60GPU
              .',:clooo:  .:looooo:.           ----------
           .;looooooooc  .oooooooooo'          OS: Ubuntu noble 24.04 x86_64
        .;looooool:,''.  :ooooooooooc          Host: SYS-1028GR-TRT (123456789)
       ;looool;.         'oooooooooo,          Kernel: Linux 6.8.0-38-generic
      ;clool'             .cooooooc.  ,,       Uptime: 26 days, 7 hours, 59 mins
         ...                ......  .:oo,      Packages: 1007 (dpkg)
  .;clol:,.                        .loooo'     Shell: zsh 5.9
 :ooooooooo,                        'ooool     Terminal: /dev/pts/12
'ooooooooooo.                        loooo.    CPU: Intel(R) Xeon(R) E5-2690 v4 (56) @ 3.50 GHz
'ooooooooool                         coooo.    GPU 1: NVIDIA Tesla M60 [Discrete]
 ,loooooooc.                        .loooo.    GPU 2: NVIDIA Tesla M60 [Discrete]
   .,;;;'.                          ;ooooc     GPU 3: ASPEED Technology, Inc. ASPEED Graphics Family
       ...                         ,ooool.     Memory: 4.16 GiB / 31.26 GiB (13%)
    .cooooc.              ..',,'.  .cooo.      Swap: 256.00 KiB / 16.00 GiB (0%)
      ;ooooo:.           ;oooooooc.  :l.       Disk (/): 27.05 GiB / 816.34 GiB (3%) - ext4
       .coooooc,..      coooooooooo.           Disk (/mnt/data): 3.15 TiB / 4.51 TiB (70%) - ext4
         .:ooooooolc:. .ooooooooooo'           Local IP (ens1f0): 192.168.38.233/24
           .':loooooo;  ,oooooooooc            Locale: en_US.UTF-8
               ..';::c'  .;loooo:'

图片.png

首先使用 ubuntu-drivers devices 命令查看有哪些驱动可以安装

╰─➤  ubuntu-drivers devices


udevadm hwdb is deprecated. Use systemd-hwdb instead.
udevadm hwdb is deprecated. Use systemd-hwdb instead.
udevadm hwdb is deprecated. Use systemd-hwdb instead.
udevadm hwdb is deprecated. Use systemd-hwdb instead.
ERROR:root:aplay command not found
== /sys/devices/pci0000:80/0000:80:03.0/0000:81:00.0/0000:82:08.0/0000:83:00.0 ==
modalias : pci:v000010DEd000013F2sv000010DEsd0000115Ebc03sc02i00
vendor   : NVIDIA Corporation
model    : GM204GL [Tesla M60]
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-535 - distro non-free recommended
driver   : nvidia-driver-535-server - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

选一个最新的 nvidia-driver-535-server

─➤  sudo apt install nvidia-driver-535-server                                                                                                                                                          1 ↵
[sudo] password for pon:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python3-cliapp python3-markdown python3-ttystatus python3-zombie-imp
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  dkms libegl-mesa0 libegl1 libepoxy0 libgbm1 libnvidia-cfg1-535-server libnvidia-common-535-server libnvidia-compute-535-server libnvidia-decode-535-server libnvidia-encode-535-server
  libnvidia-extra-535-server libnvidia-fbc1-535-server libnvidia-gl-535-server libwayland-server0 libxaw7 libxcvt0 libxfont2 libxkbfile1 libxmu6 libxrandr2 nvidia-compute-utils-535-server
  nvidia-dkms-535-server nvidia-firmware-535-server-535.183.01 nvidia-kernel-common-535-server nvidia-kernel-source-535-server nvidia-utils-535-server x11-xkb-utils xcvt xfonts-base xserver-common
  xserver-xorg-core xserver-xorg-video-nvidia-535-server
Suggested packages:
  menu nvidia-settings nvidia-prime xfs | xserver xfonts-100dpi | xfonts-75dpi xfonts-scalable
Recommended packages:
  libnvidia-compute-535-server:i386 libnvidia-decode-535-server:i386 libnvidia-encode-535-server:i386 libnvidia-fbc1-535-server:i386 libnvidia-gl-535-server:i386
The following NEW packages will be installed:
  dkms libegl-mesa0 libegl1 libepoxy0 libgbm1 libnvidia-cfg1-535-server libnvidia-common-535-server libnvidia-compute-535-server libnvidia-decode-535-server libnvidia-encode-535-server
  libnvidia-extra-535-server libnvidia-fbc1-535-server libnvidia-gl-535-server libwayland-server0 libxaw7 libxcvt0 libxfont2 libxkbfile1 libxmu6 libxrandr2 nvidia-compute-utils-535-server
  nvidia-dkms-535-server nvidia-driver-535-server nvidia-firmware-535-server-535.183.01 nvidia-kernel-common-535-server nvidia-kernel-source-535-server nvidia-utils-535-server x11-xkb-utils xcvt
  xfonts-base xserver-common xserver-xorg-core xserver-xorg-video-nvidia-535-server
0 upgraded, 33 newly installed, 0 to remove and 5 not upgraded.
Need to get 333 MB of archives.
After this operation, 820 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 dkms all 3.0.11-1ubuntu13 [51.5 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libwayland-server0 amd64 1.22.0-2.1build1 [33.9 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main amd64 libgbm1 amd64 24.0.9-0ubuntu0.1 [42.7 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/main amd64 libegl-mesa0 amd64 24.0.9-0ubuntu0.1 [115 kB]
Get:5 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libepoxy0 amd64 1.5.10-1build1 [220 kB]
Get:6 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-cfg1-535-server amd64 535.183.01-0ubuntu0.24.04.1 [107 kB]
Get:7 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-common-535-server all 535.183.01-0ubuntu0.24.04.1 [15.4 kB]
Get:8 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-compute-535-server amd64 535.183.01-0ubuntu0.24.04.1 [40.3 MB]
Get:9 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-decode-535-server amd64 535.183.01-0ubuntu0.24.04.1 [1,884 kB]
Get:10 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-encode-535-server amd64 535.183.01-0ubuntu0.24.04.1 [97.1 kB]
Get:11 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-extra-535-server amd64 535.183.01-0ubuntu0.24.04.1 [71.1 kB]
Get:12 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-fbc1-535-server amd64 535.183.01-0ubuntu0.24.04.1 [55.7 kB]
Get:13 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libegl1 amd64 1.7.0-1build1 [28.7 kB]
Get:14 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 libnvidia-gl-535-server amd64 535.183.01-0ubuntu0.24.04.1 [195 MB]
Get:15 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxmu6 amd64 2:1.1.3-3build2 [47.6 kB]
Get:16 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxaw7 amd64 2:1.0.14-1build2 [187 kB]
Get:17 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxcvt0 amd64 0.1.2-1build1 [5,684 B]
Get:18 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxfont2 amd64 1:2.0.6-1build1 [93.0 kB]
Get:19 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxkbfile1 amd64 1:1.1.0-1build4 [70.0 kB]
Get:20 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 libxrandr2 amd64 2:1.5.2-2build1 [19.7 kB]
Get:21 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-compute-utils-535-server amd64 535.183.01-0ubuntu0.24.04.1 [122 kB]
Get:22 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-kernel-source-535-server amd64 535.183.01-0ubuntu0.24.04.1 [45.1 MB]
Get:23 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-firmware-535-server-535.183.01 amd64 535.183.01-0ubuntu0.24.04.1 [39.6 MB]
Get:24 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-kernel-common-535-server amd64 535.183.01-0ubuntu0.24.04.1 [226 kB]
Get:25 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-dkms-535-server amd64 535.183.01-0ubuntu0.24.04.1 [51.5 kB]
Get:26 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-utils-535-server amd64 535.183.01-0ubuntu0.24.04.1 [405 kB]
Get:27 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 x11-xkb-utils amd64 7.7+8build2 [170 kB]
Get:28 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 xserver-common all 2:21.1.12-1ubuntu1 [33.3 kB]
Get:29 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 xserver-xorg-core amd64 2:21.1.12-1ubuntu1 [1,474 kB]
Get:30 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 xserver-xorg-video-nvidia-535-server amd64 535.183.01-0ubuntu0.24.04.1 [1,586 kB]
Get:31 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates/restricted amd64 nvidia-driver-535-server amd64 535.183.01-0ubuntu0.24.04.1 [482 kB]
Get:32 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 xcvt amd64 0.1.2-1build1 [6,982 B]
Get:33 https://mirrors.tuna.tsinghua.edu.cn/ubuntu noble/main amd64 xfonts-base all 1:1.0.5+nmu1 [5,941 kB]
Fetched 333 MB in 2min 42s (2,056 kB/s)
Extracting templates from packages: 100%
Selecting previously unselected package dkms.
(Reading database ... 147083 files and directories currently installed.)
Preparing to unpack .../00-dkms_3.0.11-1ubuntu13_all.deb ...
Unpacking dkms (3.0.11-1ubuntu13) ...
Selecting previously unselected package libwayland-server0:amd64.
Preparing to unpack .../01-libwayland-server0_1.22.0-2.1build1_amd64.deb ...
Unpacking libwayland-server0:amd64 (1.22.0-2.1build1) ...
Selecting previously unselected package libgbm1:amd64.
Preparing to unpack .../02-libgbm1_24.0.9-0ubuntu0.1_amd64.deb ...
Unpacking libgbm1:amd64 (24.0.9-0ubuntu0.1) ...
Selecting previously unselected package libegl-mesa0:amd64.
Preparing to unpack .../03-libegl-mesa0_24.0.9-0ubuntu0.1_amd64.deb ...
Unpacking libegl-mesa0:amd64 (24.0.9-0ubuntu0.1) ...
Selecting previously unselected package libepoxy0:amd64.
Preparing to unpack .../04-libepoxy0_1.5.10-1build1_amd64.deb ...
Unpacking libepoxy0:amd64 (1.5.10-1build1) ...
Selecting previously unselected package libnvidia-cfg1-535-server:amd64.
Preparing to unpack .../05-libnvidia-cfg1-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-cfg1-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-common-535-server.
Preparing to unpack .../06-libnvidia-common-535-server_535.183.01-0ubuntu0.24.04.1_all.deb ...
Unpacking libnvidia-common-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-compute-535-server:amd64.
Preparing to unpack .../07-libnvidia-compute-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-compute-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-decode-535-server:amd64.
Preparing to unpack .../08-libnvidia-decode-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-decode-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-encode-535-server:amd64.
Preparing to unpack .../09-libnvidia-encode-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-encode-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-extra-535-server:amd64.
Preparing to unpack .../10-libnvidia-extra-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-extra-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libnvidia-fbc1-535-server:amd64.
Preparing to unpack .../11-libnvidia-fbc1-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-fbc1-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libegl1:amd64.
Preparing to unpack .../12-libegl1_1.7.0-1build1_amd64.deb ...
Unpacking libegl1:amd64 (1.7.0-1build1) ...
Selecting previously unselected package libnvidia-gl-535-server:amd64.
Preparing to unpack .../13-libnvidia-gl-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking libnvidia-gl-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package libxmu6:amd64.
Preparing to unpack .../14-libxmu6_2%3a1.1.3-3build2_amd64.deb ...
Unpacking libxmu6:amd64 (2:1.1.3-3build2) ...
Selecting previously unselected package libxaw7:amd64.
Preparing to unpack .../15-libxaw7_2%3a1.0.14-1build2_amd64.deb ...
Unpacking libxaw7:amd64 (2:1.0.14-1build2) ...
Selecting previously unselected package libxcvt0:amd64.
Preparing to unpack .../16-libxcvt0_0.1.2-1build1_amd64.deb ...
Unpacking libxcvt0:amd64 (0.1.2-1build1) ...
Selecting previously unselected package libxfont2:amd64.
Preparing to unpack .../17-libxfont2_1%3a2.0.6-1build1_amd64.deb ...
Unpacking libxfont2:amd64 (1:2.0.6-1build1) ...
Selecting previously unselected package libxkbfile1:amd64.
Preparing to unpack .../18-libxkbfile1_1%3a1.1.0-1build4_amd64.deb ...
Unpacking libxkbfile1:amd64 (1:1.1.0-1build4) ...
Selecting previously unselected package libxrandr2:amd64.
Preparing to unpack .../19-libxrandr2_2%3a1.5.2-2build1_amd64.deb ...
Unpacking libxrandr2:amd64 (2:1.5.2-2build1) ...
Selecting previously unselected package nvidia-compute-utils-535-server.
Preparing to unpack .../20-nvidia-compute-utils-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-compute-utils-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-kernel-source-535-server.
Preparing to unpack .../21-nvidia-kernel-source-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-kernel-source-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-firmware-535-server-535.183.01.
Preparing to unpack .../22-nvidia-firmware-535-server-535.183.01_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-firmware-535-server-535.183.01 (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-kernel-common-535-server.
Preparing to unpack .../23-nvidia-kernel-common-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-kernel-common-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-dkms-535-server.
Preparing to unpack .../24-nvidia-dkms-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-dkms-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-utils-535-server.
Preparing to unpack .../25-nvidia-utils-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-utils-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package x11-xkb-utils.
Preparing to unpack .../26-x11-xkb-utils_7.7+8build2_amd64.deb ...
Unpacking x11-xkb-utils (7.7+8build2) ...
Selecting previously unselected package xserver-common.
Preparing to unpack .../27-xserver-common_2%3a21.1.12-1ubuntu1_all.deb ...
Unpacking xserver-common (2:21.1.12-1ubuntu1) ...
Selecting previously unselected package xserver-xorg-core.
Preparing to unpack .../28-xserver-xorg-core_2%3a21.1.12-1ubuntu1_amd64.deb ...
Unpacking xserver-xorg-core (2:21.1.12-1ubuntu1) ...
Selecting previously unselected package xserver-xorg-video-nvidia-535-server.
Preparing to unpack .../29-xserver-xorg-video-nvidia-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking xserver-xorg-video-nvidia-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package nvidia-driver-535-server.
Preparing to unpack .../30-nvidia-driver-535-server_535.183.01-0ubuntu0.24.04.1_amd64.deb ...
Unpacking nvidia-driver-535-server (535.183.01-0ubuntu0.24.04.1) ...
Selecting previously unselected package xcvt.
Preparing to unpack .../31-xcvt_0.1.2-1build1_amd64.deb ...
Unpacking xcvt (0.1.2-1build1) ...
Selecting previously unselected package xfonts-base.
Preparing to unpack .../32-xfonts-base_1%3a1.0.5+nmu1_all.deb ...
Unpacking xfonts-base (1:1.0.5+nmu1) ...
Setting up libnvidia-fbc1-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libnvidia-common-535-server (535.183.01-0ubuntu0.24.04.1) ...
Setting up libwayland-server0:amd64 (1.22.0-2.1build1) ...
Setting up libxmu6:amd64 (2:1.1.3-3build2) ...
Setting up nvidia-kernel-source-535-server (535.183.01-0ubuntu0.24.04.1) ...
Setting up libgbm1:amd64 (24.0.9-0ubuntu0.1) ...
Setting up libxaw7:amd64 (2:1.0.14-1build2) ...
Setting up dkms (3.0.11-1ubuntu13) ...
Setting up xfonts-base (1:1.0.5+nmu1) ...
Setting up libegl-mesa0:amd64 (24.0.9-0ubuntu0.1) ...
Setting up libepoxy0:amd64 (1.5.10-1build1) ...
Setting up libnvidia-extra-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libxrandr2:amd64 (2:1.5.2-2build1) ...
Setting up libnvidia-cfg1-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libnvidia-compute-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libegl1:amd64 (1.7.0-1build1) ...
Setting up libxcvt0:amd64 (0.1.2-1build1) ...
Setting up nvidia-firmware-535-server-535.183.01 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libxkbfile1:amd64 (1:1.1.0-1build4) ...
Setting up libxfont2:amd64 (1:2.0.6-1build1) ...
Setting up nvidia-compute-utils-535-server (535.183.01-0ubuntu0.24.04.1) ...
info: The home dir /nonexistent you specified can't be accessed: No such file or directory

info: Selecting UID from range 100 to 999 ...

info: Selecting GID from range 100 to 999 ...
info: Adding system user `nvidia-persistenced' (UID 110) ...
info: Adding new group `nvidia-persistenced' (GID 110) ...
info: Adding new user `nvidia-persistenced' (UID 110) with group `nvidia-persistenced' ...
info: Not creating `/nonexistent'.
Setting up x11-xkb-utils (7.7+8build2) ...
Setting up nvidia-utils-535-server (535.183.01-0ubuntu0.24.04.1) ...
Setting up xcvt (0.1.2-1build1) ...
Setting up libnvidia-gl-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up libnvidia-decode-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up nvidia-kernel-common-535-server (535.183.01-0ubuntu0.24.04.1) ...
update-initramfs: deferring update (trigger activated)
update-initramfs: Generating /boot/initrd.img-6.8.0-38-generic
I: The initramfs will attempt to resume from /dev/dm-0
I: (/dev/mapper/ubuntu--vg-lv--0)
I: Set the RESUME variable to override this.
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-hibernate.service → /usr/lib/systemd/system/nvidia-hibernate.service.
Created symlink /etc/systemd/system/systemd-suspend.service.wants/nvidia-resume.service → /usr/lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-hibernate.service.wants/nvidia-resume.service → /usr/lib/systemd/system/nvidia-resume.service.
Created symlink /etc/systemd/system/systemd-suspend.service.wants/nvidia-suspend.service → /usr/lib/systemd/system/nvidia-suspend.service.
Setting up xserver-common (2:21.1.12-1ubuntu1) ...
Setting up libnvidia-encode-535-server:amd64 (535.183.01-0ubuntu0.24.04.1) ...
Setting up nvidia-dkms-535-server (535.183.01-0ubuntu0.24.04.1) ...
update-initramfs: deferring update (trigger activated)
update-initramfs: Generating /boot/initrd.img-6.8.0-38-generic
I: The initramfs will attempt to resume from /dev/dm-0
I: (/dev/mapper/ubuntu--vg-lv--0)
I: Set the RESUME variable to override this.
Progress: [ 93%] [###################################################################################nvidia.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-38-generic/updates/dkms/

nvidia-modeset.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-38-generic/updates/dkms/

nvidia-drm.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-38-generic/updates/dkms/

nvidia-uvm.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-38-generic/updates/dkms/

nvidia-peermem.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-38-generic/updates/dkms/
depmod....
Building initial module for 6.8.0-40-generic
Done.

nvidia.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-40-generic/updates/dkms/

nvidia-modeset.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-40-generic/updates/dkms/

nvidia-drm.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-40-generic/updates/dkms/

nvidia-uvm.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-40-generic/updates/dkms/

nvidia-peermem.ko.zst:
Running module version sanity check.
 - Original module
   - No original module exists within this kernel
 - Installation
   - Installing to /lib/modules/6.8.0-40-generic/updates/dkms/
depmod....
Setting up xserver-xorg-core (2:21.1.12-1ubuntu1) ...
Setting up xserver-xorg-video-nvidia-535-server (535.183.01-0ubuntu0.24.04.1) ...
Setting up nvidia-driver-535-server (535.183.01-0ubuntu0.24.04.1) ...
Processing triggers for fontconfig (2.15.0-1.1ubuntu2) ...
Processing triggers for initramfs-tools (0.142ubuntu25.1) ...
update-initramfs: Generating /boot/initrd.img-6.8.0-40-generic
I: The initramfs will attempt to resume from /dev/dm-0
I: (/dev/mapper/ubuntu--vg-lv--0)
I: Set the RESUME variable to override this.
Processing triggers for libc-bin (2.39-0ubuntu8.2) ...
Processing triggers for man-db (2.12.0-4build2) ...
Scanning processes...
Scanning candidates...
Scanning processor microcode...
Scanning linux images...

Pending kernel upgrade!
Running kernel version:
  6.8.0-38-generic
Diagnostics:
  The currently running kernel version is not the expected kernel version 6.8.0-40-generic.

Restarting the system to load the new kernel will not be handled automatically, so you should
consider rebooting.

The processor microcode seems to be up-to-date.

Restarting services...

Service restarts being deferred:
 /etc/needrestart/restart.d/dbus.service
 systemctl restart systemd-logind.service
 systemctl restart unattended-upgrades.service

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

参考:

给 linux 的 NVIDIA GPU 安装 CUDA Toolkit

╰─➤  nvidia-smi                                                                                                                                                                                                                                                                     130 ↵
Thu Aug 22 02:00:34 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.183.01             Driver Version: 535.183.01   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| 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  Tesla M60                      Off | 00000000:83:00.0 Off |                    0 |
| N/A   27C    P0              40W / 150W |      0MiB /  7680MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
|   1  Tesla M60                      Off | 00000000:84:00.0 Off |                    0 |
| N/A   39C    P0              40W / 150W |      0MiB /  7680MiB |    100%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

方式二:在英伟达官网自己下载驱动和cuda并安装

优点:驱动版本可以是最新的
缺点:麻烦一点

下载驱动并安装

参考: nv 显卡安装驱动以及周边日志

下载地址:https://www.nvidia.com/en-us/drivers/

─➤  sudo apt install ./nvidia-driver-local-repo-ubuntu2404-550.90.07_1.0-1_amd64.deb 
[sudo] password for pon: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'nvidia-driver-local-repo-ubuntu2404-550.90.07' instead of './nvidia-driver-local-repo-ubuntu2404-550.90.07_1.0-1_amd64.deb'
The following packages were automatically installed and are no longer required:
  python3-cliapp python3-markdown python3-ttystatus python3-zombie-imp
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  nvidia-driver-local-repo-ubuntu2404-550.90.07
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
Need to get 0 B/394 MB of archives.
After this operation, 395 MB of additional disk space will be used.
Get:1 /home/pon/Downloads/nvidia-driver-local-repo-ubuntu2404-550.90.07_1.0-1_amd64.deb nvidia-driver-local-repo-ubuntu2404-550.90.07 amd64 1.0-1 [394 MB]
Selecting previously unselected package nvidia-driver-local-repo-ubuntu2404-550.90.07.
(Reading database ... 148381 files and directories currently installed.)
Preparing to unpack .../nvidia-driver-local-repo-ubuntu2404-550.90.07_1.0-1_amd64.deb ...
Unpacking nvidia-driver-local-repo-ubuntu2404-550.90.07 (1.0-1) ...
Setting up nvidia-driver-local-repo-ubuntu2404-550.90.07 (1.0-1) ...

The public nvidia-driver-local-repo-ubuntu2404-550.90.07 GPG key does not appear to be installed.
To install the key, run this command:
sudo cp /var/nvidia-driver-local-repo-ubuntu2404-550.90.07/nvidia-driver-local-1844CAD6-keyring.gpg /usr/share/keyrings/

Scanning processes...                                                                                                                                                                                                                                                                     
Scanning processor microcode...                                                                                                                                                                                                                                                           
Scanning linux images...                                                                                                                                                                                                                                                                  

Running kernel seems to be up-to-date.

The processor microcode seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.
N: Download is performed unsandboxed as root as file '/home/pon/Downloads/nvidia-driver-local-repo-ubuntu2404-550.90.07_1.0-1_amd64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)

下载 cuda 并安装

下载地址:https://developer.nvidia.com/cuda-downloads?target_os=Linux&t...

需要下载老版本:https://developer.nvidia.com/cuda-toolkit-archive

我喜欢下载 runfile,因为一些都在里面了,可以一键运行

添加可执行权限

╭─pon@M60GPU ~/Downloads  
╰─➤  chmod 777 cuda_12.6.0_560.28.03_linux.run

执行安装

╰─➤  sudo ./cuda_12.6.0_560.28.03_linux.run                                                                   130 ↵
[sudo] password for pon: 
===========
= Summary =
===========

Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-12.6/

Please make sure that
 -   PATH includes /usr/local/cuda-12.6/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-12.6/lib64, or, add /usr/local/cuda-12.6/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.6/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Logfile is /var/log/cuda-installer.log
─➤  nvidia-smi
Tue Aug 27 15:58:31 2024       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.28.03              Driver Version: 560.28.03      CUDA Version: 12.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  Tesla M60                      Off |   00000000:83:00.0 Off |                    0 |
| N/A   29C    P0             40W /  150W |       0MiB /   7680MiB |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
|   1  Tesla M60                      Off |   00000000:84:00.0 Off |                    0 |
| N/A   39C    P0             37W /  150W |       0MiB /   7680MiB |     38%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+
                                                                                         
+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

注意,安装 cuda 的时候,要以 root 或者 sudo 运行,不然会报错如下:

[INFO]: Driver not installed.
[INFO]: Checking compiler version...
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 13.2.0 (Ubuntu 13.2.0-23ubuntu4) 

[INFO]: Initializing menu
[INFO]: nvidia-fs.setKOVersion(2.22.3)
[WARNING]: Unable to write to directory: /usr/share/applications/
[INFO]: Setup complete
[INFO]: Installing: Driver
[ERROR]: Driver installation must be run as root.
[ERROR]: Install of Driver failed, quitting

universe_king
3.4k 声望677 粉丝