![意外拒绝使用 apt 安装 nvidia-cudnn 许可证,现在我无法卸载它](https://linux22.com/image/950054/%E6%84%8F%E5%A4%96%E6%8B%92%E7%BB%9D%E4%BD%BF%E7%94%A8%20apt%20%E5%AE%89%E8%A3%85%20nvidia-cudnn%20%E8%AE%B8%E5%8F%AF%E8%AF%81%EF%BC%8C%E7%8E%B0%E5%9C%A8%E6%88%91%E6%97%A0%E6%B3%95%E5%8D%B8%E8%BD%BD%E5%AE%83.png)
我尝试安装 nvidia-cudnn,但速度有点快,提示也有点乱。我在尝试安装时不小心按了拒绝。现在,当我尝试卸载时,出现以下错误:
$ sudo apt purge nvidia-cudnn -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED
nvidia-cudnn*
0 to upgrade, 0 to newly install, 1 to remove and 3 not to upgrade.
After this operation, 45.1 kB disk space will be freed.
(Reading database ... 203730 files and directories currently installed.)
Removing nvidia-cudnn (8.2.4.15~cuda11.4) ...
Purging cuDNN installation from /usr
dpkg: error processing package nvidia-cudnn (--remove):
installed nvidia-cudnn package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
nvidia-cudnn
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
手动删除sudo rm -r /usr/share/doc/nvidia-cudnn
然后sudo rm /var/lib/dpkg/info/nvidia-cudnn*
似乎sudo apt purge nvidia-cudnn
不起作用。当我尝试再次安装时,不再提示我输入许可证。我尝试在“卸载”和重新安装之间重新启动。许可证接受/拒绝信息保存在哪里?我如何强制它再次提示我输入许可证?
在发生混乱之前和之后我都使用此命令来安装 cudnnsudo apt install nvidia-cudnn
现在我得到的是:
$ sudo apt install nvidia-cudnn
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed
nvidia-cudnn
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 13.2 kB of archives.
After this operation, 45.1 kB of additional disk space will be used.
Get:1 http://gb.archive.ubuntu.com/ubuntu jammy/multiverse amd64 nvidia-cudnn amd64 8.2.4.15~cuda11.4 [13.2 kB]
Fetched 13.2 kB in 0s (971 kB/s)
Preconfiguring packages ...
Selecting previously unselected package nvidia-cudnn.
(Reading database ... 203718 files and directories currently installed.)
Preparing to unpack .../nvidia-cudnn_8.2.4.15~cuda11.4_amd64.deb ...
Unpacking nvidia-cudnn (8.2.4.15~cuda11.4) ...
Setting up nvidia-cudnn (8.2.4.15~cuda11.4) ...
答案1
卸载过程失败,因为预删除脚本 ( /var/lib/dpkg/info/nvidia-cudnn.prerm
) 返回非零退出状态。在内部,预删除脚本调用
update-nvidia-cudnn -p
位于/usr/sbin/update-nvidia-cudnn
第 164 行之后的 ( echo Purging cuDNN installation from ${PREFIX}
) 运行的命令purge_cudnn ${PREFIX}
失败。
我能够通过强制exit 0
从文件第 164 行后update-nvidia-cudnn -p
添加来解决这个问题。exit 0
/usr/sbin/update-nvidia-cudnn
综上所述,将文件末尾编辑/usr/sbin/update-nvidia-cudnn
为:
...
elif test "${DO_PURGE}" -ne 0; then
echo Purging cuDNN installation from ${PREFIX}
exit 0 # added
purge_cudnn ${PREFIX}
fi
卸载过程即可完成。然后如果nvidia-cudnn
再次安装,安装程序将再次要求您同意许可证。
答案2
要删除已安装的应用程序,正确的方法是执行安装的反向命令。
安装 nvidia-cudnn
这是您用于安装的命令。因此,删除应用程序的命令将是。
sudo apt 删除 nvidia-cudnn
强行移除不是一个好主意,而且可能会留下一些残渣。