Run the examples on your desktop
Export current CUDA source or prepare PyTorch for an optional GPU trace.
Choose the execution environment
The course’s browser editor compiles and executes CUDA C++ with a functional GPU simulator. No installation is needed for those activities. Native CUDA execution requires an NVIDIA GPU, its driver and a compatible CUDA toolkit.
Keep functional correctness and physical GPU measurements separate. Browser simulation checks program behaviour; it does not measure your GPU’s speed.
Run a current CUDA example
Install the toolkit using NVIDIA’s CUDA installation guide (new tab) for your operating system. In any course editor, open Editor tools and choose Export .cu to download your current source.
For a small complete starting program, download first-kernel.cu. In its download directory, compile and run:
Terminal · shell commands
nvcc -O2 first-kernel.cu -o first-kernel
./first-kernelThe unchanged example prints 42.0. The project validates examples in functional simulation; physical GPU execution of this example has not been validated here. Native compiler or driver errors are different from the program’s printed result.
Change the written value
In the downloaded hello kernel, change output[0] = 42.0f to output[0] = 7.0f. Compile again, run the new executable and check for 7.0 in the output. Keep the supplied allocation, CUDA error handling and result copy unchanged.
Return to the first CUDA lesson. Later complete examples are in the current lesson editors and the repository’s examples/v2-programs and examples/v2-practical directories.
Prepare PyTorch for an optional GPU trace
To capture actual framework-selected GPU launches, use the PyTorch installation selector (new tab) for your operating system and CUDA configuration. Then run:
Terminal · shell commands
python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())"The first line identifies the installed PyTorch version. The second must be True before using the profiling appendix’s CUDA capture. A CPU-only installation can check values but cannot capture GPU launches.
Continue to Inspect PyTorch GPU launches for the complete capture program, trace reader and interpretation limits. Native tools and their installations are separate from the course’s offline download.