iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >pytorch-cuda安装报错
  • 255
分享到

pytorch-cuda安装报错

pytorchpython深度学习 2023-10-03 06:10:41 255人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

2022.12.8在win+cuda11.8下安装最新PyTorch GPU版时遇到包不兼容的问题,该文记录安装的整个流程 一、按照cuda版本在官网找命令 Pytorch官网命令如下 在win

2022.12.8在win+cuda11.8下安装最新PyTorch GPU版时遇到包不兼容的问题,该文记录安装的整个流程

一、按照cuda版本在官网找命令

Pytorch官网命令如下
在win、cuda11.8下安装GPU版Pytorch

conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

分析该命令,-c后面为安装包的源,-c pytorch表示使用官方源,可能出现速度慢等问题

二、换源

因此一般先将conda切换清华源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/conda config --add channels Https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/conda config --set show_channel_urls yesconda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/

三、Bug描述

换源后去掉-c执行命令如下

conda install pytorch torchvision torchaudio pytorch-cuda=11.7

报错包不兼容,出现冲突

Found conflicts! Looking for incompatible packages.This can take several minutes.  Press CTRL-C to abort.Examining torchaudio:  43%|██████████████████████████████████████████████▎     | 3/7 [00:22<00:24,  6.10s/it]/failed                    UnsatisfiableError: The following specifications were foundto be incompatible with the existing python installation in your environment:Specifications:  - torchaudio -> Python[version='2.7.*|3.5.*|3.6.*|>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|3.4.*']Your python: python=3.7If python is on the left-most side of the chain, that's the version you've asked for.When python appears to the right, that indicates that the thing on the left is somehownot available for the python version you are constrained to. Note that conda will notchange your python version to a different minor version unless you explicitly specifythat.The following specifications were found to be incompatible with each other:Output in fORMat: Requested package -> Available versionsPackage typing conflicts for:torchvision -> typing_extensions -> typing[version='>=3.7.4']pytorch -> typing_extensions -> typing[version='>=3.7.4']Package pytorch conflicts for:torchaudio -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0']torchvision -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0|1.5.1|1.5.0|1.4.0|1.3.1|1.3.0|1.2.0|>=1.1.0|>=1.0.0|>=0.4']Package pytorch-cuda conflicts for:pytorch -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8']torchaudio -> pytorch-cuda[version='11.6.*|11.7.*']torchvision -> pytorch==1.13.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8']torchaudio -> pytorch==1.13.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8']torchvision -> pytorch-cuda[version='11.6.*|11.7.*']Package requests conflicts for:python=3.7 -> pip -> requeststorchvision -> request

四、解决方法

参考之前安装成功的命令为

conda install pytorch torchvision torchaudio cudatoolkit=11.3

尝试执行

conda install pytorch torchvision torchaudio cudatoolkit=11.7

报错找不到包

PackagesNotFoundError: The following packages are not available from current channels:  - cudatoolkit=11.7

推测原因可能是cuda11.7将cudatoolkit=11.7换为pytorch-cuda=11.7,而-c nvidia为pytorch-cuda的源。

执行如下命令成功安装

 conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c nvidia  

五、查看是否使用GPU

import torchuse_gpu = torch.cuda.is_available()print(use_gpu)print("devices count:", torch.cuda.device_count())

输出

Truedevices count: 1

来源地址:https://blog.csdn.net/JamesShuker/article/details/128257519

--结束END--

本文标题: pytorch-cuda安装报错

本文链接: https://www.lsjlt.com/news/422915.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作