torch profiler 性能分析 | 关于版本、设置的BUG


记录使用torch profiler分析性能过程中遇到的问题和解决方法。

版本问题

pytorch官网的 profiler tutorial 提到了在DDP模式下有个 Distributed View 可以分析多卡分布式训练时的同步时间和数据传输时间。
profiler_distributed_view
但是实际应用时却没有显示。根据github里的 issues 得知,只有pytorch版本降到1.11.0才能显示该视图。实测从2.0.0降到1.11.0后,显示正常。

参数设置问题

官网的示例设置如下:

prof = torch.profiler.profile(
        schedule=torch.profiler.schedule(wait=1, warmup=1, active=3, repeat=2),
        on_trace_ready=torch.profiler.tensorboard_trace_handler('./log/resnet18'),
        record_shapes=True,
        with_stack=True)

用该设置在运行自己的程序时,非DDP模式下报错“Segmentation fault (core dumped) ”,DDP模式下报错“raise ProcessExitedException(
torch.multiprocessing.spawn.ProcessExitedException: process 2 terminated with signal SIGSEGV
”。

另外,运行了github源码的 ddp example, 显示一切正常。 对两者进行对比后发现,实际with_stack设置为False才能正常运行。该参数的意思是记录操作的源信息(文件和行号),具体产生报错的原因还未可知。

其它报错

因为版本和程序的不同可能会出现以下报错,但不影响运行。

  1. 运行自己的程序时出现了“[W CPUAllocator.cpp:219] Memory block of unknown size was allocated before the profiling started, profiler results will not include the deallocation event
  2. 使用pytorch2.0.0和设置skip_first参数之后,程序都会出现“[W kineto_shim.cpp:343] Profiler is not initialized: skipping step() invocation
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值