You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/python/profiler.md
+15-12Lines changed: 15 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -195,10 +195,10 @@ print(profiler.dumps())
195
195
You can also dump the information collected by the profiler into a `json` file using the `profiler.dump()` function and view it in a browser.
196
196
197
197
```python
198
-
profiler.dump()
198
+
profiler.dump(finished=False)
199
199
```
200
200
201
-
`dump()` creates a `json` file which can be viewed using a trace consumer like `chrome://tracing` in the Chrome browser. Here is a snapshot that shows the output of the profiling we did above.
201
+
`dump()` creates a `json` file which can be viewed using a trace consumer like `chrome://tracing` in the Chrome browser. Here is a snapshot that shows the output of the profiling we did above. Note that setting the `finished` parameter to `False` will prevent the profiler from finishing dumping to file. If you just use `profiler.dump()`, you will no longer be able to profile the remaining sections of your model.
Here, we have created a custom operator called `MyAddOne`, and within its `forward()` function, we simply add one to the input. We can visualize the dump file in `chrome://tracing/`:
@@ -267,10 +264,10 @@ Please note that: to be able to see the previously described information, you ne
@@ -280,9 +277,15 @@ c = b.bind(mx.cpu(), {'a': inp})
280
277
y = c.forward()
281
278
mx.nd.waitall()
282
279
profiler.set_state('stop')
280
+
print(profiler.dumps())
283
281
profiler.dump()
284
282
```
285
283
284
+
### Some Rules to Pay Attention to
285
+
1. Always use `profiler.dump(finished=False)` if you do not intend to finish dumping to file. Otherwise, calling `profiler.dump()` in the middle of your model may lead to unexpected behaviors; and if you subsequently call `profiler.set_config()`, the program will error out.
286
+
287
+
2. You can only dump to one file. Do not change the target file by calling `profiler.set_config(filename='new_name.json')` in the middle of your model. This will lead to incomplete dump outputs.
288
+
286
289
## Advanced: Using NVIDIA Profiling Tools
287
290
288
291
MXNet's Profiler is the recommended starting point for profiling MXNet code, but NVIDIA also provides a couple of tools for low-level profiling of CUDA code: [NVProf](https://devblogs.nvidia.com/cuda-pro-tip-nvprof-your-handy-universal-gpu-profiler/), [Visual Profiler](https://developer.nvidia.com/nvidia-visual-profiler) and [Nsight Compute](https://developer.nvidia.com/nsight-compute). You can use these tools to profile all kinds of executables, so they can be used for profiling Python scripts running MXNet. And you can use these in conjunction with the MXNet Profiler to see high-level information from MXNet alongside the low-level CUDA kernel information.
0 commit comments