Compiling CUDA Files
Learn how to use the Compiler Explorer to compile your CUDA code and generate assembly output.Basic Workflow
1
Select a File
Click the file selector in the Compiler Explorer header to choose a
.cu file from your workspace.2
Configure Settings
The compiler auto-detects your nvcc version and GPU architecture. You can override these if needed.
3
Compile
Click Compile to generate PTX and SASS output. Results appear in the tabbed view below.
File Selection
From the File Picker
Click the folder icon or File button to open a file dialog. Navigate to and select your.cu file.
From an Open Editor
If you have a.cu file open in VS Code, the Compiler Explorer can detect and use it automatically.
Configuration Options
Compiler Version
The nvcc version is auto-detected from your local installation. The detected version shows with “(detected)” suffix. You can manually select a different version if needed—for example, if you want to see how code compiles with a different CUDA version.| Version | Notes |
|---|---|
| Auto-detected | Uses your local nvcc installation |
| Manual selection | Choose from available CUDA versions |
GPU Architecture
The target architecture is auto-detected from your local GPU. The detected architecture shows with “(detected)” suffix. Common architectures:| Architecture | GPU Examples |
|---|---|
sm_100 | NVIDIA B200 |
sm_90 | NVIDIA H100, H200 |
sm_89 | NVIDIA L40S |
sm_80 | NVIDIA A100 |
sm_75 | NVIDIA T4 |
The architecture affects SASS output. PTX is architecture-independent, but SASS is specific to each GPU generation.
Live Compilation
When a file is selected, live compilation is automatically enabled. This means:- The file is recompiled whenever you save it
- Results update automatically without clicking Compile
- You can iterate quickly on optimizations
Compilation Process
When you compile, Wafer:- Runs nvcc with your file and settings
- Generates PTX from the CUDA source
- Generates SASS using nvdisasm (if available)
- Displays results in the tabbed interface
What Happens Behind the Scenes
Handling Errors
Compilation Errors
If your code has errors, they appear in the Compilation Output panel at the bottom:- Syntax errors
- Type mismatches
- Missing headers
- Undefined symbols
NVCC Not Found
If nvcc isn’t installed or not in your PATH:nvcc is in your PATH.
- Ubuntu/Debian
- Download from NVIDIA
Tips for Better Compilation
Use standalone kernel files
Use standalone kernel files
For best results, compile files that contain complete kernels. Files with only device functions may not produce meaningful output.
Include necessary headers
Include necessary headers
Make sure your
.cu file includes all required headers. The compiler runs with your file in isolation.Match architecture to your target
Match architecture to your target
Compile for your target deployment GPU, not just your development machine. This ensures you see the actual instructions that will run.
View Modes
After compilation, you can view results in different modes:Single Panel Mode
View one output type at a time using the tabs:- Source — Your original CUDA code
- PTX — Generated PTX assembly
- SASS — Generated SASS machine code
Side-by-Side Mode
Click the side-by-side button to view two panels at once. Compare:- Source vs. PTX
- Source vs. SASS
- PTX vs. SASS
Understanding Output
Learn how to read and interpret PTX and SASS →