Requirements
Hardware
- NVIDIA GPU with Compute Capability 6.0 or higher
- Recommended: RTX 20 series or newer for optimal performance
- Minimum: 4GB GPU memory (varies by model size)
Software
- CUDA Toolkit 11.8 or 12.x
- cuDNN 8.x or later
- NVIDIA driver 520.61.05 or newer (Linux) / 528.33 or newer (Windows)
The CUDA provider is included in the
onnxruntime-genai-cuda package.Installation
- Python
- C++
- C#
Basic Configuration
Python API
genai_config.json
Configure CUDA in your model configuration:GPU Memory Management
Memory Allocation
The CUDA provider uses ONNX Runtime’s allocator for GPU memory:GPU Memory Limit: Set
gpu_mem_limit to restrict CUDA memory usage (in bytes). This is useful for multi-tenant scenarios.KV Cache Management
ONNX Runtime GenAI optimizes key-value cache management:Performance Tuning
CUDA Graph Optimization
Enable CUDA graphs to reduce kernel launch overhead:CUDA graphs are only compatible with greedy search (
num_beams=1). Disable for beam search scenarios.Multi-Profile Support
Optimize for multiple sequence lengths:Stream Configuration
The CUDA provider uses a dedicated stream for async operations. Memory transfers are optimized using pinned host memory:Precision Options
FP16 Inference
The CUDA provider supports FP16 for reduced memory and faster inference:- FP32
- FP16
- Memory: Higher usage
- Speed: Baseline performance
- Precision: Full precision
- Hardware: All CUDA GPUs
Advanced Configuration
Device Selection
Select a specific GPU in multi-GPU systems:Session Options
Fine-tune ONNX Runtime session settings:Troubleshooting
Out of Memory Errors
Performance Issues
Enable CUDA Graph
Enable CUDA Graph
Use FP16 Models
Use FP16 Models
Switch to FP16 model variants for Tensor Core acceleration.
Optimize KV Cache
Optimize KV Cache
Driver Compatibility
Verify CUDA installation:Benchmarking
Next Steps
Model Optimization
Optimize models for CUDA deployment
Memory Management
Learn advanced memory techniques