我正在尝试在 Ubuntu 22.04.4 LTS 上安装 CUDA 11.7。基于官方文档,Ubuntu 22.04 支持内核 5.15。但是,当我尝试安装 cuda 时,安装程序会抛出以下错误:
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-source-515.0.crash'
Error! Bad return status for module build on kernel: 6.5.0-18-generic (x86_64)
Consult /var/lib/dkms/nvidia/515.65.01/build/make.log for more information.
dpkg: error processing package nvidia-dkms-515 (--configure):
installed nvidia-dkms-515 package post-installation script subprocess returned error exit status 10
Setting up nsight-systems-2022.1.3 (2022.1.3.3-1c7b5f7) ...
update-alternatives: using /opt/nvidia/nsight-systems/2022.1.3/target-linux-x64/nsys to provide /usr/local/bin/nsys (nsys) in auto mode
update-alternatives: using /opt/nvidia/nsight-systems/2022.1.3/host-linux-x64/nsys-ui to provide /usr/local/bin/nsys-ui (nsys-ui) in auto mode
Setting up libxml2:i386 (2.9.13+dfsg-1ubuntu0.3) ...
Setting up libcufile-dev-11-7 (1.3.1.18-1) ...
Setting up cuda-libraries-11-7 (11.7.1-1) ...
Setting up libxcb-dri3-0:i386 (1.14-3ubuntu3) ...
dpkg: dependency problems prevent configuration of cuda-drivers-515:
cuda-drivers-515 depends on nvidia-dkms-515 (>= 515.65.01); however:
Package nvidia-dkms-515 is not configured yet.
我在日志文件中发现以下错误:
/var/lib/dkms/nvidia/515.65.01/build/common/inc/nv-mm.h: In function ‘NV_GET_USER_PAGES_REMOTE’:
/var/lib/dkms/nvidia/515.65.01/build/common/inc/nv-mm.h:164:45: error: passing argument 1 of ‘get_user_pages_remote’ from incompatible pointer type [-Werror=incompatible-pointer-types]
164 | return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
| ^~~
| |
| struct task_struct *
In file included from /var/lib/dkms/nvidia/515.65.01/build/common/inc/nv-pgprot.h:30,
该错误是在安装 NVIDIA 驱动程序 515 期间生成的。虽然文档说要安装它,但似乎NVIDIA 驱动程序 515 与 Ubuntu 22.04 内的内核 5.15 不兼容。同样,我尝试通过安装 NVIDIA Open GPU Kernel Modules 包sudo apt install -y nvidia-kernel-open-515
,但它抛出了类似的错误。
NVIDIA 驱动程序 535
后来我安装了基于NVIDIA的驱动这个建议使用以下命令:
$ sudo ubuntu-drivers install
以上命令安装完毕nvidia-driver-535 (535.154.05-0ubuntu0.22.04.1)
。然后,我安装了cuda-toolkit-11-7
软件包(注意,它不是cuda-11-7
软件包)。最后,我应该安装,cuda-driver-535
但没有这样的包,如下所示:
$ sudo apt install cuda-driver
cuda-driver-dev-11-7 cuda-drivers-fabricmanager-450 cuda-drivers-fabricmanager-515
cuda-drivers cuda-drivers-fabricmanager-460 cuda-drivers-fabricmanager-525
cuda-drivers-515 cuda-drivers-fabricmanager-470 cuda-drivers-fabricmanager-535
cuda-drivers-fabricmanager cuda-drivers-fabricmanager-510
为了检查我的信仰,我安装了cuda-drivers-515
但它被删除,nvidia-driver-535
如下所示:
$ sudo apt install cuda-drivers-515
The following packages will be REMOVED:
libnvidia-cfg1-535 libnvidia-common-535 libnvidia-compute-535 libnvidia-compute-535:i386 libnvidia-decode-535
libnvidia-decode-535:i386 libnvidia-encode-535 libnvidia-encode-535:i386 libnvidia-extra-535 libnvidia-fbc1-535
libnvidia-fbc1-535:i386 libnvidia-gl-535 libnvidia-gl-535:i386 linux-modules-nvidia-535-6.5.0-18-generic
linux-modules-nvidia-535-generic-hwe-22.04 nvidia-compute-utils-535 nvidia-driver-535 nvidia-kernel-common-535
nvidia-kernel-source-535 nvidia-utils-535 xserver-xorg-video-nvidia-535
The following NEW packages will be installed:
cuda-drivers-515 dctrl-tools dkms libegl-mesa0:i386 libegl1:i386 libgbm1:i386 libgles2:i386 libnvidia-cfg1-515
libnvidia-common-515 libnvidia-compute-515 libnvidia-compute-515:i386 libnvidia-decode-515 libnvidia-decode-515:i386
libnvidia-encode-515 libnvidia-encode-515:i386 libnvidia-extra-515 libnvidia-fbc1-515 libnvidia-fbc1-515:i386
libnvidia-gl-515 libnvidia-gl-515:i386 libopengl0:i386 libwayland-client0:i386 libwayland-server0:i386
nvidia-compute-utils-515 nvidia-dkms-515 nvidia-driver-515 nvidia-kernel-common-515 nvidia-kernel-source-515
nvidia-modprobe nvidia-utils-515 xserver-xorg-video-nvidia-515
0 upgraded, 31 newly installed, 21 to remove and 14 not upgraded.
但问题仍然存在。
内核6.2
此时,我想到了如何使用更新的内核(尽管官方文档中没有提到)。所以我用了6.2.0-39-generic
.然而,报告了类似的错误。
Ubuntu 22.04 中的 CUDA 11.7 推荐使用哪个 nvidia 驱动程序?
更新
环境信息:
$ uname -a
Linux asus 5.15.0-94-generic #104-Ubuntu SMP Tue Jan 9 15:25:40 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ldd --version
ldd (Ubuntu GLIBC 2.35-0ubuntu3.6) 2.35
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
安装步骤
$ sudo dpkg -i cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb
Selecting previously unselected package cuda-repo-ubuntu2204-11-7-local.
(Reading database ... 777187 files and directories currently installed.)
Preparing to unpack cuda-repo-ubuntu2204-11-7-local_11.7.1-515.65.01-1_amd64.deb ...
Unpacking cuda-repo-ubuntu2204-11-7-local (11.7.1-515.65.01-1) ...
Setting up cuda-repo-ubuntu2204-11-7-local (11.7.1-515.65.01-1) ...
The public CUDA GPG key does not appear to be installed.
To install the key, run this command:
sudo cp /var/cuda-repo-ubuntu2204-11-7-local/cuda-F83D2C4C-keyring.gpg /usr/share/keyrings/
$ sudo cp /var/cuda-repo-ubuntu2204-11-7-local/cuda-F83D2C4C-keyring.gpg /usr/share/keyrings/
$ sudo apt update
$ sudo apt install cuda-11-7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
cuda-cccl-11-7 cuda-command-line-tools-11-7 cuda-compiler-11-7 cuda-cudart-11-7 cuda-cudart-dev-11-7
cuda-cuobjdump-11-7 cuda-cupti-11-7 cuda-cupti-dev-11-7 cuda-cuxxfilt-11-7 cuda-demo-suite-11-7
cuda-documentation-11-7 cuda-driver-dev-11-7 cuda-drivers cuda-drivers-515 cuda-gdb-11-7 cuda-libraries-11-7
cuda-libraries-dev-11-7 cuda-memcheck-11-7 cuda-nsight-11-7 cuda-nsight-compute-11-7 cuda-nsight-systems-11-7
cuda-nvcc-11-7 cuda-nvdisasm-11-7 cuda-nvml-dev-11-7 cuda-nvprof-11-7 cuda-nvprune-11-7 cuda-nvrtc-11-7
cuda-nvrtc-dev-11-7 cuda-nvtx-11-7 cuda-nvvp-11-7 cuda-runtime-11-7 cuda-sanitizer-11-7 cuda-toolkit-11-7
cuda-toolkit-11-7-config-common cuda-toolkit-11-config-common cuda-toolkit-config-common cuda-tools-11-7
cuda-visual-tools-11-7 dctrl-tools dkms gds-tools-11-7 libatomic1:i386 libbsd0:i386 libcublas-11-7
libcublas-dev-11-7 libcufft-11-7 libcufft-dev-11-7 libcufile-11-7 libcufile-dev-11-7 libcurand-11-7
libcurand-dev-11-7 libcusolver-11-7 libcusolver-dev-11-7 libcusparse-11-7 libcusparse-dev-11-7 libdrm-amdgpu1:i386
libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libegl-mesa0:i386
libegl1:i386 libelf1:i386 libexpat1:i386 libffi8:i386 libgbm1:i386 libgl1:i386 libgl1-mesa-dri:i386
libglapi-mesa:i386 libgles2:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libicu70:i386 libllvm15:i386
libmd0:i386 libnpp-11-7 libnpp-dev-11-7 libnvidia-cfg1-515 libnvidia-common-515 libnvidia-compute-515
libnvidia-compute-515:i386 libnvidia-decode-515 libnvidia-decode-515:i386 libnvidia-encode-515
libnvidia-encode-515:i386 libnvidia-extra-515 libnvidia-fbc1-515 libnvidia-fbc1-515:i386 libnvidia-gl-515
libnvidia-gl-515:i386 libnvjpeg-11-7 libnvjpeg-dev-11-7 libopengl0:i386 libpciaccess0:i386 libsensors5:i386
libstdc++6:i386 libtinfo5 libwayland-client0:i386 libwayland-server0: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
libxml2:i386 libxshmfence1:i386 libxxf86vm1:i386 nsight-compute-2022.2.1 nsight-systems-2022.1.3
nvidia-compute-utils-515 nvidia-dkms-515 nvidia-driver-515 nvidia-kernel-common-515 nvidia-kernel-source-515
nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-515 screen-resolution-extra xserver-xorg-video-nvidia-515
Suggested packages:
debtags menu lm-sensors:i386
Recommended packages:
libgl1-amber-dri:i386
The following NEW packages will be installed:
cuda-11-7 cuda-cccl-11-7 cuda-command-line-tools-11-7 cuda-compiler-11-7 cuda-cudart-11-7 cuda-cudart-dev-11-7
cuda-cuobjdump-11-7 cuda-cupti-11-7 cuda-cupti-dev-11-7 cuda-cuxxfilt-11-7 cuda-demo-suite-11-7
cuda-documentation-11-7 cuda-driver-dev-11-7 cuda-drivers cuda-drivers-515 cuda-gdb-11-7 cuda-libraries-11-7
cuda-libraries-dev-11-7 cuda-memcheck-11-7 cuda-nsight-11-7 cuda-nsight-compute-11-7 cuda-nsight-systems-11-7
cuda-nvcc-11-7 cuda-nvdisasm-11-7 cuda-nvml-dev-11-7 cuda-nvprof-11-7 cuda-nvprune-11-7 cuda-nvrtc-11-7
cuda-nvrtc-dev-11-7 cuda-nvtx-11-7 cuda-nvvp-11-7 cuda-runtime-11-7 cuda-sanitizer-11-7 cuda-toolkit-11-7
cuda-toolkit-11-7-config-common cuda-toolkit-11-config-common cuda-toolkit-config-common cuda-tools-11-7
cuda-visual-tools-11-7 dctrl-tools dkms gds-tools-11-7 libatomic1:i386 libbsd0:i386 libcublas-11-7
libcublas-dev-11-7 libcufft-11-7 libcufft-dev-11-7 libcufile-11-7 libcufile-dev-11-7 libcurand-11-7
libcurand-dev-11-7 libcusolver-11-7 libcusolver-dev-11-7 libcusparse-11-7 libcusparse-dev-11-7 libdrm-amdgpu1:i386
libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libegl-mesa0:i386
libegl1:i386 libelf1:i386 libexpat1:i386 libffi8:i386 libgbm1:i386 libgl1:i386 libgl1-mesa-dri:i386
libglapi-mesa:i386 libgles2:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libicu70:i386 libllvm15:i386
libmd0:i386 libnpp-11-7 libnpp-dev-11-7 libnvidia-cfg1-515 libnvidia-common-515 libnvidia-compute-515
libnvidia-compute-515:i386 libnvidia-decode-515 libnvidia-decode-515:i386 libnvidia-encode-515
libnvidia-encode-515:i386 libnvidia-extra-515 libnvidia-fbc1-515 libnvidia-fbc1-515:i386 libnvidia-gl-515
libnvidia-gl-515:i386 libnvjpeg-11-7 libnvjpeg-dev-11-7 libopengl0:i386 libpciaccess0:i386 libsensors5:i386
libstdc++6:i386 libtinfo5 libwayland-client0:i386 libwayland-server0: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
libxml2:i386 libxshmfence1:i386 libxxf86vm1:i386 nsight-compute-2022.2.1 nsight-systems-2022.1.3
nvidia-compute-utils-515 nvidia-dkms-515 nvidia-driver-515 nvidia-kernel-common-515 nvidia-kernel-source-515
nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-515 screen-resolution-extra xserver-xorg-video-nvidia-515
0 upgraded, 133 newly installed, 0 to remove and 14 not upgraded.
Need to get 0 B/2,668 MB of archives.
After this operation, 6,272 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...
...
...
A new initrd image has also been created. To revert, please regenerate your
initrd by running the following command after deleting the modprobe.d file:
`/usr/sbin/initramfs -u`
*****************************************************************************
*** Reboot your computer and verify that the NVIDIA graphics driver can ***
*** be loaded. ***
*****************************************************************************
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Loading new nvidia-515.65.01 DKMS files...
Building for 5.15.0-94-generic 6.5.0-18-generic
Building for architecture x86_64
Building initial module for 5.15.0-94-generic
Secure Boot not enabled on this system.
Done.
nvidia.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.15.0-94-generic/updates/dkms/
nvidia-modeset.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.15.0-94-generic/updates/dkms/
nvidia-drm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.15.0-94-generic/updates/dkms/
nvidia-peermem.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.15.0-94-generic/updates/dkms/
nvidia-uvm.ko:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/5.15.0-94-generic/updates/dkms/
depmod...
Building initial module for 6.5.0-18-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-kernel-source-515.0.crash'
Error! Bad return status for module build on kernel: 6.5.0-18-generic (x86_64)
Consult /var/lib/dkms/nvidia/515.65.01/build/make.log for more information.
dpkg: error processing package nvidia-dkms-515 (--configure):
installed nvidia-dkms-515 package post-installation script subprocess returned error exit status 10
Setting up nsight-systems-2022.1.3 (2022.1.3.3-1c7b5f7) ...
update-alternatives: using /opt/nvidia/nsight-systems/2022.1.3/target-linux-x64/nsys to provide /usr/local/bin/nsys (nsy
s) in auto mode
update-alternatives: using /opt/nvidia/nsight-systems/2022.1.3/host-linux-x64/nsys-ui to provide /usr/local/bin/nsys-ui
(nsys-ui) in auto mode
Setting up libxml2:i386 (2.9.13+dfsg-1ubuntu0.3) ...
Setting up libcufile-dev-11-7 (1.3.1.18-1) ...
Setting up cuda-libraries-11-7 (11.7.1-1) ...
Setting up libxcb-dri3-0:i386 (1.14-3ubuntu3) ...
dpkg: dependency problems prevent configuration of cuda-drivers-515:
cuda-drivers-515 depends on nvidia-dkms-515 (>= 515.65.01); however:
Package nvidia-dkms-515 is not configured yet.
dpkg: error processing package cuda-drivers-515 (--configure):
dependency problems - leaving unconfigured
Setting up libx11-xcb1:i386 (2:1.7.5-1ubuntu0.3) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Setting up lib
gbm1:i386 (23.2.1-1ubuntu3.1~22.04.2) ...
Setting up cuda-compiler-11-7 (11.7.1-1) ...
Setting up cuda-cupti-11-7 (11.7.101-1) ...
Setting up libxext6:i386 (2:1.3.4-1build1) ...
Setting up cuda-cupti-dev-11-7 (11.7.101-1) ...
Setting up libxxf86vm1:i386 (1:1.1.4-1build3) ...
Setting up libegl-mesa0:i386 (23.2.1-1ubuntu3.1~22.04.2) ...
Setting up libxfixes3:i386 (1:6.0.0-1) ...
dpkg: dependency problems prevent configuration of cuda-drivers:
cuda-drivers depends on cuda-drivers-515 (= 515.65.01-1); however:
Package cuda-drivers-515 is not configured yet.
dpkg: error processing package cuda-drivers (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependen
cy problems prevent configuration of nvidia-driver-515:
nvidia-driver-515 depends on nvidia-dkms-515 (= 515.65.01-0ubuntu1); however:
Package nvidia-dkms-515 is not configured yet.
dpkg: error processing package nvidia-driver-515 (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Setting up libnvidia-decode-515:i386 (515.65.01-0ubuntu1)
...
Setting up libllvm15:i386 (1:15.0.7-0ubuntu0.22.04.3) ...
Setting up libegl1:i386 (1.4.0-1) ...
Setting up cuda-nsight-systems-11-7 (11.7.1-1) ...
Setting up cuda-libraries-dev-11-7 (11.7.1-1) ...
dpkg: dependency problems prevent configuration of cuda-runtime-11-7:
cuda-runtime-11-7 depends on cuda-drivers (>= 515.65.01); however:
Package cuda-drivers is not configured yet.
dpkg: error processing package cuda-runtime-11-7 (--configure):
dependency problems - leaving unconfigured
Setting up libgl1-mesa-dri:i386 (23.2.1-1ubuntu3.1~22.04.2) ...
No apport report written because MaxReports is reached already
Setting up cuda-command-line-tools-11-7 (11.7.1-1) ...
Setting up libnvidia-encode-515:i386 (515.65.01-0ubuntu1) ...
Setting up cuda-visual-tools-11-7 (11.7.1-1) ...
dpkg: dependency problems prevent configuration of cuda-demo-suite-11-7:
cuda-demo-suite-11-7 depends on cuda-runtime-11-7; however:
Package cuda-runtime-11-7 is not configured yet.
dpkg: error processing package cuda-demo-suite-11-7 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda-11-7:
cuda-11-7 depends on cuda-runtime-11-7 (>= 11.7.1); however:
Package cuda-runtime-11-7 is not configured yet.
cuda-11-7 depends on cuda-demo-suite-11-7 (>= 11.7.91); however:
Package cuda-demo-suite-11-7 is not configured yet.
dpkg: error processing package cuda-11-7 (--configure):
dependency problems - leaving unconfigured
Setting up libglx-mesa0:i386 (23.2.1-1ubuntu3.1~22.04.2) ...
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached alr
eady
Setting up libglx0:i386 (1.4.0-1) ...
Setting up libgl1:i386 (1.4.0-1) ...
Setting up cuda-tools-11-7 (11.7.1-1) ...
Setting up libnvidia-gl-515:i386 (515.65.01-0ubuntu1) ...
Setting up libnvidia-fbc1-515:i386 (515.65.01-0ubuntu1) ...
Setting up cuda-toolkit-11-7 (11.7.1-1) ...
Setting alternatives
Processing triggers for bamfdaemon (0.5.6+22.04.20220217-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for dbus (1.12.20-2ubuntu4.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for initramfs-tools (0.140ubuntu13.4) ...
update-initramfs: Generating /boot/initrd.img-6.5.0-18-generic
Errors were encountered while processing:
nvidia-dkms-515
cuda-drivers-515
cuda-drivers
nvidia-driver-515
cuda-runtime-11-7
cuda-demo-suite-11-7
cuda-11-7
E: Sub-process /usr/bin/dpkg returned an error code (1)