Loading

Accelerate dense vector indexing with a GPU in Elasticsearch

GPU indexing in Elasticsearch builds Hierarchical Navigable Small World (HNSW) graphs with the NVIDIA cuVS library. Offloading that work to a graphics processing unit (GPU) speeds up dense vector ingest on large datasets and frees CPU resources for search and other tasks.

To use GPU indexing, you need:

  • An Enterprise subscription
  • A supported NVIDIA GPU (Ampere architecture or better, compute capability >= 8.0) with a minimum 8 GB of GPU memory
  • GPU driver, CUDA, and cuVS runtime libraries installed on the node. Refer to the Elastic support matrix for supported CUDA and cuVS versions.
  • LD_LIBRARY_PATH environment variable configured to include the cuVS libraries path and its dependencies (CUDA, rmm, and so on)
  • Supported platform: Linux x86_64 only, Java 22 or later
  • Supported dense vector configurations: hnsw and int8_hnsw; float element type only

The vectors.indexing.use_gpu node-level setting controls GPU vector indexing.

You can extend the official Elasticsearch Docker image with this example Dockerfile to add the dependencies required for GPU support.

Warning

This Dockerfile serves as an example implementation, and is not fully supported like our official Docker images.

The host machine running the Docker container needs NVIDIA Container Toolkit installed and configured.

docker build -t es-gpu .
		
docker run \
  -p 9200:9200 \
  -p 9300:9300 \
  -e "discovery.type=single-node" \
  -e "xpack.security.enabled=false" \
  -e "xpack.license.self_generated.type=trial" \
  -e "vectors.indexing.use_gpu=true" \
  --user elasticsearch \
  --gpus all \
  --rm -it es-gpu
		

Use the GET _xpack/usage API to monitor GPU vector indexing status and usage across all nodes in the cluster:

				GET _xpack/usage?filter_path=gpu_vector_indexing
		
{
  "gpu_vector_indexing": {
    "available": true,
    "enabled": true,
    "index_build_count": 30,
    "nodes_with_gpu": 3,
    "nodes": [
      { "type": "NVIDIA L4", "memory_in_bytes": 24000000000,
        "enabled": true, "index_build_count": 10 },
      { "type": "NVIDIA L4", "memory_in_bytes": 24000000000,
        "enabled": true, "index_build_count": 10 },
      { "type": "NVIDIA A100", "memory_in_bytes": 80000000000,
        "enabled": true, "index_build_count": 10 }
    ]
  }
}
		
  1. Whether the current license permits GPU indexing.
  2. Whether at least one node has GPU hardware configured and has not turned it off through vectors.indexing.use_gpu=false.
  3. Total number of GPU index builds across the cluster.
  4. Number of data nodes with GPU support.
  5. Per-node GPU details including type, memory, enabled status, and build count.

By default, Elasticsearch uses GPU indexing for supported vector types if a compatible GPU and required libraries are detected. Check server logs for messages indicating whether Elasticsearch has detected a GPU.

If the following message appears, a GPU was successfully detected and GPU indexing is used:

[o.e.x.g.GPUSupport ] [elasticsearch-0] Found compatible GPU [NVIDIA L4] (id: [0])
		

If this message doesn't appear, check for warning messages explaining why GPU indexing isn't being used, such as an unsupported environment, missing libraries, or an incompatible GPU.

To enforce GPU indexing, set vectors.indexing.use_gpu: true in elasticsearch.yml. The node fails to start if GPU indexing isn't available. For example, if a GPU isn't detected by Elasticsearch, if the runtime isn't supported, or if the necessary dependencies aren't correctly configured.

If the node fails to start, check:

  • A supported NVIDIA GPU is present
  • CUDA runtime libraries and drivers are installed (check with nvidia-smi)
  • LD_LIBRARY_PATH includes paths to the cuVS libraries and to their dependencies (for example, CUDA)
  • Supported platform: Linux x86_64 with Java 22 or later

If you're sure that GPU indexing is enabled but performance doesn't improve, check the following:

  • Use supported vector index types and the float element type.
  • Use a dataset large enough to benefit from GPU acceleration.
  • Check for other bottlenecks. GPU indexing accelerates HNSW graph building, but other factors can limit speedups.
    • Indexing throughput depends on how fast you can get data into Elasticsearch. Check network speed and client performance. Use multiple clients if needed.
    • JSON parsing can dominate the computation. Use base64 encoded vectors instead of JSON arrays.
    • Storage speed also matters. The GPU can process lots of data, so use storage that can keep up. Avoid network-attached storage, and prefer fast NVMe.
  • Monitor CPU usage to confirm work is offloaded to the GPU.
  • Monitor GPU usage (for example, with nvidia-smi).