$ sudo apt-get update --fix-missing
$ sudo apt-get install -f
단순한 패키지 오류일 경우에는 위의 명령어만 써도 해결될 수 있다.
위 방법이 나한테는 적용되었다.
$ sudo apt update
$ sudo apt clean
$ sudo apt autoremove
이렇게 하면, 다음과 같이 dependency 오류가 뜰 것이다.
(base) ubuntu@gpuserver:/etc/apt$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cuda-compiler-11-8 : Depends: cuda-cuxxfilt-11-8 (>= 11.8.86) but it is not installed
Depends: cuda-nvcc-11-8 (>= 11.8.89) but it is not installed
cuda-cupti-dev-11-8 : Depends: cuda-cupti-11-8 (>= 11.8.87) but it is not installed
cuda-libraries-11-8 : Depends: cuda-cudart-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-nvrtc-11-8 (>= 11.8.89) but it is not installed
Depends: libcufft-11-8 (>= 10.9.0.58) but it is not installed
Depends: libcurand-11-8 (>= 10.3.0.86) but it is not installed
Depends: libcusolver-11-8 (>= 11.4.1.48) but it is not installed
Depends: libcusparse-11-8 (>= 11.7.5.86) but it is not installed
Depends: libnpp-11-8 (>= 11.8.0.86) but it is not installed
Depends: libnvjpeg-11-8 (>= 11.9.0.86) but it is not installed
cuda-libraries-dev-11-8 : Depends: cuda-cudart-dev-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-cccl-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-driver-dev-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-nvrtc-dev-11-8 (>= 11.8.89) but it is not installed
Depends: libcublas-dev-11-8 (>= 11.11.3.6) but it is not installed
Depends: libcufft-dev-11-8 (>= 10.9.0.58) but it is not installed
Depends: libcurand-dev-11-8 (>= 10.3.0.86) but it is not installed
Depends: libcusolver-dev-11-8 (>= 11.4.1.48) but it is not installed
Depends: libcusparse-dev-11-8 (>= 11.7.5.86) but it is not installed
Depends: libnpp-dev-11-8 (>= 11.8.0.86) but it is not installed
Depends: libnvjpeg-dev-11-8 (>= 11.9.0.86) but it is not installed
cuda-visual-tools-11-8 : Depends: cuda-nvml-dev-11-8 (>= 11.8.86) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
여기서 apt --fix-broken install
해봤자 아무것도 해결되지 않는다.
우리가 지워야 할 패키지 이름을 알 수 있다:
아래의 명령어로 패키지를 하나씩 지워줘야 한다.
sudo dpkg --remove --force-remove-reinstreq {PACKAGE NAME}
예를 들어, 나는 cuda-compiler-11-8에 의존성이 걸려있기 때문에 저 패키지를 지워야 한다.
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-compiler-11-8
(Reading database ... 203878 files and directories currently installed.)
Removing cuda-compiler-11-8 (11.8.0-1) ...
이렇게 쉽게 지워질 수 있는데,
여기서 한 번에 지워지지 않는 패키지도 있다.
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-libraries-11-8
dpkg: dependency problems prevent removal of cuda-libraries-11-8:
cuda-runtime-11-8 depends on cuda-libraries-11-8 (>= 11.8.0).
dpkg: error processing package cuda-libraries-11-8 (--remove):
dependency problems - not removing
Errors were encountered while processing:
cuda-libraries-11-8
위의 경우에는 내가 cuda-libraries-11-8 패키지를 삭제하려고 했는데, 해당 패키지를 cuda-runtime-11-8 이라는 패키지가 먼저 참조하고 있기 때문에 cuda-runtime-11-8이라는 패키지를 먼저 지워주어야 한다.
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-runtime-11-8
dpkg: dependency problems prevent removal of cuda-runtime-11-8:
cuda-demo-suite-11-8 depends on cuda-runtime-11-8.
dpkg: error processing package cuda-runtime-11-8 (--remove):
dependency problems - not removing
Errors were encountered while processing:
cuda-runtime-11-8
하지만, cuda-runtime-11-8 역시 cuda-demo-suite-11-8 이라는 패키지가 이미 참조하고 있다. cuda-demo-suite-11-8 패키지를 또 먼저 지워주자.
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-demo-suite-11-8
(Reading database ... 203386 files and directories currently installed.)
Removing cuda-demo-suite-11-8 (11.8.86-1) ...
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-runtime-11-8
(Reading database ... 203366 files and directories currently installed.)
Removing cuda-runtime-11-8 (11.8.0-1) ...
(base) ubuntu@gpuserver:/etc/apt$ sudo dpkg --remove --force-remove-reinstreq cuda-libraries-11-8
(Reading database ... 203364 files and directories currently installed.)
Removing cuda-libraries-11-8 (11.8.0-1) ...
(base) ubuntu@gpuserver:/etc/apt$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
cuda-libraries-dev-11-8 : Depends: cuda-cudart-dev-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-cccl-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-driver-dev-11-8 (>= 11.8.89) but it is not installed
Depends: cuda-nvrtc-dev-11-8 (>= 11.8.89) but it is not installed
Depends: libcublas-dev-11-8 (>= 11.11.3.6) but it is not installed
Depends: libcufft-dev-11-8 (>= 10.9.0.58) but it is not installed
Depends: libcurand-dev-11-8 (>= 10.3.0.86) but it is not installed
Depends: libcusolver-dev-11-8 (>= 11.4.1.48) but it is not installed
Depends: libcusparse-dev-11-8 (>= 11.7.5.86) but it is not installed
Depends: libnpp-dev-11-8 (>= 11.8.0.86) but it is not installed
Depends: libnvjpeg-dev-11-8 (>= 11.9.0.86) but it is not installed
cuda-visual-tools-11-8 : Depends: cuda-nvml-dev-11-8 (>= 11.8.86) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
순차적으로 지우니 잘 지워졌다.
이제 cuda-libraries-dev-11-8 패키지와 cuda-visual-tools-11-8 패키지도 똑같이 지워주자.
감사합니다. 진짜 감사합니다.