bug(python): Vector Index creation fails with CUDA device
Author: BTheunissenCreated Oct 23, 2024Updated Sep 24, 2026
Labelsbug
LanceDB version
0.14.0
What happened?
Getting a centroid shape error specifically when building vector index with device='cuda' since upgrading, confirmed that this same call works well on CPU with device=None.
Error Logs:
2024-10-22 19:19:17,868 [INFO] (3052) vector_store_table - Building index with partitions: 38 and sub vectors: 769, from 769 vectors with dimension 769, and metric dot
2024-10-22 19:19:17,868 [INFO] (3052) vector_store_table - Creating index with device: cuda
2024-10-22 19:19:17,868 [INFO] (3052) root - Randomly select 38 centroids from <lance.dataset.LanceDataset object at 0x7fa862a66030> (filt=vector is not null)
2024-10-22 19:19:17,907 [INFO] (3052) root - Done sampling: centroids shape: torch.Size([40, 769])
2024-10-22 19:19:17,908 [INFO] (3052) root - Training IVF partitions using GPU(cuda)
2024-10-22 19:19:17,908 [INFO] (3052) root - Start kmean training, metric: dot, iters: 50
2024-10-22 19:19:20,121 [INFO] (3052) root - Finish KMean training in 2.2132339477539062
2024-10-22 19:19:20,122 [INFO] (3052) root - Saved centroids to /tmp/tmpa_xeilpo
100%|██████████| 155975/155975 [00:01<00:00, 135535.00it/s]9318:
2024-10-22 19:19:21,274 [INFO] (3052) root - Saved precomputed partitions to /tmp/tmpziw4_wr2
2024-10-22 19:19:21,274 [ERROR] (3052) vector_store.vector_store_table - Failed to create index. Continuing without index...
Traceback (most recent call last):
File "/vector_store/vector_store_table.py", line 566, in _make_vector_index
self._table.create_index(
File "/.venv/lib/python3.11/site-packages/lancedb/table.py", line 1316, in create_index
self._dataset_mut.create_index(
File "/.venv/lib/python3.11/site-packages/lance/dataset.py", line 1708, in create_index
raise ValueError(
> ValueError: Ivf centroids must be 2D array: (clusters, dim), got (40, 769)Machine Details:
Considered resources (1 node):
----------------------------------------------------------------------------------------------
CLOUD INSTANCE vCPUs Mem(GB) ACCELERATORS REGION/ZONE COST ($) CHOSEN
----------------------------------------------------------------------------------------------
GCP n1-highmem-16 16 104 T4:1 us-central1-a 1.30 ✔
----------------------------------------------------------------------------------------------Are there known steps to reproduce?
No response
Source: lancedb/lancedb