Happens in the process when installing cuda-toolkit-12-3
Problem
Install cuda-toolkit-12-3, but there is no space, so use ctrl-C to terminate the install process.
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.1-1_all.deb
sudo dpkg -i cuda-keyring_1.1-1_all.deb
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-3
and every apt update reports the error that there is a dependency to the unfinished package, need to "apt -f install", but when executing this command, it will install the infinished dependency packages, which leads to no-space error.
sudo apt-get --fix-broken install
Here are commands that are not useful:
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get -f install
Try to reslove depencencies:
sudo dpkg --configure -a
sudo apt-get -f install
dpkg -l | grep cuda-toolkit
iU cuda-toolkit 12.3.2-1 amd64 CUDA Toolkit meta-package
iU cuda-toolkit-12-3 12.3.2-1 amd64 CUDA Toolkit 12.3 meta-package
ii cuda-toolkit-12-3-config-common 12.3.101-1 all Common config package for CUDA Toolkit 12.3.
ii cuda-toolkit-12-config-common 12.3.101-1 all Common config package for CUDA Toolkit 12.
ii cuda-toolkit-config-common 12.3.101-1 all Common config package for CUDA Toolkit.
and these packages have dependencies problems that are showed in the "dpkg --configure -a"
Solve method_1 remove old-version kernels to free space
dpkg --list 'linux-image*'
Or:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
TO remove:
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs dpkg --remove
What is the point here
To use dpkg
instead of apt-get purge
.
And in the same way, we can use aptitude
sometimes to replace apt
to solve lock problem.
Solve method_2 --force
# remove packages in dpkg
dpkg --purge --force-all cuda-toolkit
# and force remove in apt
sudo apt-get -f autoremove