使用torch.cuda.Event

使用torch.cuda.Event,第1张

import torch

time_pool = 0

for input_tensor,label in dataloader:

    start = torch.cuda.Event(enable_timing=True)
    end = torch.cuda.Event(enable_timing=True)
        
    start.record(stream=torch.cuda.current_stream())
    output_tensor = model(input_tensor)
    end.record(stream=torch.cuda.current_stream())
    end.synchronize()

    time_pool += start.elapsed_time(end)

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/714783.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-24
下一篇 2022-04-24

发表评论

登录后才能评论

评论列表(0条)

保存