先是想着尝鲜,安装了最新的CUDA11.4:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda-repo-ubuntu1804-11-4-local_11.4.1-470.57.02-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-4-local_11.4.1-470.57.02-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-4-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

结果安装pytorch时发现最新的1.9也只支持到了CUDA11.1,虽然不影响pytorch的安装成功,但是跑代码时用到cuda时就报下面的错误:

GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/

warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
>>> print(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/python3/lib/python3.9/site-packages/torch/tensor.py", line 193, in __repr__
    return torch._tensor_str._str(self)
  File "/usr/local/python3/lib/python3.9/site-packages/torch/_tensor_str.py", line 383, in _str
    return _str_intern(self)
  File "/usr/local/python3/lib/python3.9/site-packages/torch/_tensor_str.py", line 358, in _str_intern
    tensor_str = _tensor_str(self, indent)
  File "/usr/local/python3/lib/python3.9/site-packages/torch/_tensor_str.py", line 242, in _tensor_str
    formatter = _Formatter(get_summarized_data(self) if summarize else self)
  File "/usr/local/python3/lib/python3.9/site-packages/torch/_tensor_str.py", line 90, in __init__
    nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0))
RuntimeError: CUDA error: no kernel image is available for execution on the device

于是使用下面的命令删掉CUDA11.4:

sudo apt-get --purge remove "cuda*"
sudo apt-get --purge remove "*nvidia*470"

然后再使用下面的命令安装CUDA11.1.1

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804-11-1-local_11.1.1-455.32.00-1_amd64.deb
sudo apt-key add /var/cuda-repo-ubuntu1804-11-1-local/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

结果报下面的错误:

You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda : Depends: cuda-11-1 (>= 11.1.1) but it is not going to be installed
 nvidia-dkms-470 : Depends: nvidia-kernel-source-470 but it is not going to be installed
                   Depends: nvidia-kernel-common-470 (= 470.57.02-0ubuntu1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

反复删除安装了几遍还是这样,想想怎么还提示

cuda : Depends: cuda-11-1 (>= 11.1.1) but it is not going to be installed

是不是CUDA11.4的包没删除干净,于是执行:

sudo apt-get --purge remove "cuda*"
sudo apt-get --purge remove "*nvidia*"

把cuda和nvidia驱动所有相关的东西都删了(nvidia docker2也被误删了),再安装CUDA11.1.1,就顺利成功了。

不过由于把nvidia docker2也误删了,所以还得再安装一下:

sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

如果安装CUDA后没有重启让driver生效,那么在通过docker run --gpus all ...或者nvidia-docker run ...启动nvidia docker时会报错:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"process_linux.go:432: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: initialization error: nvml error: driver/library version mismatch\\\\n\\\"\"": unknown.

这种错误一般是因为GPU驱动没有安装或者安装后没有生效。

安装CUDA时报错packages have unmet dependencies的一个可能原因相关推荐

  1. ubuntu报错解决:The following packages have unmet dependencies:

    我安装了全新的ubuntu,然后安装软件时报错了: root@ubuntu:/home/zhang# apt install g++ Reading package lists... Done Bui ...

  2. ubuntu 安装依赖包时出现The following packages have unmet dependencies:

    本人环境:ubuntu18.04 docker中安装opencv的依赖apt install libopencv-dev出现此问题: Reading package lists... Done Bui ...

  3. The following packages have unmet dependencies: libx11-dev : Depends: libx11-6 (= 2:1.6.7-1+deb10u2

    ubuntu apt-get install 时报错:Depends: ***(=某版本)but***(另一版本)is to be installed 比如: The following packag ...

  4. The following packages have unmet dependencies: deepin.com.wechat:i386 : Depends: deepin-wine:i386

    系统之前装过微信,安装gitk时报错: Heisenberg海森堡:~$ sudo apt-get -f install gitk Reading package lists... Done Buil ...

  5. The following packages have unmet dependencies: build-essential : Depends: libc6-dev but it is not

    本文为转载,原文地址: http://blog.csdn.net/duanlove/article/details/54666441 操作系统(Ubuntu server)环境: uname -a L ...

  6. The following packages have unmet dependencies

    background: 之前使用dpkg装mysql时候,失败了,应该是把pkg的版本弄乱了. 这次安装ldap,报该错误:The following packages have unmet depe ...

  7. The following packages have unmet dependencies错误

    转载自:https://blog.csdn.net/weixin_33804582/article/details/94657169 但是我这边,是通过换成aptitude 去安装就行了 sudo a ...

  8. win10中anaconda安装tensorflow时报错Traceback (most recent call last): File “E:\Anaconda3\lib\site-packag

    windows系统anaconda安装tensorflow时报错解决办法. 报错: Traceback (most recent call last): File "E:\Anaconda3 ...

  9. 解决The following packages have unmet dependencies: vim : Depends: vim-runtime (= 2:7.4.052-1ubu

    仔细看报错说明,把报错的软件删了,再当前的软件,刚刚删了的会自动补上合适的版本 sudo apt-get remove vim-runtime sudo apt-get install vim roo ...

最新文章

  1. Java 理解泛型的基本含义
  2. 第六章 逻辑回归-机器学习老师板书-斯坦福吴恩达教授
  3. JS开源框架Stimulus:让web应用在移动端达到原生体验!
  4. 小程序 省市区县三级联动选择器(caseCade)
  5. IOS学习笔记 -- scrollView和tableView整理
  6. 我的编程之路(二十五) 上海的老同学
  7. Hibernate框架核心组件
  8. 程序员代码面试指南(左程云著)java学习笔记
  9. vb adodc连接mysql_VB中用ADODC控件连接ACCESS数据库
  10. java因子分析_spss因子分析
  11. ftl不存在为真_ftl 语法
  12. css模板 bulma_用Bulma在6分钟内学习CSS框架
  13. dns被劫持有什么现象?DNS是什么 dns被劫持了如何解决
  14. P4315 月下“毛景树” 树链剖分+线段树
  15. 第六讲 幂级数的收敛半径和收敛域
  16. gitee怎么看用户名_多账号如何登录gitee
  17. c语言无符号字符型5是什么,C语言中无符号型别是什么意思啊?
  18. python 头条新闻机器人_新闻写作机器人的应用及前景展望——以今日头条新闻机器人张小明(xiaomingbot)为例...
  19. VLC捕获网络摄像头视频(rtsp协议)
  20. php隐写,数据隐藏技术

热门文章

  1. Ventoy多镜像+防毒全能U盘工具箱
  2. SpringBoot中关于RunWith以及SpringBootTest
  3. 如何让你的程序同时只能运行一个?
  4. 【Unity3D】基于AssetBundle实现资源热更新
  5. JavaSE基础知识
  6. Linux入门居然只要会看就行!!!
  7. 我的世界梦世界服务器物品怎么卖,我的世界流浪商人交易表_我的世界流浪商人交易表图物品大全_攻略...
  8. 图像二值化方法及适用场景分析(OTSU Trangle 自适应阈值分割)
  9. 为什么5G能比4G快十倍?
  10. 联想小新air14和联想pro14哪个好