首页 > 编程知识 正文

torch.scatter,如何做benchmark

时间:2023-05-03 07:31:05 阅读:175277 作者:4884

首先,为了理解什么是backends,Pytorch的backends是该调用的基础库。 torch的backends包括以下内容:

cuda

cudnn

mkl

mkldnn

openmp

代码torch.backends.cudnn.benchmark主要为Pytorch的cudnn基础库设置,并输入为布尔值True或False。

如果设置为True,cuDNN将测量其库中多个卷积算法的速度,并选择其中最快的卷积算法。

请看官方文档的说明:

因此,如果将此参数设置为True,则启动算法之前的时间将会变慢,但算法运行时速度会非常快。

官网论坛一位海外网友表示,只要输入大小固定,采用cudnn.benchmark就可以加速推理和训练。 在启动时以外花额外的时间构成。 但是,对于输入大小变动的东西,每次变更都会被配置,反而会影响速度。

英语的原始回答如下。 It enables benchmark mode in cudnn。

benchmarkmodeisgoodwheneveryourinputsizesforyournetworkdonotvary.this way、 cudnwillookfortheoptimalsetofalgorithmsforthatparticularconfiguration (whichtakessometime ).thisusuallyleadstofasterruntime

utifyourinputsizeschangesateachiteration,thencudnwillbenchmarkeverytimeanewsizeappears,possiblyleadingtoworseruntimepeperfers

设定为False

此功能将关闭。 见链接1:https://py torch.org/docs/stable/backends.html

参考链接2:https://discuss.py torch.org/t/what-does-torch-backends-Cu dnn-benchmark-do/5936

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。