Skip to content

mdaiter/cuda_ioctl_sniffer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo works to launch CUDA kernels without relying on the CUDA runtime.

## Repository layout

- `src/` – Rust crate that drives the reverse-engineered submission path.
- `cuda_kernels/` – cache of compiled kernels the CLI can load quickly.
- `open-gpu-kernel-modules/` – NVIDIA’s open kernel headers (required for bindgen
  and for compiling new cubins/PTX).
- `orig_cpp/` – the historical C++/CUDA prototype plus helper scripts. Nothing in
  this folder is built by default, but it’s useful reference material and still
  provides optional utilities such as `libsniff`.

## First-time setup

1. Clone NVIDIA’s header repository beside the crate (if you haven’t already):

   ```bash
   git clone https://github.com/NVIDIA/open-gpu-kernel-modules.git
   ```

2. (Optional but recommended) Rebuild the legacy “simple” cubin that the Rust
   loader can fall back to when `TRIVIAL` is unset:

   ```bash
   (cd orig_cpp && ./cudaless.sh)
   # creates orig_cpp/out/simple.o
   ```

   If you prefer to rely exclusively on the built-in trivial program, export
   `TRIVIAL=1` before running any of the binaries and you can skip this step.

3. (Optional) Build the C helper library used by the original sniffing code:

   ```bash
   (cd orig_cpp && ./make_sniff.sh)
   # produces orig_cpp/out/libsniff.so
   ```

## Building and running the Rust tools

- Minimal end-to-end launch (uses built-in “TRIVIAL” kernel automatically):

  ```bash
  cargo run --bin minimal_demo
  ```

- Rich TUI CLI (`gpu_cli`) with optional C shim:

  ```bash
  # Rebuild libsniff if you skipped it earlier: (cd orig_cpp && ./make_sniff.sh)
  cargo run --features with-sniff-c --bin gpu_cli
  # Set LD_LIBRARY_PATH if you enabled the shim:
  LD_LIBRARY_PATH=orig_cpp/out cargo run --features with-sniff-c --bin gpu_cli
  ```

- Compiling new CUDA sources through the CLI:

  ```text
  kernel compile path/to/file.cu arch=sm_86
  kernel demo <name>
  ```

  The command injects include paths for `open-gpu-kernel-modules`, writes the
  resulting PTX/CUBIN into `cuda_kernels/`, and updates the registry so you can
  `kernel use <name>` later.

## Legacy prototype

All of the original C++ sources are under `orig_cpp/`. The noteworthy entry
points are:

- `orig_cpp/gpu_driver.cc` – hand-crafted command submission.
- `orig_cpp/tc_context.cc` – minimal `cuInit` / `cuCtxCreate` replacement.

They continue to build exactly as they did historically once
`open-gpu-kernel-modules/` is present at the repo root.

About

Sniff CUDA ioctls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 47.7%
  • C 27.2%
  • C++ 20.1%
  • Cuda 3.0%
  • Other 2.0%