우분투 사용하다 보면 패키지 업데이트 중 의존성 문제를 겪는 것은 흔한 일이다. 최근에는 CUDA 패키지 업데이트 도중 의존성 문제가 발생했다. 몇몇 CUDA 관련 패키지들이 서로 충돌하면서 의존성 오류가 발생했는데, 이는 다른 버전의 패키지들이 이미 설치되어 있어서 발생한 문제였다.
이 문제를 해결하기 위해 apt --fix-broken install
명령어를 사용해 봤지만, 문제는 계속되었다. 결국, 파일 충돌을 무시하고 강제로 설치할 수 있는 dpkg --force-overwrite
옵션을 사용하여 문제를 해결할 수 있었다. 이 명령어는 충돌하는 파일들을 덮어쓰게 하여, 패키지들이 성공적으로 설치되도록 도와준다.
Bash
vividian@TP-P14s-G4:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cuda-compiler-12-3 : Depends: cuda-nvcc-12-3 (>= 12.3.107) but it is not installed
cuda-libraries-12-3 : Depends: cuda-nvrtc-12-3 (>= 12.3.107) but 12.3.103-1 is installed
Depends: libcurand-12-3 (>= 10.3.4.107) but 10.3.4.101-1 is installed
cuda-libraries-dev-12-3 : Depends: cuda-nvrtc-dev-12-3 (>= 12.3.107) but 12.3.103-1 is installed
Depends: libcurand-dev-12-3 (>= 10.3.4.107) but 10.3.4.101-1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
apt –fix-broken install 을 입력해도 문제는 계속된다.
Bash
vividian@TP-P14s-G4:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
cuda-nvcc-12-3 cuda-nvrtc-12-3 cuda-nvrtc-dev-12-3 libcurand-12-3 libcurand-dev-12-3
The following NEW packages will be installed:
cuda-nvcc-12-3
The following packages will be upgraded:
cuda-nvrtc-12-3 cuda-nvrtc-dev-12-3 libcurand-12-3 libcurand-dev-12-3
4 upgraded, 1 newly installed, 0 to remove and 82 not upgraded.
3 not fully installed or removed.
Need to get 0 B/144 MB of archives.
After this operation, 137 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 39969 files and directories currently installed.)
Preparing to unpack .../cuda-nvcc-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvcc-12-3 (12.3.107-1) ...
dpkg: error processing archive /var/cache/apt/archives/cuda-nvcc-12-3_12.3.107-1_amd64.deb (--unpack):
trying to overwrite '/usr/local/cuda-12.3/include', which is also in package libcusparse-dev-12-3 12.2.0.103-1
Preparing to unpack .../cuda-nvrtc-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvrtc-12-3 (12.3.107-1) over (12.3.103-1) ...
dpkg: error processing archive /var/cache/apt/archives/cuda-nvrtc-12-3_12.3.107-1_amd64.deb (--unpack):
trying to overwrite '/usr/local/cuda-12.3/lib64', which is also in package libcusparse-dev-12-3 12.2.0.103-1
Preparing to unpack .../libcurand-12-3_10.3.4.107-1_amd64.deb ...
Unpacking libcurand-12-3 (10.3.4.107-1) over (10.3.4.101-1) ...
dpkg: error processing archive /var/cache/apt/archives/libcurand-12-3_10.3.4.107-1_amd64.deb (--unpack):
trying to overwrite '/usr/local/cuda-12.3/lib64', which is also in package libcusparse-dev-12-3 12.2.0.103-1
Preparing to unpack .../cuda-nvrtc-dev-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvrtc-dev-12-3 (12.3.107-1) over (12.3.103-1) ...
dpkg: error processing archive /var/cache/apt/archives/cuda-nvrtc-dev-12-3_12.3.107-1_amd64.deb (--unpack):
trying to overwrite '/usr/local/cuda-12.3/include', which is also in package libcusparse-dev-12-3 12.2.0.103-1
No apport report written because MaxReports is reached already
Preparing to unpack .../libcurand-dev-12-3_10.3.4.107-1_amd64.deb ...
Unpacking libcurand-dev-12-3 (10.3.4.107-1) over (10.3.4.101-1) ...
dpkg: error processing archive /var/cache/apt/archives/libcurand-dev-12-3_10.3.4.107-1_amd64.deb (--unpack):
trying to overwrite '/usr/local/cuda-12.3/include', which is also in package libcusparse-dev-12-3 12.2.0.103-1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
/var/cache/apt/archives/cuda-nvcc-12-3_12.3.107-1_amd64.deb
/var/cache/apt/archives/cuda-nvrtc-12-3_12.3.107-1_amd64.deb
/var/cache/apt/archives/libcurand-12-3_10.3.4.107-1_amd64.deb
/var/cache/apt/archives/cuda-nvrtc-dev-12-3_12.3.107-1_amd64.deb
/var/cache/apt/archives/libcurand-dev-12-3_10.3.4.107-1_amd64.deb
dpkg -i –force-overwrite 명령어로 패키지를 수동으로 설치하여 문제 해결했다.
Bash
vividian@TP-P14s-G4:~$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/cuda-nvcc-12-3_12.3.107-1_amd64.deb
(Reading database ... 39969 files and directories currently installed.)
Preparing to unpack .../cuda-nvcc-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvcc-12-3 (12.3.107-1) ...
dpkg: warning: overriding problem because --force enabled:
dpkg: warning: trying to overwrite '/usr/local/cuda-12.3/include', which is also in package libcusparse-dev-12-3 12.2.0.103-1
.....(중략)
vividian@TP-P14s-G4:~$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/cuda-nvrtc-12-3_12.3.107-1_amd64.deb
Selecting previously unselected package cuda-nvrtc-12-3.
(Reading database ... 39986 files and directories currently installed.)
Preparing to unpack .../cuda-nvrtc-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvrtc-12-3 (12.3.107-1) over (12.3.103-1) ...
Setting up cuda-nvrtc-12-3 (12.3.107-1) ...
vividian@TP-P14s-G4:~$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/libcurand-12-3_10.3.4.107-1_amd64.deb
(Reading database ... 39986 files and directories currently installed.)
Preparing to unpack .../libcurand-12-3_10.3.4.107-1_amd64.deb ...
Unpacking libcurand-12-3 (10.3.4.107-1) over (10.3.4.101-1) ...
Setting up libcurand-12-3 (10.3.4.107-1) ...
vividian@TP-P14s-G4:~$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/cuda-nvrtc-dev-12-3_12.3.107-1_amd64.deb
Selecting previously unselected package cuda-nvrtc-dev-12-3.
(Reading database ... 39986 files and directories currently installed.)
Preparing to unpack .../cuda-nvrtc-dev-12-3_12.3.107-1_amd64.deb ...
Unpacking cuda-nvrtc-dev-12-3 (12.3.107-1) over (12.3.103-1) ...
Setting up cuda-nvrtc-dev-12-3 (12.3.107-1) ...
vividian@TP-P14s-G4:~$ sudo dpkg -i --force-overwrite /var/cache/apt/archives/libcurand-dev-12-3_10.3.4.107-1_amd64.deb
(Reading database ... 39986 files and directories currently installed.)
Preparing to unpack .../libcurand-dev-12-3_10.3.4.107-1_amd64.deb ...
Unpacking libcurand-dev-12-3 (10.3.4.107-1) over (10.3.4.101-1) ...
Setting up libcurand-dev-12-3 (10.3.4.107-1) ...
vividian@TP-P14s-G4:~$ sudo apt upgrade
... (중략) ...
vividian@TP-P14s-G4:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.