cuda - 如何使用 NSight Compute 2019 CLI 获取内核的执行时间?
问题描述
假设我有一个myapp
不需要命令行参数的可执行文件,并启动一个 CUDA kernel mykernel
。我可以调用:
nv-nsight-cu-cli -k mykernel myapp
并获得如下所示的输出:
==PROF== Connected to process 30446 (/path/to/myapp)
==PROF== Profiling "mykernel": 0%....50%....100% - 13 passes
==PROF== Disconnected from process 1234
[1234] myapp@127.0.0.1
mykernel(), 2020-Oct-25 01:23:45, Context 1, Stream 7
Section: GPU Speed Of Light
--------------------------------------------------------------------
Memory Frequency cycle/nsecond 1.62
SOL FB % 1.58
Elapsed Cycles cycle 4,421,067
SM Frequency cycle/nsecond 1.43
Memory [%] % 61.76
Duration msecond 3.07
SOL L2 % 0.79
SM Active Cycles cycle 4,390,420.69
(etc. etc.)
--------------------------------------------------------------------
(etc. etc. - other sections here)
到目前为止,一切都很好。mykernel
但是现在,我只想要- 而没有其他输出的整体内核持续时间。看着nv-nsight-cu-cli --query-metrics
,我看到,除其他外:
gpu__time_duration incremental duration in nanoseconds; isolated measurement is same as gpu__time_active
gpu__time_active total duration in nanoseconds
所以,它一定是其中之一,对吧?但是当我跑步时
nv-nsight-cu-cli -k mykernel myapp --metrics gpu__time_duration,gpu__time_active
我得到:
==PROF== Connected to process 30446 (/path/to/myapp)
==PROF== Profiling "mykernel": 0%....50%....100% - 13 passes
==PROF== Disconnected from process 12345
[12345] myapp@127.0.0.1
mykernel(), 2020-Oct-25 12:34:56, Context 1, Stream 7
Section: GPU Speed Of Light
Section: Command line profiler metrics
---------------------------------------------------------------
gpu__time_active (!) n/a
gpu__time_duration (!) n/a
---------------------------------------------------------------
我的问题:
- 为什么我得到“n/a”值?
- 我怎样才能得到我所追求的实际价值,而不是别的?
备注::
- 我将 CUDA 10.2 与 NSight Compute 版本 2019.5.0(内部版本 27346997)一起使用。
- 我意识到我可以过滤不合格调用的标准输出流,但这不是我想要的。
- 我实际上只想要原始数字,但我愿意接受并使用
--csv
最后一个字段。 - 在nvprof 过渡指南中找不到任何相关内容。
解决方案
tl; dr:您需要指定适当的“子度量”:
nv-nsight-cu-cli -k mykernel myapp --metrics gpu__time_active.avg
(基于@RobertCrovella 的评论)
CUDA 的分析机制收集“基本指标”,这些指标确实以--list-metrics
. 对于这些中的每一个,都采集了多个样本。在 NSight Compute 2019.5 版本中,您不能只获取原始样本;您只能获得“子度量”值。
“子度量”本质上是将样本序列聚合为标量值。不同的指标有不同种类的子指标(见这个清单);对于gpu__time_active
,它们是:.min
, .max
, .sum
, .avg
. 是的,如果您想知道 - 他们缺少像方差或样本标准差这样的第二时刻指标。
因此,您必须指定一个或多个子指标(参见上面的示例),或者升级到更新版本的 NSight Compute,您实际上可以通过它获得所有样本。
推荐阅读
- android - 如何从汽车方向盘下方的控件中捕捉事件
- angularjs - AngularJS ng-src 不加载具有相同 url 的新图像
- php - 您可以使用配置值关闭 PHP 中的 SSL 验证吗?
- python-3.x - pdoc 不突出显示文档字符串中的参数
- go - 为什么在更改导入时 Golang Intellisense 在 VS Code 中速度很慢?
- r - geom_sf 在绘制 shapefile 时忽略填充变量
- javascript - 使用给定的 Redux 状态加载 React 应用程序?
- swift - NSSegmentedControl 不会使模板图像变暗
- botframework - node js bot框架中的setTimout函数中的对话框上下文不可用
- django - Django Azure 广告 AADSTS50011:请求中指定的回复 url 与为应用程序配置的回复 url 不匹配