Skip to main content
OpenGround can leverage NVIDIA GPUs to significantly speed up embedding generation. This guide covers GPU detection, setup, and optimization.

Quick Start

If you have an NVIDIA GPU:
OpenGround will automatically detect your GPU and provide recommendations if the setup is incomplete.

GPU Detection

OpenGround performs automatic GPU hardware detection using two methods (embeddings.py:28-41):
This function:
  1. First attempts to run nvidia-smi (NVIDIA System Management Interface)
  2. On Linux, falls back to checking for /dev/nvidia0 device file
  3. Returns True only if GPU hardware is detected

Compatibility Checking

OpenGround performs comprehensive compatibility checking on startup (embeddings.py:44-91):
This checks three critical conditions:
  1. GPU Hardware: Is an NVIDIA GPU physically present?
  2. GPU Package: Is fastembed-gpu installed?
  3. Functional GPU: Is CUDA properly configured in onnxruntime?

Compatibility Scenarios

Scenario 1: GPU Detected, No GPU Package

You have GPU hardware but are using the CPU version. Install the GPU package for better performance.

Scenario 2: GPU Package, No GPU Hardware

You installed the GPU version but don’t have GPU hardware. Switch to CPU version to avoid unnecessary dependencies.

Scenario 3: GPU Package + Hardware, But CUDA Non-Functional

This is the most complex scenario - GPU hardware and package are present, but CUDA isn’t properly configured.

Fastembed GPU Implementation

Fastembed uses ONNX Runtime’s CUDA execution provider (embeddings.py:93-116):
Key points:
  • Uses CUDAExecutionProvider for GPU acceleration
  • Automatically falls back to CPU if GPU initialization fails
  • Calls check_gpu_compatibility() on failure to show helpful diagnostics

CUDA Setup Requirements

Prerequisites

  1. NVIDIA GPU (compute capability 3.5 or higher)
  2. NVIDIA Driver (compatible with your GPU)
  3. CUDA Toolkit (version compatible with onnxruntime-gpu)
  4. cuDNN (version compatible with onnxruntime-gpu)

Checking Your Setup

You should see CUDAExecutionProvider in the list of providers.

Version Compatibility

ONNX Runtime requires specific CUDA and cuDNN versions. Check the CUDA Execution Provider documentation for compatibility matrix.
Common compatible versions:
  • ONNX Runtime 1.16+: CUDA 11.8 or 12.x, cuDNN 8.x
  • ONNX Runtime 1.15: CUDA 11.6/11.7, cuDNN 8.x

Sentence-Transformers GPU Support

Sentence-transformers has broader GPU compatibility since it uses PyTorch:
PyTorch will automatically use CUDA if available. Check with:

Performance Optimization

Batch Size Tuning

GPUs benefit from larger batch sizes:
Recommendations:
  • CPU: 16-32
  • GPU (8GB VRAM): 64-128
  • GPU (16GB+ VRAM): 128-256

Memory Considerations

GPU memory usage depends on:
  • Model size: Larger embedding models need more VRAM
  • Batch size: Larger batches need more VRAM
  • Sequence length: Longer documents need more VRAM
If you encounter out-of-memory errors:
  1. Reduce batch_size
  2. Use a smaller embedding model
  3. Chunk documents into smaller pieces

Performance Comparison

Typical speedups with GPU acceleration:
Actual performance varies based on hardware, model size, document length, and batch size.

Troubleshooting

”CUDAExecutionProvider not available”

Cause: onnxruntime-gpu is not properly installed or CUDA is misconfigured Solutions:
  1. Verify CUDA installation: nvidia-smi
  2. Reinstall onnxruntime-gpu: pip install --force-reinstall onnxruntime-gpu
  3. Check CUDA version compatibility
  4. Install matching cuDNN version

”CUDA out of memory”

Cause: Batch size or model too large for GPU VRAM Solutions:
  1. Reduce batch_size in config
  2. Use a smaller embedding model
  3. Close other GPU-intensive applications

”GPU not detected”

Cause: nvidia-smi not found or GPU driver issue Solutions:
  1. Install/update NVIDIA drivers
  2. Verify GPU is recognized: lspci | grep -i nvidia
  3. Check if GPU is enabled in BIOS/UEFI

Slow Performance Despite GPU

Causes:
  • Batch size too small (GPU underutilized)
  • Data transfer bottleneck
  • CPU preprocessing overhead
Solutions:
  1. Increase batch size gradually
  2. Profile with nvidia-smi dmon during indexing
  3. Ensure SSD storage for faster I/O

Environment Variables

Useful CUDA-related environment variables:

Next Steps

  • Learn about Embedding Backends to choose between fastembed and sentence-transformers
  • Explore Hybrid Search to understand how embeddings are used in queries