ModuleNotFoundError:没有名为“torch.utils.benchmark”的模块

问题描述 投票:0回答:1

我一直在尝试使用 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
。根本原因可能是什么?

python python-3.x pytorch tensorboard torchvision
1个回答
0
投票

您尝试过升级手电筒吗?我看到您正在使用 1.4.0,但目前 1.9.0 可用。

pip install torch --upgrade

我已经按照您在 1.9.0 中描述的方式测试了模块的导入,并且没有收到任何错误。

© www.soinside.com 2019 - 2024. All rights reserved.