2017-03-09 38 views
0

是否可以使用nvprof來計算CUDA內核執行次數(即啓動了多少個內核)?使用nvprof對CUDA內核執行進行計數

現在當我運行nprof我所看到的是:

==537== Profiling application: python tf.py 
==537== Profiling result: 
Time(%)  Time  Calls  Avg  Min  Max Name 
51.73% 91.294us  20 4.5640us 4.1280us 6.1760us [CUDA memcpy HtoD] 
43.72% 77.148us  20 3.8570us 3.5840us 4.7030us [CUDA memcpy DtoH] 
    4.55% 8.0320us   1 8.0320us 8.0320us 8.0320us [CUDA memset] 

==537== API calls: 
Time(%)  Time  Calls  Avg  Min  Max Name 
90.17% 110.11ms   1 110.11ms 110.11ms 110.11ms cuDevicePrimaryCtxRetain 
    6.63% 8.0905ms   1 8.0905ms 8.0905ms 8.0905ms cuMemAlloc 
    0.57% 700.41us   2 350.21us 346.89us 353.52us cuMemGetInfo 
    0.55% 670.28us   1 670.28us 670.28us 670.28us cuMemHostAlloc 
    0.28% 347.01us   1 347.01us 347.01us 347.01us cuDeviceTotalMem 
... 

回答

1

是,其可能的。如果你不知道,有documentation和命令行幫助可用(nvprof --help)。

什麼你問的是nvprof的最簡單的用法提供:

nvprof ./my_application

這將輸出(除其他事項外)的名字內核列表,多少次,每次一個被啓動,並且每個GPU佔用的總體GPU佔用的百分比。

下面是一個例子:

$ nvprof ./t1288 
==12904== NVPROF is profiling process 12904, command: ./t1288 
[email protected]: 0x402add 
[email protected]: 0x8 
run on device 
func_A is correctly invoked! 
run on host 
func_A is correctly invoked! 
==12904== Profiling application: ./t1288 
==12904== Profiling result: 
Time(%)  Time  Calls  Avg  Min  Max Name 
98.93% 195.28us   1 195.28us 195.28us 195.28us run_on_device(Parameters*) 
    1.07% 2.1120us   1 2.1120us 2.1120us 2.1120us assign_func_pointer(Parameters*) 

==12904== Unified Memory profiling result: 
Device "Tesla K20Xm (0)" 
    Count Avg Size Min Size Max Size Total Size Total Time Name 
     1 4.0000KB 4.0000KB 4.0000KB 4.000000KB 3.136000us Host To Device 
     6 32.000KB 4.0000KB 60.000KB 192.0000KB 34.20800us Device To Host 
Total CPU Page faults: 3 

==12904== API calls: 
Time(%)  Time  Calls  Avg  Min  Max Name 
98.08% 321.35ms   1 321.35ms 321.35ms 321.35ms cudaMallocManaged 
    0.93% 3.0613ms  364 8.4100us  278ns 286.84us cuDeviceGetAttribute 
    0.42% 1.3626ms   4 340.65us 331.12us 355.60us cuDeviceTotalMem 
    0.38% 1.2391ms   2 619.57us 113.13us 1.1260ms cudaLaunch 
    0.08% 251.20us   4 62.798us 57.985us 70.827us cuDeviceGetName 
    0.08% 246.55us   2 123.27us 21.343us 225.20us cudaDeviceSynchronize 
    0.03% 98.950us   1 98.950us 98.950us 98.950us cudaFree 
    0.00% 8.9820us  12  748ns  278ns 2.2670us cuDeviceGet 
    0.00% 6.0260us   2 3.0130us  613ns 5.4130us cudaSetupArgument 
    0.00% 5.7190us   3 1.9060us  490ns 4.1130us cuDeviceGetCount 
    0.00% 5.2370us   2 2.6180us 1.2100us 4.0270us cudaConfigureCall 
$ 

在上面的例子run_on_deviceassign_func_pointer是內核的名字。在我鏈接的文檔中也有示例輸出。

+0

我更新了我在運行nprof時看到的問題。我沒有看到任何叫做內核的東西。 –

+0

我可以考慮兩種可能性:1.你的python代碼沒有進行任何(成功的)內核調用 - 你在做適當的錯誤檢查嗎?你確定知道內核被調用嗎? 2.你可能需要告訴nvprof來描述子進程 - 如何做到這一點在我鏈接的文檔中有介紹。這將取決於你在'tf.py'中發佈什麼類型的工作 - 可能是tensorflow。 –

+0

好的,結果沒有內核被調用。 –