# cuda4cpu [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/javier-cabezas/cuda4cpu  
**GitHub Stars:** 8  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/cuda4cpu

## Description
Run CUDA and HIP programs on CPUs, unmodified, with GCC or Clang. No GPU or CUDA toolkit needed. Debug kernels with gdb, AddressSanitizer and Valgrind, and let AI agents compile, run and check them through an MCP server.

## Claude Desktop Quick Installation
No confirmed install details yet, so no config is published. Follow the setup steps in the repository above.

## Documentation

## What cuda4cpu does

cuda4cpu runs CUDA and HIP source on ordinary CPUs rather than requiring a GPU, `nvcc`, or the CUDA toolkit. Its MCP component, `cuda4cpu-mcp`, exposes that workflow to coding agents. Agents can submit source files or programs built with cuda4cpu, then receive compilation diagnostics, execution results, and automated kernel checks.

The underlying runtime supports CUDA-style execution concepts including shared memory, atomics, streams, events, CUDA graphs with stream capture, warp operations, cooperative groups, several low-precision numeric types, and HIP compilation. The project reports that 184 of 209 programs drawn from NVIDIA, Rodinia, and AMD example collections build and pass unchanged.

## How it works

The server communicates over MCP using stdio. The agent starts `cuda4cpu-mcp` as a local subprocess, or starts the equivalent container command with the project directory mounted. The server invokes cuda4cpu’s compiler and runtime against the supplied code, so kernels execute as native code across CPU cores.

Three MCP tools cover the main workflow:

- `compile` builds CUDA or HIP code and returns compiler diagnostics at source locations, along with notices about cuda4cpu features used by the program but not implemented.
- `run` executes a compiled program and returns its exit status, output, and cuda4cpu warnings.
- `check` performs the project’s diagnostic checks and returns a verdict with findings tied to source lines.

Checks use sanitizers, altered memory initialization, and multiple thread execution orders. They can expose memory errors, undefined behavior, missing synchronization, and barrier-related problems that may be difficult to reproduce on a GPU. The standalone `cuda4cpu-check` command can also inspect source files or existing programs and returns exit code 1 when it finds a problem.

## Setup and configuration

The supported quick-start environment is Linux or WSL 2 on x86-64 with GCC 14 or newer and Python 3. The latest Linux x86-64 release can be unpacked into `~/.local`. A Docker image is also available with cuda4cpu, GCC, and CMake included. Building from source requires CMake 3.25 or newer and Ninja.

After installation, register the local server with an MCP client using a command such as:

```sh
claude mcp add cuda4cpu -- cuda4cpu-mcp
```

A container deployment can mount the working directory and run the server interactively:

```sh
docker run -i --rm -v "$PWD:$PWD" ghcr.io/javier-cabezas/cuda4cpu
```

The container can access only directories explicitly mounted into it. The server is registered in the MCP Registry as `io.github.javier-cabezas/cuda4cpu`.

## Tools and capabilities

The compiler wrappers accept regular C++ compiler options through `cuda4cpu-c++`, while `cuda4cpu-nvcc` accepts nvcc-style options. Debugging can use gdb, AddressSanitizer, UBSan, and Valgrind. CUDA threads are represented as fibers, allowing breakpoints, stepping, and backtraces inside individual kernel threads. Diagnostics identify CUDA thread and block coordinates when a kernel crashes or a sanitizer reports an error.

Execution scheduling can be changed to help reveal synchronization bugs. `CUDA4CPU_SCHEDULE=reverse` runs block threads in reverse order, while `CUDA4CPU_SCHEDULE=random` uses a randomized order; a seed can be supplied to reproduce a randomized run. The runtime also detects blocks whose threads reach different `__syncthreads()` calls.

## Limitations and notes

The documented quick-start target is x86-64 Linux or WSL 2, rather than a native GPU runtime. CPU execution is intended for testing and debugging CUDA or HIP behavior; it does not provide GPU performance characteristics. Code using features that cuda4cpu has not implemented can be identified by the compile tool, and the project’s compatibility results show that some programs do not pass unchanged.

_Full upstream README: https://allmcps.com/mcp/cuda4cpu/readme_

