问题一
1.问题描述:
运行深度学习时报错:
UserWarning: Failed to load image Python extension: warn(f"Failed to load image Python extension: {e}")
2.原因:
1)导入torchvision包时就会报错。
import torch
import torchvision
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension:
warn(f"Failed to load image Python extension: {e}")
2)可能的原因一:torch与torchvision版本不匹配
参考链接
3)可能的原因二:torch与torchvision版本特定版本就会出现这个问题
参考链接
3.解决办法:
如下面的版本即便是匹配了也会出现,降级1.9版本即可解决。
Snipaste_2022-11-08_10-28-00.png
问题二
1.问题描述:
用mps加速时,运行深度学习时报错:
Snipaste_2022-11-08_11-00-28.png
RuntimeError: don't know how to restore data location of torch.storage._UntypedStorage (tagged with mps)
2.解决办法:
pytorch版本1.12.0,支持mps加速,但是依旧报错;更换版本1.12.1依旧。最后通过安装最新版本1.13.0,解决问题。
parser.add_argument('--device', default='mps',
help='device id (i.e. 0 or 0,1 or cpu)')
if not torch.backends.mps.is_available():
if not torch.backends.mps.is_built():
print(
"MPS not available because the current PyTorch install was not "
"built with MPS enabled.")
else:
print(
"MPS not available because the current MacOS version is not 12.3+ "
"and/or you do not have an MPS-enabled device on this machine.")
device = torch.device('cpu')
else:
device = torch.device(args.device)
网友评论