当前位置:网站首页>无法导入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'
边栏推荐
- In-depth Zabbix user guide - from the green boy
- 数组&的运算
- 摆脱极域软件的限制
- 错误类型:反射。ReflectionException:无法设置属性“xxx”的“类”xxx”与价值“xxx”
- Come, come, let you understand how Cocos Creator reads and writes JSON files
- GetEnumerator method and MoveNext and Reset methods in Unity
- 干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
- What impact does CIPU have on the cloud computing industry?
- Advantages of overseas servers
- 5分钟完成mysql离线安装
猜你喜欢
随机推荐
By solving these three problems, the operation and maintenance efficiency will exceed 90% of the hospital
网络排错基础-学习笔记
Autoware--Beike Tianhui rfans lidar uses the camera & lidar joint calibration file to verify the fusion effect of point cloud images
Met with the browser page
Cocos Creator Mini Game Case "Stick Soldier"
What should I do if the SSL certificate prompts that it is expired or invalid?
LeetCode practice and self-comprehension record (1)
系统基础-学习笔记(一些命令记录)
el-progress实现进度条颜色不同
Xiaodu Xiaodu is here!
Mina断线重连
D39_Eulerian Angles and Quaternions
Will intelligent operation and maintenance replace manual operation and maintenance?
el-progress implements different colors of the progress bar
大小屏适配
docker部署完mysql无法连接
干货!教您使用工业树莓派结合CODESYS配置EtherCAT主站
Complete mysql offline installation in 5 minutes
VLAN介绍与实验
King power volume LinkSLA, realize operations engineer is happy fishing
![[Problem has been resolved]-Virtual machine error contains a file system with errors check forced](/img/07/1222a44dd52b359bf7873e6f3b7ebf.png)








![[问题已处理]-jenkins流水线checkout超时](/img/3d/c14276d2b5ce18fc3d1288abb059c0.png)