AnswerDotAI / AnswerDotAI/RAGatouille

CUDA out of memory for 3k documents

Open
#247 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4k
Forks
276
PR merge metrics
No merged PRs in 30d

Description

Similar to #205, I am experiencing an issue where CUDA runs out of memory when processing 3k documents (which are actually chunks, as I am using my own splitter).

I’ve noticed in your release notes (v0.0.8 and #173) that you mention adding documents in the range of 100k-500k, which makes me curious about how you achieve that without running out of memory, given that I’m facing memory issues on a T4 GPU with 15360MiB when processing just 3k documents.

What I find interesting is that when using `CUDA_VISIBLE_DEVICES=""`, the process works and takes a relatively short time (around 3 hours). I would like to know if you are still working on a solution for this, or if there is any way to prevent CUDA from running out of memory, as using only the CPU takes 3 hours, and with the GPU, the performance should improve significantly!

My code:
```
def add_documents(self, index_name, documents, metadatas):
RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0")
RAG.index(
collection=documents,
document_metadatas=metadatas,
index_name=index_name,
split_documents=False
)
```

Cuda Error:

```
PyTorch-based indexing did not succeed with error: CUDA out of memory. Tried to allocate 7.60 GiB. GPU 0 has a total capacity of 14.58 GiB of which 2.44 GiB is free. Process 16619 has 1.03 GiB memory in use. Including non-PyTorch memory, this process has 11.11 GiB memory in use. Of the allocated memory 10.87 GiB is allocated by PyTorch, and 109.76 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables) ! Reverting to using FAISS and attempting again...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reported add_documents method and its RAG.index call using colbert-ir/colbertv2.0, then compare the CUDA failure with the CPU fallback and the behavior described in release notes v0.0.8, #173, and #205. Done means identifying a reproducible way to index 3k documents on the stated T4 without the reported CUDA out-of-memory failure, or documenting the required limitation and configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.