Registry / ai-ml / cuda-wasm

cuda-wasm

JSON →
library1.1.1jsnpmunverified

cuda-wasm (v1.1.1) is a high-performance transpiler that converts CUDA C++ code to WebAssembly and WebGPU, enabling GPU-accelerated computing in browsers and Node.js without NVIDIA hardware. It uses a clean-room implementation based on public CUDA specifications, translating CUDA syntax to Rust/WebGPU patterns. Ships with TypeScript types, supports Node >=16.0.0. Key differentiators: no NVIDIA dependencies, near-native performance via WebGPU, ruv-FANN neural network integration. Released under MIT/Apache-2.0. Active development.

npm install cuda-wasm
INSTALL
IMPORT
SIG · CUDA-WASM
C
cuda-wasm
ai-mljavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cudaWasm
import { cudaWasm } from 'cuda-wasm'
const cudaWasm = require('cuda-wasm')
Package is ESM-only; CommonJS require not supported.
transpileCUDA
import { transpileCUDA } from 'cuda-wasm/transpile'
import { transpileCUDA } from 'cuda-wasm'
Subpath export: use '/transpile' for the transpiler function.
runKernel
import { runKernel } from 'cuda-wasm/runtime'
import { runKernel } from 'cuda-wasm'
Runtime execution is in '/runtime' subpath.
NeuralNetwork
import { NeuralNetwork } from 'cuda-wasm/neural'
import { NeuralNetwork } from 'cuda-wasm/neural-network'
Neural network module is at '/neural'.

Transpile a CUDA kernel and run it on WebGPU, demonstrating vector addition.

import { transpileCUDA } from 'cuda-wasm/transpile'; import { runKernel } from 'cuda-wasm/runtime'; const cudaCode = ` __global__ void vectorAdd(const float* A, const float* B, float* C, int N) { int i = threadIdx.x + blockIdx.x * blockDim.x; if (i < N) C[i] = A[i] + B[i]; } `; async function main() { const wasmModule = await transpileCUDA(cudaCode); const result = await runKernel(wasmModule, 'vectorAdd', { args: [new Float32Array([1,2,3]), new Float32Array([4,5,6]), new Float32Array(3), 3], grid: [1, 1, 1], block: [3, 1, 1] }); console.log(result); // Float32Array [5, 7, 9] } main();
cuda-wasm --version
Debug
Known issues
breakingCUDA runtime API and driver API are NOT supported. Only kernel execution is transpiled.
fix
Use transpileCUDA and runKernel for kernels; do not expect CUDA runtime functions.
affects: all
breakingNot all CUDA features are implemented. See compatibility table.
fix
Consult the documentation for supported features; avoid dynamic parallelism and PTX.
affects: all
gotchaWebGPU requires HTTPS or localhost. Using file:// or non-secure origins will fail.
fix
Serve your app over HTTPS or use localhost; do not open HTML directly from filesystem.
affects: all
deprecatedThe separate @cuda-wasm/web package is deprecated and merged into main package.
fix
Use cuda-wasm directly; no need for additional packages.
affects: <=1.0.0
Errors
Common errors & fixes
TypeError: WebGPU not supported in this browser
Browser lacks WebGPU support (e.g., Safari, older Chrome).
fix
Use a browser with WebGPU enabled (Chrome 113+, Edge 113+, Firefox Nightly).
Error: CUDA_RUNTIME_API_NOT_SUPPORTED
Using CUDA runtime API calls (e.g., cudaMalloc) in the transpiled code.
fix
Rewrite kernel to avoid runtime API; allocate memory outside and pass as args.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
cuda-wasm — npm install cuda-wasm · libregistry