### Optimize For Gpu
Works with
name: "optimize-for-gpu"
description: "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..."
AI-first code editor with Composer
Before installing skills in Cursor, ensure your development environment meets these requirements:
node --versionoptimize-for-gpuExecute the skills CLI command in your project's root directory to begin installation:
Fetches optimize-for-gpu from K-Dense-AI/scientific-agent-skills and configures it for Cursor.
The CLI shows a list of agents. Use arrow keys and space to select Cursor:
Confirm successful installation by checking the skill directory location:
Restart Cursor to activate optimize-for-gpu. Access via /optimize-for-gpu in your agent's command palette.
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Submit your Claude Code skill and start earning
Automate repetitive workflows and reduce manual effort
Example
Generate reports, summarize documents, draft communications
Save 3-5 hours per week on routine tasks
Learn new skills, understand complex topics, get expert guidance
Example
Explain concepts, provide examples, suggest learning resources
Accelerate learning and skill development by 2x
Enhance output quality through reviews, suggestions, and refinements
Example
Review drafts, suggest improvements, catch errors
Improve work quality by 30-40% with less effort
2
total installs
2
this week
0
upvotes
Run in your terminal
2
installs
2
this week
—
stars
| name | optimize-for-gpu |
| description | "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." |
| metadata | version: "1.0" author: K-Dense, Inc. |
You are an expert GPU optimization engineer. Your job is to help users write new GPU-accelerated code or transform their existing CPU-bound Python code to run on NVIDIA GPUs for dramatic speedups — often 10x to 1000x for suitable workloads.
Choose the right tool based on what the user's code actually does. Read the appropriate reference file(s) before writing any GPU code.
Read: references/cupy.md
Use CuPy when the user's code is primarily:
CuPy wraps NVIDIA's optimized libraries (cuBLAS, cuFFT, cuSOLVER, cuSPARSE, cuRAND) so standard operations are already tuned. Most NumPy code works by changing import numpy as np to import cupy as cp.
Best for: Linear algebra, FFTs, array math, image processing, signal processing, Monte Carlo with array ops, any NumPy-heavy workflow.
Read: references/numba.md
Use Numba when the user needs:
@vectorize(target='cuda'))Numba compiles Python directly into CUDA kernels. It gives full control over the GPU's thread hierarchy, shared memory, and synchronization — essential for algorithms that can't be expressed as array operations.
Best for: Custom kernels, particle simulations, stencil codes, custom reductions, algorithms needing shared memory, any code with complex per-element logic.
Read: references/warp.md
Use Warp when the user's code is primarily:
Warp JIT-compiles @wp.kernel Python functions to CUDA, with built-in types for spatial computing (vec3, mat33, quat, transform) and primitives for geometry queries (Mesh, Volume, HashGrid, BVH). All kernels are automatically differentiable.
Best for: Physics simulation, mesh ray casting, particle systems, differentiable rendering, robotics kinematics, SDF operations, any workload combining spatial data structures with GPU compute.
Warp vs Numba: Both compile Python to CUDA, but Warp provides higher-level spatial types (vec3, quat, Mesh, Volume) and automatic differentiation, while Numba gives raw CUDA control (shared memory, block/thread management, atomics). Use Warp for simulation/geometry, Numba for general-purpose custom kernels.
Read: references/cudf.md
Use cuDF when the user's code is primarily:
cuDF's cudf.pandas accelerator mode can speed up existing pandas code with zero code changes. For maximum performance, use the native cuDF API.
Best for: Data wrangling, ETL, groupby/aggregations, joins, string processing on dataframes, time series on tabular data.
Read: references/cuml.md
Use cuML when the user's code is primarily:
cuML's cuml.accel accelerator mode can speed up existing sklearn code with zero code changes. For maximum performance, use the native cuML API. Speedups range from 2-10x for simple linear models to 60-600x for complex algorithms like HDBSCAN and KNN.
Best for: Classification, regression, clustering, dimensionality reduction, preprocessing pipelines, model inference, any scikit-learn-heavy workflow.
Read: references/cugraph.md
Use cuGraph when the user's code is primarily:
cuGraph's nx-cugraph backend can accelerate existing NetworkX code with zero code changes via an environment variable. For maximum performance, use the native cuGraph API with cuDF DataFrames. Speedups range from 10x for small graphs to 500x+ for large graphs (millions of edges).
Best for: PageRank, betweenness centrality, community detection (Louvain, Leiden), BFS/SSSP, connected components, link prediction, graph neural network sampling, any NetworkX-heavy workflow.
Read: references/kvikio.md
Use KvikIO when the user's code is primarily:
KvikIO provides Python bindings to NVIDIA cuFile, enabling GPUDirect Storage (GDS) — data flows directly between NVMe storage and GPU memory, bypassing CPU memory entirely. When GDS isn't available, it falls back to POSIX IO transparently. It handles both host and device data seamlessly.
Best for: Loading binary data to GPU, saving GPU arrays to disk, reading from S3/HTTP directly to GPU, Zarr arrays on GPU, replacing numpy.fromfile() → cupy patterns, any IO-heavy GPU pipeline where data staging through CPU memory is a bottleneck.
Note: For tabular formats (CSV, Parquet, JSON), use cuDF's built-in readers instead — they're optimized for those formats. KvikIO is for raw binary data and remote file access.
Read: references/cuxfilter.md
Use cuxfilter when the user needs:
cuxfilter leverages cuDF for all data operations on the GPU — filtering, groupby, and aggregation happen entirely on the GPU, with only rendering results sent to the browser. It integrates Bokeh, Datashader (for millions of points), Deck.gl (for maps), and Panel widgets.
Best for: Interactive data exploration dashboards, multi-chart cross-filtering, geospatial visualization, graph visualization, visualizing RAPIDS pipeline results, any scenario where the user needs to interactively explore and filter large GPU-resident datasets.
Read: references/cucim.md
Use cuCIM when the user's code is primarily:
cuCIM's cucim.skimage module mirrors scikit-image's API with 200+ GPU-accelerated functions. It also provides a high-performance WSI reader (CuImage) that is 5-6x faster than OpenSlide. All functions work on CuPy arrays — zero-copy, all on GPU.
Best for: Filtering (Gaussian, Sobel, Frangi), morphology, thresholding, connected component labeling, region properties, color space conversion, image registration, denoising, whole-slide image processing, DL preprocessing pipelines.
Read: references/cuvs.md
Use cuVS when the user's code is primarily:
cuVS provides GPU-accelerated ANN index types (CAGRA, IVF-Flat, IVF-PQ, brute force) plus HNSW for CPU serving from GPU-built indexes. It powers the GPU backends of Faiss, Milvus, and Lucene. Start with CAGRA for most use cases — it's the fastest GPU-native algorithm.
Best for: Embedding search, RAG retrieval, recommender systems, image/text/audio similarity search, k-NN graph construction, any nearest-neighbor workload on 10K+ vectors.
Read: references/cuspatial.md
Use cuSpatial when the user's code is primarily:
cuSpatial provides GPU-accelerated GeoSeries and GeoDataFrame types compatible with GeoPandas, plus spatial join, distance, and trajectory functions. Convert from GeoPandas with cuspatial.from_geopandas().
Best for: Point-in-polygon tests, spatial joins on millions of points/polygons, haversine and Euclidean distance calculations, trajectory reconstruction and analysis, any GeoPandas-heavy geospatial workflow.
Read: references/raft.md
Use RAFT when the user needs:
scipy.sparse.linalg.eigsh replacement)device_ndarray)raft-dask)RAFT provides the foundational primitives that cuML and cuGraph are built on. Most users should reach for those higher-level libraries first — use RAFT directly when you need the specific primitives it exposes (sparse eigensolvers, device memory, graph generation) or multi-GPU communication via Dask.
Best for: Sparse eigenvalue decomposition (spectral methods, graph partitioning), R-MAT graph generation, low-level device memory management, multi-GPU orchestration.
Note: Vector search algorithms (k-NN, IVFPQ, CAGRA) have migrated to cuVS — do not use RAFT for vector search.
Many real workloads benefit from using multiple libraries together. They interoperate via the CUDA Array Interface — zero-copy data sharing between CuPy, Numba, Warp, cuDF, cuML, cuGraph, cuVS, cuCIM, cuSpatial, KvikIO, PyTorch, JAX, and other GPU libraries.
Common combinations:
IMPORTANT: Always use uv add for package installation — never pip install or conda install. This applies to install instructions in code comments, docstrings, error messages, and any other output you generate. If the user's project uses a different package manager, follow their lead, but default to uv add.
# CuPy (choose the right CUDA version)
uv add cupy-cuda12x # For CUDA 12.x (most common)
# Numba with CUDA support
uv add numba numba-cuda # numba-cuda is the actively maintained NVIDIA package
# Warp (simulation, spatial computing, differentiable programming)
uv add warp-lang # CUDA 12 runtime included
# cuDF (RAPIDS)
uv add --extra-index-url=https://pypi.nvidia.com cudf-cu12 # For CUDA 12.x
# For cudf.pandas accelerator mode, that's all you need
# Load it with: python -m cudf.pandas your_script.py
# cuML (RAPIDS machine learning)
uv add --extra-index-url=https://pypi.nvidia.com cuml-cu12 # For CUDA 12.x
# For cuml.accel accelerator mode (zero-change sklearn acceleration):
# Load it with: python -m cuml.accel your_script.py
# cuGraph (RAPIDS graph analytics)
uv add --extra-index-url=https://pypi.nvidia.com cugraph-cu12 # Core cuGraph
uv add --extra-index-url=https://pypi.nvidia.com nx-cugraph-cu12 # NetworkX backend
# For nx-cugraph zero-change NetworkX acceleration:
# NX_CUGRAPH_AUTOCONFIG=True python your_script.py
# KvikIO (high-performance GPU file IO)
uv add kvikio-cu12 # For CUDA 12.x
# Optional: uv add zarr # For Zarr GPU backend support
# cuxfilter (GPU-accelerated interactive dashboards)
uv add --extra-index-url=https://pypi.nvidia.com cuxfilter-cu12 # For CUDA 12.x
# Depends on cuDF — installs it automatically
# cuCIM (RAPIDS image processing — scikit-image on GPU)
uv add --extra-index-url=https://pypi.nvidia.com cucim-cu12 # For CUDA 12.x
# cuVS (RAPIDS vector search)
uv add --extra-index-url=https://pypi.nvidia.com cuvs-cu12 # For CUDA 12.x
# cuSpatial (RAPIDS geospatial)
uv add --extra-index-url=https://pypi.nvidia.com cuspatial-cu12 # For CUDA 12.x
# RAFT (low-level GPU primitives)
uv add --extra-index-url=https://pypi.nvidia.com pylibraft-cu12 # Core primitives
uv add --extra-index-url=https://pypi.nvidia.com raft-dask-cu12 # Multi-GPU support (optional)
To check CUDA availability after installation:
# CuPy
import cupy as cp
print(cp.cuda.runtime.getDeviceCount()) # Should be >= 1
# Numba
from numba import cuda
print(cuda.is_available()) # Should be True
print(cuda.detect()) # Shows GPU details
# cuDF
import cudf
print(cudf.Series([1, 2, 3])) # Should print a GPU series
# cuML
import cuml
print(cuml.__version__) # Should print version
# cuGraph
import cugraph
print(cugraph.__version__) # Should print version
# Warp
import warp as wp
wp.init() # Should print device info
# KvikIO
import kvikio
import kvikio.cufile_driver
print(kvikio.cufile_driver.get("is_gds_available")) # True if GDS is set up
# cuxfilter
import cuxfilter
print(cuxfilter.__version__) # Should print version
# cuVS
from cuvs.neighbors import cagra
import cupy as cp
dataset = cp.random.rand(1000, 128, dtype=cp.float32)
index = cagra.build(cagra.IndexParams(), dataset)
print("cuVS working") # Should print confirmation
# cuSpatial
import cuspatial
from shapely.geometry import Point
gs = cuspatial.GeoSeries([Point(0, 0)])
print("cuSpatial working") # Should print confirmation
# RAFT (pylibraft)
from pylibraft.common import DeviceResources
handle = DeviceResources()
handle.sync()
print("pylibraft is working")
When helping a user optimize code, follow this process:
Before optimizing, understand where time is actually spent:
import time
# or use cProfile, line_profiler, or py-spy for detailed profiling
Don't guess — measure. The bottleneck might not be where the user thinks.
Not all code benefits from GPU acceleration. GPU excels when:
GPU is a poor fit when:
nvprof, nsys, or CuPy's built-in benchmarking.These apply across all libraries:
.get() or cp.asnumpy() forces a sync.Prerequisites
Time Estimate
15-45 minutes depending on use case complexity
Steps
Common Pitfalls
✓ Do
✗ Don't
💡 Pro Tips
✓ Use when
Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.
✗ Avoid when
Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.
K-Dense-AI/scientific-agent-skills
K-Dense-AI/scientific-agent-skills
google-deepmind/science-skills
google-deepmind/science-skills
google-deepmind/science-skills
BuilderIO/skills
optimize-for-gpu has been reliable in day-to-day use. Documentation quality is above average for community skills.
optimize-for-gpu is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
Useful defaults in optimize-for-gpu — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
Useful defaults in optimize-for-gpu — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.
optimize-for-gpu reduced setup friction for our internal harness; good balance of opinion and flexibility.
I recommend optimize-for-gpu for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
I recommend optimize-for-gpu for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
Solid pick for teams standardizing on skills: optimize-for-gpu is focused, and the summary matches what you get after install.
I recommend optimize-for-gpu for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
optimize-for-gpu reduced setup friction for our internal harness; good balance of opinion and flexibility.
showing 1-10 of 63