cuvs icon indicating copy to clipboard operation
cuvs copied to clipboard

[BUG] deallocation cinit Cython error when freeing IndexParams and Index objects on ARM machines

Open dantegd opened this issue 1 year ago • 0 comments

Describe the bug When using cuVS on an ARM machine, at the time of deallocating cdef classes like cuvs.neighbors.ivf_flat.ivf_flat.Index there is a TypeError that occurs when closing a Python session if the object has not been freed manually before.

Steps/Code to reproduce bug The simple IVF Flat example from the documentation is enough to repro:

(base) rapids@ac26ff6b4be0:~$ python
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:25:01) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupy as cp
>>> from cuvs.neighbors import ivf_flat
>>> n_samples = 50000
>>> n_features = 50
>>> n_queries = 1000
>>> k = 10
>>> dataset = cp.random.random_sample((n_samples, n_features),
...                                   dtype=cp.float32)
>>> build_params = ivf_flat.IndexParams(metric="sqeuclidean")
>>> index = ivf_flat.build(build_params, dataset)
>>> distances, neighbors = ivf_flat.search(ivf_flat.SearchParams(),
...                                        index, dataset,
...                                        k)
>>> distances = cp.asarray(distances)
>>> neighbors = cp.asarray(neighbors)
>>> neighbors
array([[    0, 47082, 38052, ..., 38144, 43180, 18275],
       [    1, 22656, 30272, ..., 46976, 21029, 29177],
       [    2,  1396,  9110, ...,  8034, 40497, 18806],
       ...,
       [49997, 44169, 42303, ..., 38554, 26157, 10332],
       [49998, 42216, 21389, ..., 32133, 30673, 37598],
       [49999, 16160, 11968, ..., 13136, 30920, 10138]])
>>>
TypeError: 'NoneType' object is not callable
Exception ignored in: 'cuvs.neighbors.ivf_flat.ivf_flat.IndexParams.__dealloc__'
TypeError: 'NoneType' object is not callable
TypeError: 'NoneType' object is not callable
Exception ignored in: 'cuvs.neighbors.ivf_flat.ivf_flat.Index.__dealloc__'
TypeError: 'NoneType' object is not callable
(base) rapids@ac26ff6b4be0:~$ 

On the other hand, if we manually del the objects then everything works as expected:

(base) rapids@ac26ff6b4be0:~$ python
Python 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:25:01) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cupy as cp
>>> from cuvs.neighbors import ivf_flat
>>> n_samples = 50000
>>> n_features = 50
>>> n_queries = 1000
>>> k = 10
>>> dataset = cp.random.random_sample((n_samples, n_features),
...                                   dtype=cp.float32)
>>> build_params = ivf_flat.IndexParams(metric="sqeuclidean")
>>> index = ivf_flat.build(build_params, dataset)
>>> distances, neighbors = ivf_flat.search(ivf_flat.SearchParams(),
...                                        index, dataset,
...                                        k)
>>> distances = cp.asarray(distances)
>>> neighbors = cp.asarray(neighbors)
>>> del index
>>> del build_params
>>>
(base) rapids@ac26ff6b4be0:~$

Expected behavior No errors

Environment details (please complete the following information):

  • Environment location: Doker RAPIDS 24.08 nightlies, ARM machine
  • Method of RAFT install: Docker
docker pull rapidsai/base:24.08a-cuda12.2-py3.11
docker run --gpus all --rm -id     --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864   --volume $PWD:/workspace   rapidsai/base:24.08a-cuda12.2-py3.11

dantegd avatar Jun 24 '24 21:06 dantegd