Skip to content

本页尚未翻译

本页内容仍为英文原文,源自官方文档 indexing/gpu-indexing。中文翻译正在分批进行中。

GPU Indexing ​

Build a vector index faster with GPU acceleration, manually in LanceDB Embedded or automatically in LanceDB Enterprise.

Applies to: Embedded ✅, Enterprise ✅

GPU acceleration can reduce the time needed to build vector indexes on large datasets. Actual build time depends on the index configuration, vector dimensions, storage throughput and available GPU resources.

说明

Automatic GPU indexing

Automatic GPU Indexing is currently only available in LanceDB Enterprise. Please contact us to enable this feature for your deployment.

The vector index is created when you call create_index. The backend uses GPU resources to build IVF_PQ indexes, with the number of GPUs set by the deployment's configuration.

This process is also asynchronous by default, but you can use wait_for_index to convert it into a synchronous process by waiting until the index is built.

wait_for_index(...) waits for the index to exist and for index_stats(...) to report num_unindexed_rows == 0. It can time out if the table is receiving continuous writes while the build is trying to catch up.

GPU acceleration changes how the vector index is built, not the lifecycle after the build. In the embedded library, rows appended later still need optimize() before they are part of the index; a deployment adds them in the background -- see Incremental Indexing. fast_search() only searches indexed rows.

Manual GPU indexing in LanceDB Embedded ​

You can use the Python SDK to manually create the IVF_PQ index on a GPU. You'll need PyTorch>2.0. Note that GPU-based indexing is currently only supported by the synchronous SDK in LanceDB Embedded.

Specify the values cuda or mps (on Apple Silicon) for the accelerator parameter to enable GPU training on your device.

GPU indexing on Linux ​

python
table.create_index(
    num_partitions=256,
    num_sub_vectors=96,
    accelerator="cuda",
)

GPU indexing on macOS (Apple Silicon) ​

python
table.create_index(
    num_partitions=256,
    num_sub_vectors=96,
    accelerator="mps",
)

Performance considerations ​

  • GPU memory usage scales with num_partitions and vector dimensions
  • Size GPU memory for the training batches and index configuration
  • Monitor memory use while choosing training batch sizes
  • Measure build time and recall before changing training settings

Troubleshooting ​

If you encounter the error AssertionError: Torch not compiled with CUDA enabled, you need to install PyTorch with CUDA support.

Incremental IndexingKeeping an index up-to-date as new data arrives.SlurmRunning these GPU workers alongside training on shared Slurm-scheduled infrastructure.