Skip to content

Conversation

@AviadHAv
Copy link

No description provided.

orihabAnyvision and others added 20 commits July 28, 2021 14:17
IndexIDMap was missing from the go bindings, even though is is important
to wrap a flat index in if addWithID functionality is required.
IDMapWrapper isn't practical bc I would like to be able to transfer
gpuIndex (or any other index for that matter) to gpu using the
transferToGpu. So I dont want a specific structure which wraps an idmap
index, rather just return an Index interface.
Better to have a test to make sure everything functions properly than an
example usage..
In addition added a test for the bindings which show how to use the
functionality.
This is potentially necessary for various things, but specifically is
critical for us NOW because RemoveIDs isn't implemented for GPUIndexs,
so until we implement that functionality in faiss, the only solution is
to transfer the index back and forth to the CPU and remove ids which the
index is on CPU.
This is so that it will be possible to compile and use the library on a
machine which doesn't have a gpu as well.
Didn't know t.Log existed, better to use it.
I discoverd the hard way that after transferring an index to the GPU,
the gpu memory isn't freed when the index is deleted. It seems like a
gpuResource is being allocated and holding the memory. Its necessary to
free the gpuResource in order to free the Gpumemory.

In order to free the gpuResource we will need to save it, and call free
on it. In the next commit I will add the Free functionality to
gpu_bindings.go.
…letes the index

TransferToCpu will free the gpu memory after copying the index to CPU.

Also added a function to CreateGpuIndex just because it was easy and may
be useful for someone.
Its not really the best, but I assume that most Gpus will run out of
memory when creating 20 gpu indices, so if the test passes, most likely
the free function is working ;)
instead of hold just one gpu resource  , hold all the gpus resrouces.
this is neccesrry when we want to do sharding on multiple gpus with the same index
* Removed redundant get_sizet function
* Changed inside TransferToGpu from gpuResources to gpuResource + made adjustments to work with resources and not resource in the return value
* Added TODO with comment out function TransferToAllGPUsWithOptions for future development
* Free function was adjusted to support array of gpuReource
this  is just to let cpu mode code to compile
currently there is bug on faiss facebookresearch/faiss#2357
to use sharding you have to use this version of faiss for now git clone -b fix-cpi-gpu-faiss_index_cpu_to_gpu_multiple_with_options https://github.com/AviadHAv/faiss.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants