optimize-for-gpu

Accelerate Python workloads on NVIDIA GPUs using CuPy, Numba, Warp, and RAPIDS libraries.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill optimize-for-gpu-tamagusko
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: optimize-for-gpu
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/optimize-for-gpu
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill optimize-for-gpu-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

šŸ’” This Skill includes references (resource) components.

What problem does it solve? CPU-bound Python code for numerical computing, dataframes, machine learning, graph analytics, image processing, and simulation runs orders of magnitude slower than it could on an NVIDIA GPU, and choosing the right GPU library for each workload is difficult. ## Core Features & Use Cases - Library Decision Framework: Maps workloads to the right tool — CuPy for NumPy arrays, cuDF for pandas, cuML for scikit-learn, cuGraph for NetworkX, cuCIM for scikit-image, cuVS for vector search, cuSpatial for GeoPandas, Warp for physics simulation, Numba for custom CUDA kernels, KvikIO for GPUDirect Storage IO, cuxfilter for dashboards, and RAFT for low-level primitives. - Code Transformation Patterns: Provides before/after examples for converting NumPy, pandas, scikit-learn, NetworkX, scikit-image, and GeoPandas code to GPU equivalents, including zero-code-change accelerator modes like cudf.pandas, cuml.accel, and nx-cugraph. - Optimization Workflow: Guides profiling, GPU suitability assessment, memory management, and common pitfalls such as host-device transfer overhead and implicit CPU fallback. - Use Case: A data scientist with a slow pandas ETL pipeline and a scikit-learn training loop can convert both to cuDF and cuML, achieving 10-100x speedups with minimal code changes. ## Quick Start Ask the assistant to convert your NumPy or pandas script to run on the GPU and it will select the right library and rewrite the code.

Frequently Asked Questions about optimize-for-gpu

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

FAQPage Schema
How do I speed up NumPy code on a GPU?ā–¼

Replace NumPy with CuPy, a drop-in GPU replacement wrapping cuBLAS, cuFFT, and cuSOLVER. Most code works by changing 'import numpy as np' to 'import cupy as cp', often yielding 10-100x speedups on large arrays.

How do I accelerate pandas code without rewriting it?ā–¼

Use cudf.pandas accelerator mode by running 'python -m cudf.pandas your_script.py' or loading the extension before importing pandas. It executes supported operations on GPU and falls back to CPU automatically, passing 93% of pandas unit tests.

Numba vs Warp for custom GPU kernels — which should I use?ā–¼

Use Warp for physics simulation, mesh operations, and differentiable programming since it provides spatial types like vec3 and quat plus automatic differentiation. Use Numba when you need raw CUDA control over shared memory, thread blocks, and atomics.

Can I run scikit-learn code on a GPU without changes?ā–¼

Yes, cuML's accelerator mode runs existing sklearn code on GPU via 'python -m cuml.accel your_script.py'. Speedups range from 2-10x for linear models to 60-600x for algorithms like HDBSCAN and KNN.

When is GPU acceleration not worth it for Python code?ā–¼

GPUs underperform on datasets below roughly 10K elements, inherently sequential algorithms with data dependencies, and I/O-bound workloads. Kernel launch overhead of 5-20 microseconds also dominates when running many small operations.

How do I load large files directly into GPU memory?ā–¼

Use KvikIO, which binds to NVIDIA cuFile for GPUDirect Storage, streaming data from NVMe or S3 directly into GPU memory and bypassing CPU staging. It falls back to POSIX IO transparently when GDS is unavailable.