W: GPG error: cudnn GPG key 错误

apt

key Error

cudnn安装完毕后出现错误,显示软件源没有gpg key验证,网上都是清一色的sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15198637E3EC4A60,但是这只是其他情况,这里的cudnn还是有一些问题,运行后显示gpg: keyserver receive failed: No data,没有找到对应的key。最终仔细分析提示,man apt-secure去查看对应的说明,man手册里详细介绍了一些apt基础知识,大概就是没有这个gpg key,我update软件源列表就会出错,所以必须添加这个gpg key。

Get:1 file:/var/cudnn-local-repo-ubuntu2004-8.4.1.50  InRelease [1575 B]
Get:1 file:/var/cudnn-local-repo-ubuntu2004-8.4.1.50  InRelease [1575 B]
Err:1 file:/var/cudnn-local-repo-ubuntu2004-8.4.1.50  InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 15198637E3EC4A60
Hit:2 https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal InRelease        
Hit:3 https://mirrors.cloud.tencent.com/ubuntu focal InRelease                 
Hit:4 https://mirrors.cloud.tencent.com/ubuntu focal-updates InRelease         
Hit:5 https://mirrors.cloud.tencent.com/ubuntu focal-backports InRelease       
Hit:6 https://mirrors.cloud.tencent.com/ubuntu focal-security InRelease        
Hit:7 http://packages.microsoft.com/repos/code stable InRelease                
Hit:9 https://nvidia.github.io/libnvidia-container/stable/ubuntu18.04/amd64  InRelease
Hit:8 https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64  InRelease
Hit:10 http://packages.ros.org/ros2/ubuntu focal InRelease                     
Reading package lists... Done
W: GPG error: file:/var/cudnn-local-repo-ubuntu2004-8.4.1.50  InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 15198637E3EC4A60
E: The repository 'file:/var/cudnn-local-repo-ubuntu2004-8.4.1.50  InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: Target Packages (Packages) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1
W: Target Translations (en) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1
W: Target Translations (zh_CN) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1
W: Target Packages (Packages) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1
W: Target Translations (en) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1
W: Target Translations (zh_CN) is configured multiple times in /etc/apt/sources.list:58 and /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list:1

回忆安装cuda的过程,发现所有的key都在/usr/share/keyrings/里,cuda安装时设置仓库源和GPG key的命令如下

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
      && curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
      && curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
            sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
            sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

其中是先下载再安装到/usr/share/keyrings
因此我这里也缺少一个key,然后前往/var/cudnn-local-repo-ubuntu2004-8.4.1.50文件夹,发现包含许多gpg文件,sudo cp /var/cudnn-local-repo-ubuntu2004-8.4.1.50/*.gpg /usr/share/keyrings/复制到/usr/share/keyrings即可。
最终复制错误信息到谷歌查看,也在ubuntu论坛查找到类似的情况,有之处同样的方案

源重复的warning

最后,那个Warning就是源重复,按照提示注释掉/etc/apt/sources.list:58的软件源。
查看了/etc/apt/sources.list.d/显示的内容:
deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /
可以看到,这个deb包不仅有源还有注册的gpg key的路径,反思上面的问题就是gpg key出现错误。

总结

此刻update一下,没有出现报错了,问题成功解决。
心得体会如下:

  • 平时下载软件不能只按照官网的命令行复制操作,出现问题了茫然失措,还是要基本了解下载的流程,安装ros、cuda等都是自己通过echo在/etc/apt/sources.list添加源,然后从链接下载gpg key并且激活,激活的方式一般是直接复制或者apt-key等命令,之后就可以update更新软件列表,就可以直接install这个包了。大致流程都如上所示,具体的细节可以不掌握,但是使用的命令还可以看一眼,根据命令可以猜测大致的过程,也便于后续问题的排查。
  • 终端可以使用export LC_ALL=C临时切换到英文,复制到谷歌去查找bug,效率会高很多。csdn上全是一篇文章复制来复制去,无效信息太多。。。
  • 19
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

迷途-归处

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值