当前位置:网站首页>无法导入torchvision.io.read_image
无法导入torchvision.io.read_image
2022-08-05 05:25:00 【ProfSnail】
在运行官网pytorch案例的时候,发现无法从torchvision.io中导入read_image。
ImportError: cannot import name 'read_image' from 'torchvision.io'
查看torchvision的版本发现是0.6的落后版本。
In [1]: import torchvision as tv
In [2]: tv.__version__
Out[2]: '0.6.0'
升级torchvision版本即可,使用pip进行升级。
pip install --upgrade torchvision
但是发现存在权限访问异常的问题。
ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'c:\\users\\zhang\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\~orch\\lib\\asmjit.dll'
Consider using the `--user` option or check the permissions.
在升级的时候加上–user选项即可。
pip install --user --upgrade torchvison
检查版本号,发现升级成功。
In [1]: import torchvision as tv
In [2]: tv.__version__
Out[2]: '0.10.0+cpu'
In [3]: tv.io.read_image
Out[3]: <function torchvision.io.image.read_image(path: str, mode: torchvision.io.image.ImageReadMode = <ImageReadMode.UNCHANGED: 0>) -> torch.Tensor>
不过这样还是不行,因为升级到了cpu版本,cuda不能调用了。索性卸载了torch,重新安装了一遍。
pip3 install torch==1.9.0+cu111 torchvision==0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/torch_stable.html
这下就没问题了。
In [1]: import torch
In [2]: torch.__version__
Out[2]: '1.9.0+cu111'
In [3]: torch.cuda.is_available()
Out[3]: True
In [4]: import torchvision as tv
In [5]: tv.__version__
Out[5]: '0.10.0+cu111'
边栏推荐
- Quick question and quick answer - FAQ of Tencent Cloud Server
- Proprietary host CDH
- VRRP overview and experiment
- 从“双卡双待“到”双通“,vivo率先推动DSDA架构落地
- CIPU, what impact does it have on the cloud computing industry?
- Met with the browser page
- 【考研结束第一天,过于空虚,想对自己进行总结一下】
- selenium learning
- In-depth Zabbix user guide - from the green boy
- Vim tutorial: vimtutor
猜你喜欢

单片机期末复习大题

BIO, NIO, AIO practical study notes (easy to understand theory)

网络层协议介绍

云计算基础-学习笔记

Nacos集群搭建

input detailed file upload

Chengyun Technology was invited to attend the 2022 Alibaba Cloud Partner Conference and won the "Gathering Strength and Going Far" Award

config.js related configuration summary

VSCode编写OpenCV

sql server 重复值在后面计数
随机推荐
User and user group management, file permission management
错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
Complete mysql offline installation in 5 minutes
【考研结束第一天,过于空虚,想对自己进行总结一下】
NB-IOT智能云家具项目系列实站
通过反射获取Class对象的四种方式
vs2017关于函数命名方面的注意事项
GetEnumerator method and MoveNext and Reset methods in Unity
Mina's long and short connections
The hook of the operation of the selenium module
Wireshark packet capture and common filtering methods
el-autocomplete use
LeetCode中常用语言的一些基本方法记录
Configuration of routers and static routes
数组&的运算
Programmers should understand I/O this way
指针常量与常量指针 巧记
Insight into the general trend of the Internet, after reading this article, you will have a thorough understanding of Chinese domain names
媒体查询、rem移动端适配
input detailed file upload