当前位置:网站首页>无法导入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'
边栏推荐
- 618, you may be able to wake up a little bit
- Disk management and file systems
- Problems encountered in installing Yolo3 target detection module in Autoware
- Operation and maintenance engineer, come and pick up the wool
- Alibaba Cloud Video on Demand
- The highlight moment of operation and maintenance starts with intelligence
- D39_Vector
- ES2020新特性
- Difference between link and @improt
- Tencent Cloud Message Queue CMQ
猜你喜欢
多线程之传递参数
Wireshark packet capture and common filtering methods
从“双卡双待“到”双通“,vivo率先推动DSDA架构落地
The cocos interview answers you are looking for are all here!
[Problem has been resolved]-Virtual machine error contains a file system with errors check forced
VLAN介绍与实验
Mina's long and short connections
NB-IOT智能云家具项目系列实站
错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
System basics - study notes (some command records)
随机推荐
干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
input详解之文件上传
Xiaodu Xiaodu is here!
Does flink cdc currently support Gauss database sources?
Browser Storage for H5
[issue resolved] - jenkins pipeline checkout timeout
VLAN is introduced with the experiment
GetEnumerator method and MoveNext and Reset methods in Unity
深夜小酌,50道经典SQL题,真香~
Drools规则引擎快速入门(一)
Passing parameters in multiple threads
NB-IOT智能云家具项目系列实站
Network Protocol Fundamentals - Study Notes
Mina disconnects and reconnects
The cocos interview answers you are looking for are all here!
多行文本省略
May I ask how to read the binlog of the two tables of hologres through flink sql, and then how to join?
Will intelligent operation and maintenance replace manual operation and maintenance?
5分钟完成mysql离线安装
网络层协议介绍