记录在anconda新建虚拟环境中安装pytorch遇到的问题

首先借鉴这篇文章

torch.cuda.is_available()返回false——解决办法_cuda available false-CSDN博客

如果你想在anaconda下的虚拟环境使用它,没问题,这里提供一个投机取巧的方法:
找到刚才在cmd中下载成功的三个东西,他们在你的anaconda目录下的lib->site-packages,例如我的在D:\anaconda\Lib\site-packages

这里的方法我不能正常使用,所以我在anaconda protempt中切换到指定的虚拟环境

使用pip方法重新安装

这里遇到了

查了查,说是默认的pip源的问题,这里可以使用国内的镜像

国内的一些pip源:

阿里云 http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

使用方法:在后面直接 -i 加 url

最后出现这样的错误

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.15.2+cu117 requires torch==2.0.1, but you have torch 2.0.0 which is incompatible.

发现是已经有2.0的torch,使用指令 pip uninstall torch,重新安装2.1版本的torch

python
import torch
torch.cuda.is_available()
 

最后验证成功,返回为True

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值