optimize-for-gpu
GPU-accelerate Python code using CuPy, Numba CUDA, Warp, cuDF, cuML, cuGraph, KvikIO, cuCIM, cuxfilter, cuVS, cuSpatial, and RAFT. Use whenever the user mentions GPU/CUDA/NVIDIA acceleration, or wants to speed up NumPy, pandas, scikit-learn, scikit-image, NetworkX, GeoPandas, or Faiss workloads. Covers physics simulation, differentiable rendering, mesh ray casting, particle systems (DEM/SPH/fluids), vector/similarity search, GPUDirect Storage file IO, interactive dashboards, geospatial analysis, medical imaging, and sparse eigensolvers. Also use when you see CPU-bound Python code (loops, large arrays, ML pipelines, graph analytics, image processing) that would benefit from GPU acceleration, even if not explicitly requested.
Author
Category
Development ToolsInstall
Download and extract to your skills directory
Copy command and send to AI Agent for auto-install:
Python GPU Acceleration — optimize-for-gpu Skills Deep Dive
Skill Overview
optimize-for-gpu is a professional Python GPU acceleration skill that helps developers speed up CPU-intensive Python code by 10x to 1000x using NVIDIA GPUs, including GPU alternatives for commonly used libraries such as NumPy, pandas, and scikit-learn.
Ideal Use Cases
Core Features
Frequently Asked Questions
How can I make Python code run on the GPU?
You can choose a zero-code modification approach (e.g.,
python -m cudf.pandas your_script.py) or use a GPU-accelerated library directly. The simplest method is to replace imports: change import numpy as np to import cupy as cp, and change import pandas as pd to import cudf. For existing code, cudf.pandas and cuml.accel provide automatic acceleration modes, allowing you to get GPU performance benefits without modifying your code.What hardware and software are needed for GPU acceleration?
You need an NVIDIA GPU that supports CUDA (GTX 1060 or higher is recommended), install CUDA 12.x or 13.x drivers, and use a Python 3.11+ environment. Install RAPIDS libraries via
uv add (e.g., uv add cudf-cu12). For CuPy, you must match the CUDA version (e.g., uv add cupy-cuda12x). After installation, you can check GPU availability with import cupy as cp; print(cp.cuda.runtime.getDeviceCount()).How do I know if my code is suitable for GPU acceleration?
GPU acceleration works best for scenarios with high data parallelism, compute-intensive workloads, and large data volumes (typically >10,000 elements). Common compatible cases include NumPy array operations, pandas groupby/aggregation, scikit-learn training, NetworkX graph algorithms, image processing filters, and physics simulation loops. Not suitable cases include small arrays (<10K elements), algorithms with sequential dependencies, and I/O-intensive operations (unless using KvikIO GPUDirect Storage).