学习记录:AttributeError: module ‘torch._C‘ has no attribute ‘_cuda_setDevice‘

运行main.py时报错如下:

AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

网上查询原因:说我安装的torch是适合CPU的,而不是适合GPU的。于是我查询pytorch

>python
Python 3.8.0 (default, Nov 6 2019, 16:00:48) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import torch
>>>torch.cuda.is_available()
False

显而易见,环境使用的是CPU版本的torch,但是我仔细检查了一下我安装的命令,如下

conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=11.3 -c pytorch -c conda-forge

发现并没有什么问题,查询才知道,windows系统会默认安装适合cpu版本的,于是我去

https://download.pytorch.org/whl/torch_stable.html

下载三个安装包,适合GPU版本的

分别pip install 他们,这样就能够安装适合GPU版本的torch了

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值