我一直在尝试使用 torch benchmark 模块来分析代码。验证所有必需的导入均已到位:
import torch
import torchvision
import torch.utils.benchmark
此外,这些是已安装的版本:
torch -> 1.4.0
torchvision -> 0.2.1
tensorflow -> 1.12.0
tensorflow-gpu -> 1.12.0
tensorboard -> 2.5.0
但是我在导入
ModuleNotFoundError: No module named 'torch.utils.benchmark'
时仍然遇到错误:torch.utils.benchmark
。根本原因可能是什么?
您尝试过升级手电筒吗?我看到您正在使用 1.4.0,但目前 1.9.0 可用。
pip install torch --upgrade
我已经按照您在 1.9.0 中描述的方式测试了模块的导入,并且没有收到任何错误。