意外拒绝使用 apt 安装 nvidia-cudnn 许可证,现在我无法卸载它

意外拒绝使用 apt 安装 nvidia-cudnn 许可证,现在我无法卸载它

我尝试安装 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

强行移除不是一个好主意,而且可能会留下一些残渣。

相关内容