Code mit NVTX annotieren
Benennen Sie Bereiche für übersichtliche Timelines.
Code mit NVTX annotieren ist eine kostenlose CUDA Academy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des CUDA Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der CUDA Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Timelines Need Labels
A raw timeline is full of anonymous bars. NVTX lets you add your own names so the profiler reads like your code. 🏷️
What NVTX Is
NVTX is NVIDIA's Tools Extension: a tiny library for marking regions and events that Nsight then draws on the timeline.
Including the Header
You start by including one header. After that, the marking calls are available anywhere in your host code.
#include <nvtx3/nvToolsExt.h>Marking a Range
Wrap a section of work in a named range. The push starts it and the pop ends it, drawing one labeled bar.
nvtxRangePush("load data");
// work here
nvtxRangePop();Push and Pop Nest
Ranges nest like brackets. An inner push must pop before its outer one, so labels stack neatly on the timeline.
Instant Markers
For a single moment in time, drop a marker instead of a range. It pins one event, like the start of an epoch.
nvtxMark("epoch start");Color Your Ranges
You can give each range a color so stages stand out at a glance. Loading might be blue, computing might be green.
Readable Timelines
With NVTX, your Nsight view shows phases like preprocess and inference by name. You stop decoding cryptic kernel symbols.
Nearly Free When Off
When no profiler is attached, NVTX calls are almost free. You can leave the annotations in your code with no real cost.
It Is Host-Side
NVTX annotates host code, the CPU side that orchestrates work. It frames the regions where your kernels and copies happen.
RAII Wrappers
In modern C++ you often wrap a range in a small RAII object. It pops automatically when the scope ends, so you never forget.
Quick Check
You want named, labeled regions to appear on your Nsight timeline.
Recap
NVTX turns mystery bars into named ranges and markers. A few push and pop calls make your Nsight timelines instantly readable. 👏
Häufig gestellte Fragen
Ist die Lektion „Code mit NVTX annotieren“ kostenlos?
Ja — der vollständige Text von „Code mit NVTX annotieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des CUDA Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der CUDA Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Code mit NVTX annotieren“?
Benennen Sie Bereiche für übersichtliche Timelines. Du übst CUDA Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um CUDA Academy zu starten?
Keine Vorkenntnisse erforderlich. CUDA Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Code mit NVTX annotieren“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser CUDA Academy-Lektion Code schreiben und ausführen?
Ja. Jede CUDA Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Timeline-Ansicht in Nsight Systems
- Kernel-Metriken in Nsight Compute
- Compute-bound vs. Memory-bound
- Code mit NVTX annotieren