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.

Install

Hot:20

Download and extract to your skills directory

Copy command and send to AI Agent for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-skills-optimize-for-gpu&locale=en&source=copy

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


  • Accelerating Data Processing: When you need to process large-scale datasets—using pandas and NumPy for data cleaning, transformation, and analysis—you can perform the same operations on the GPU using cuDF and CuPy to achieve substantial performance gains.
  • Machine Learning Optimization: When training and running machine learning models, use cuML instead of scikit-learn to execute algorithms such as classification, regression, and clustering on the GPU—especially well-suited for hyperparameter tuning and large-scale feature engineering.
  • Scientific Computing and Simulation: For compute-intensive tasks such as physics simulations, particle systems, fluid dynamics, and grid computing, use Numba CUDA or Warp to write custom GPU kernels to speed up Python simulation loops by hundreds of times.
  • Core Features


  • Multi-Library GPU Acceleration Support: Provides full support for 11 NVIDIA acceleration libraries, including CuPy (NumPy alternative), cuDF (pandas alternative), cuML (scikit-learn alternative), Numba CUDA (custom kernels), Warp (physics simulation), cuGraph (graph computing), cuVS (vector search), cuCIM (image processing), cuSpatial (geospatial), KvikIO (GPU file I/O), and RAFT (low-level GPU primitives).
  • Zero-Code Change Acceleration Mode: Achieve GPU acceleration for pandas, scikit-learn, and NetworkX without modifying existing code by using cudf.pandas, cuml.accel, and the nx-cugraph backend—reducing the migration barrier.
  • End-to-End Optimization Workflow: From performance profiling, GPU suitability assessment, and code conversion to memory management optimization, it offers end-to-end guidance for GPU acceleration workflows, including custom kernel development, combining multiple libraries, and best practices for performance tuning.
  • 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).