cuda-python

Route Python GPU compute to CuPy or NumPy with CPU fallbacks.

15|2|Updated May 23, 2026
One-click install
npx skills add https://github.com/VKirill/antigravity-for-claude-code --skill cuda-python
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cuda-python
Source: https://github.com/VKirill/antigravity-for-claude-code/tree/main/skills/cuda-python
Command: npx skills add https://github.com/VKirill/antigravity-for-claude-code --skill cuda-python

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

GPU-accelerated Python code often breaks on machines without NVIDIA GPUs or with mismatched CUDA driver/toolkit/library versions, forcing developers to add brittle imports and scattered conditionals.

Core Features & Use Cases

  • Optional-dependency routing (core artifact): detects CUDA at runtime, exposes an xp namespace (CuPy if usable, NumPy otherwise), and guarantees CPU-safe imports so the same package works in CI and production.
  • CUDA-capable tooling map: helps you choose between CuPy, Numba @cuda.jit, PyCUDA (legacy), and cuda-python (official low-level bindings) based on task level and debugging needs.
  • High-stakes operational guidance: provides a symptom-indexed troubleshooting playbook for common CUDA failures like driver/toolkit mismatch and illegal memory access, plus memory-management and interop patterns.

Quick Start

Ask: "Plan and implement a CPU/GPU optional module using cuda-python optional dependency detection, then show how to write one function that uses xp on GPU when available and falls back to CPU when not."

Frequently Asked Questions about cuda-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make my Python CUDA code fall back to CPU when a GPU is not available?

To make Python CUDA code fall back to CPU, implement an optional-dependency pattern that detects the GPU at runtime and routes array workloads to NumPy if CuPy is unavailable, ensuring imports remain CPU-safe in CI and production.

What is the best way to choose between CuPy, Numba, and cuda-python for GPU workloads?

Choosing between CuPy, Numba, and cuda-python depends on task level: use CuPy for array workloads, Numba @cuda.jit for custom kernel development, and cuda-python for driver-level diagnostics and low-level bindings across multi-GPU environments.

How do I write a Python function that uses a GPU when available and otherwise runs on CPU?

Write a GPU-optional Python function by exposing an xp namespace that maps to CuPy on GPU and NumPy on CPU, allowing the same code path to execute on either architecture based on runtime hardware detection.

Why does my Python GPU code fail in CI due to CUDA driver and toolkit mismatches?

Python GPU code fails in CI from CUDA driver and toolkit mismatches because runtime environments lack compatible NVIDIA hardware or libraries, requiring guardrails to detect versions and enforce safe CPU fallbacks.

Can I run CUDA-accelerated Python packages in Docker containers without NVIDIA GPUs?

You can run CUDA-accelerated Python packages in Docker containers without NVIDIA GPUs by enforcing an optional-dependency pattern with runtime GPU detection that gracefully degrades to CPU-safe NumPy operations.