ncu: GPU CUDA Kernel Profiler¶
Available¶
- Roihu-GPU: version depends on the CUDA environment
License¶
Usage is possible for both academic and commercial purposes.
Usage¶
NVIDIA Nsight Compute is a CUDA kernel profiler that provides detailed performance data and offers guidance for optimizing your CUDA kernels. The ncu command-line tool collects kernel-level performance metrics, such as computational throughput, memory throughput, memory access efficiency and GPU occupancy.
It is recommended to first use Nsight Systems (nsys) to identify performance
bottlenecks at the application level and then use Nsight Compute for more
detailed analysis of individual CUDA kernels.
Profiling is done in two steps:
- Collect profiling data by running the application with the
ncucommand line tool - Analyze the results with
ncu-uiGUI.
To use ncu, one needs to first load the CUDA module:
Collecting profiling data¶
For collecting data, run your application normally via Slurm and prepend your executable with ncu <profiling options>:
This example collects kernel-level performance metrics and stores the
profiling report in profile.ncu-rep.
Depending on the performance metrics collected, each kernel launch may be replayed multiple times, adding significant overhead to the application runtime. Thus, it is recommended to shorten the duration of the application (e.g. run only a limited number of time steps or iterations), and collect metrics only for the most relevant GPU kernels. See NVIDIA documentation for more details.
Analyzing the results on the command line¶
The profiling report can be inspected directly on the command line:
Analyzing the results in a GUI¶
We recommend analyzing the profiling reports on your local workstation using a local installation of NVIDIA Nsight Compute. This provides a more responsive GUI, especially when analyzing large profiling reports. You do not need to have an NVIDIA GPU on your local workstation to view the reports.
First, check the version of Nsight Compute used to collect the profiling data on Roihu:
Download and install NVIDIA Nsight Compute on your local workstation. We recommend using the same version as the one used to collect the profiling data.
Copy the profiling report (profile.ncu-rep) from Roihu to your
local workstation, for example by running the following command
in a local terminal:
Replace the username and path with your own. For more information, see our instructions for moving data.
Open the downloaded report in the Nsight Compute GUI using
File > Open, or launch the GUI from a local terminal
if ncu-ui is available in your PATH:
Lightweight analysis through X11 forwarding¶
For short and lightweight analysis of small profiling reports, the GUI can be launched on a Roihu-GPU login node:
First, connect to Roihu-GPU with X11 forwarding enabled:
For more information on setting up X11 forwarding, see our SSH instructions for Linux and macOS and Windows.
Load the CUDA module:
Start the GUI: