Cloud GPU Compiler (Unofficial)
Compiles and runs the currently open .cu file — or, if it's part of a
multi-file project with a CMakeLists.txt, the whole project — on a real
cloud GPU via the public Compiler Explorer API (hosted at godbolt.org), and
shows the output directly in VS Code (Output panel). No local CUDA
toolchain, no local GPU, no npm dependencies.
Not affiliated with, endorsed by, or officially connected to the
Compiler Explorer project — this is an independent client that simply
calls their public, documented API.
Built for educational use in a university GPU programming course, as a way
for students without an NVIDIA GPU on their own machine to still compile
and run CUDA code for coursework. Useful for any CUDA course in the same
situation.
The service this relies on
All the actual compiling and GPU execution happens on
Compiler Explorer
(godbolt.org), an open-source project run independently of this extension
and its author. It's free to use and kept running by its own maintainers
and community — donations via
Patreon or
GitHub Sponsors, and
corporate sponsorships. I have no affiliation with Compiler Explorer or
its maintainers — this extension is just a thin client for their public
API. If you find it useful, consider supporting them directly at the
links above.
Usage
Single file
- Open a
.cu file (e.g. tp/tp1/hello.cu).
- Press
Cmd+Option+R (macOS — VS Code calls the Option key "Alt" in its
keybindings, so it may also show as Cmd+Alt+R) or Ctrl+Alt+R
(Windows/Linux), or run Cmd+Shift+P → "CUDA: Run Active File on
Cloud GPU".
- Type program arguments if the program needs them (e.g.
1024), or
leave the box empty and press Enter.
- Output shows up in View → Output → "Cloud GPU Compiler" (VS Code
usually switches to it automatically): compiler warnings/errors first,
then the program's stdout/stderr and exit code.
Multi-file project
If your .cu file lives in a folder that also has a CMakeLists.txt
(e.g. add_executable(main main.cu helper.cu)), the same command and
keybinding above automatically build and link the whole project instead
of just the open file — headers and other .cu/.cpp files in that
folder are picked up on their own. If the CMakeLists.txt defines more
than one add_executable, you'll be asked which one to run.
You can also trigger this explicitly via Cmd+Shift+P →
"CUDA: Run Project (CMakeLists.txt) on Cloud GPU", or by opening the
CMakeLists.txt file itself and running the usual command/keybinding on
it.
Why this exists
Apple removed NVIDIA driver support from macOS years ago, so nvcc can
never run on a Mac directly — no local toolchain install fixes that. This
extension routes around it by compiling and executing your code on a real
GPU in the cloud, without leaving the editor.
Configuration
In VS Code settings (Cmd+,), search "cudaGodbolt":
cudaGodbolt.compilerId — which NVCC version on Compiler Explorer to
use (default nvcc129u1), used for both single-file and project runs.
Change if you need a specific CUDA version.
cudaGodbolt.extraCompilerArgs — extra flags passed to nvcc on every
single-file run (default -std=c++17). Not used for project runs — set
compiler flags in CMakeLists.txt instead (e.g. via
target_compile_options).
Limitations
- Requires internet access (compilation happens on godbolt.org's servers,
not locally).
- No external libraries beyond what's already available on Compiler
Explorer (no
find_package/FetchContent pulling from the internet —
the build machines have no internet access).
- Project mode only builds a single
CMakeLists.txt at the root of the
folder (no add_subdirectory, no nested CMake projects).
- For graded lab assignments, remember your course's AI policy if it has
one: this extension only changes how you run code you already wrote
yourself, the same role
nvcc/cmake play on a machine that has a
GPU — it does not write any code for you.
Maintaining or packaging this extension yourself? See DEVELOPMENT.md.