Ubuntu 22.04において、CUDA 12.3からCUDA 12.4にアップグレードする際に発生したエラーの解決手順です。
更新中に発生したエラー:
CUDA 12.3からCUDA 12.4にapt
を使用してアップグレードしようとしたときに、以下のエラーが発生しました:
$ sudo apt -y install cuda-12-4 cuda-drivers Reading package lists... Done Building dependency tree... Done Reading state information... Done cuda-drivers is already the newest version (550.54.15-1). You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies: cuda-12-4 : Depends: cuda-runtime-12-4 (>= 12.4.1) but it is not going to be installed Depends: cuda-toolkit-12-4 (>= 12.4.1) but it is not going to be installed Depends: cuda-demo-suite-12-4 (>= 12.4.127) but it is not going to be installed cuda-drivers : Depends: cuda-drivers-550 (= 550.54.15-1) but it is not going to be installed libnvidia-decode-545 : Depends: libnvidia-compute-545 (= 545.23.08-0ubuntu1) but it is not going to be installed E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
apt --fix-broken install
を実行しても特に解決しませんでした。
$ sudo apt --fix-broken install The following packages were automatically installed and are no longer required: libatomic1:i386 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 libopengl0:i386 libpciaccess0:i386 libsensors5:i386 libstdc++6:i386 libwayland-client0:i386 libwayland-server0:i386 libx11-xcb1: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 libxfixes3:i386 libxml2:i386 libxshmfence1:i386 libxxf86vm1:i386 nvidia-modprobe Use 'apt autoremove' to remove them. The following additional packages will be installed: cuda-drivers-550 libnvidia-cfg1-550 libnvidia-compute-550:i386 libnvidia-decode-550 libnvidia-decode-550:i386 libnvidia-encode-550 libnvidia-encode-550:i386 libnvidia-extra-550 libnvidia-fbc1-550 libnvidia-fbc1-550:i386 libnvidia-gl-550 libnvidia-gl-550:i386 nvidia-compute-utils-550 nvidia-dkms-550 nvidia-driver-550 nvidia-firmware-550-550.54.15 nvidia-kernel-common-550 nvidia-kernel-source-550 nvidia-utils-550 xserver-xorg-video-nvidia-550 The following packages will be REMOVED: libnvidia-cfg1-545 libnvidia-decode-545 libnvidia-encode-545 libnvidia-extra-545 libnvidia-fbc1-545 libnvidia-fbc1-545:i386 nvidia-dkms-545 nvidia-kernel-common-545 nvidia-kernel-source-545 xserver-xorg-video-nvidia-545 The following NEW packages will be installed: cuda-drivers-550 libnvidia-cfg1-550 libnvidia-compute-550:i386 libnvidia-decode-550 libnvidia-decode-550:i386 libnvidia-encode-550 libnvidia-encode-550:i386 libnvidia-extra-550 libnvidia-fbc1-550 libnvidia-fbc1-550:i386 libnvidia-gl-550 libnvidia-gl-550:i386 nvidia-compute-utils-550 nvidia-dkms-550 nvidia-driver-550 nvidia-firmware-550-550.54.15 nvidia-kernel-common-550 nvidia-kernel-source-550 nvidia-utils-550 xserver-xorg-video-nvidia-550 0 upgraded, 20 newly installed, 10 to remove and 8 not upgraded. 3 not fully installed or removed. Need to get 0 B/290 MB of archives. After this operation, 662 MB of additional disk space will be used. Do you want to continue? [Y/n] Y (Reading database ... 434884 files and directories currently installed.) Preparing to unpack .../libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb ... dpkg-query: no packages found matching libnvidia-gl-535 Unpacking libnvidia-gl-550:amd64 (550.54.15-0ubuntu1) ... dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb (--unpack): trying to overwrite '/usr/lib/x86_64-linux-gnu/libnvidia-api.so.1', which is also in package libnvidia-extra-545:amd64 545.23.08-0ubuntu1 dpkg-deb: error: paste subprocess was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
エラーの原因は、/var/cache/apt/archives/libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb
が悪さをしているようです。
解決方法:
この一時ファイルに対してdpkg -i --force-overwrite
コマンドを使用すると、事態が進展しました。
$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb (Reading database ... 434884 files and directories currently installed.) Preparing to unpack .../libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb ... dpkg-query: no packages found matching libnvidia-gl-535 Unpacking libnvidia-gl-550:amd64 (550.54.15-0ubuntu1) ... dpkg: warning: overriding problem because --force enabled: dpkg: warning: trying to overwrite '/usr/lib/x86_64-linux-gnu/libnvidia-api.so.1', which is also in package libnvidia-extra-545:amd64 545.23.08-0ubuntu1 dpkg: dependency problems prevent configuration of libnvidia-gl-550:amd64: libnvidia-gl-550:amd64 depends on libnvidia-common-550; however: Package libnvidia-common-550 is not configured yet. libnvidia-gl-550:amd64 depends on libnvidia-compute-550 (>= 550.54.15); however: Package libnvidia-compute-550:amd64 is not configured yet. dpkg: error processing package libnvidia-gl-550:amd64 (--install): dependency problems - leaving unconfigured Processing triggers for libc-bin (2.35-0ubuntu3.7) ... Errors were encountered while processing: libnvidia-gl-550:amd64
この時点ではまだエラーが出ていますが、その後もう一度apt --fix-broken install
を実行すると(なぜか)エラーが出なくなり、色々な修正が働きました。
最後の手順:
その後、nvidia-smi
を実行すると以下のエラーが表示されました:
$ nvidia-smi Failed to initialize NVML: Driver/library version mismatch NVML library version: 550.54
nvidiaドライバが更新されたため、nvidia-smi
を使えるようにするために一度再起動しました。その後、apt -y update && apt -y upgrade
を実行することで、無事に最新のCUDA 12.4がインストールされ、nvidia-smi
も正常に動作しました。