【问题标题】:TypeError when using torch.autograd.profiler.profile使用 torch.autograd.profiler.profile 时出现类型错误
【发布时间】:2021-05-09 14:18:19
【问题描述】:

我正在尝试分析我的模型的内存消耗,如下所述: https://pytorch.org/tutorials/recipes/recipes/profiler_recipe.html

使用这些行:

with profiler.profile(profile_memory=True, record_shapes=True) as prof:
    tubes, _, _ = zip(*model(imgs, img_metas, return_loss=False))
print(prof.key_averages().table(sort_by="self_cpu_memory_usage", row_limit=10))

但我收到此错误

TypeError: init() 得到了一个意外的关键字参数 'profile_memory'

那么,这个错误的原因和/或解决方案是什么?

【问题讨论】:

  • 能否在问题中包含完整的代码
  • 您使用的 PyTorch 版本是什么?
  • pytorch 1.1.0, py3.7_cuda10.0.130_cudnn7.5.1_0
  • 为了包含完整的代码,我认为是无关紧要的。

标签: pytorch profiler


【解决方案1】:

您需要升级您的 PyTorch 版本。查看the code,可以看到profile_memory参数是在PyTorch v1.6.0中首先添加到函数签名中的。

您也可以通过torch.autograd 的文档看到这一点。可以看到 PyTorch v1.1.0 中不存在该参数。

【讨论】:

    猜你喜欢
    • 2021-09-06
    • 2011-10-17
    • 2017-06-15
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多