Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CUDA gpus #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

irthomasthomas
Copy link

@irthomasthomas irthomasthomas commented Jan 18, 2024

Hi Simon,

I was just looking at https://huggingface.co/datasets/SciPhi/AgentSearch-V1
1 Billion passages and 50 Million documents with jina embeddings.

So it motivated me to add cuda support to your jina plugin. CPU is way too slow for me. Only problem is you need to drop the batch size to 1 or 2 for most consumer devices.

Changes

  • Add try/except block to move model to CUDA or keep it on CPU if CUDA is not available
  • No changes to functionality or API of the class

Timing tests

CPU - Batch size 10 (The maximum I can run in 64GB)

time llm embed-multi prompts-cpu-b10-run1 -d embeddings.db --attach logs $(llm logs path) --sql 'SELECT id, prompt FROM logs.responses LIMIT 1000' -m jina-embeddings-v2-base-en --prefix prompt/ --batch-size 10

Output:

llm embed-multi prompts-cpu-b10-run1 -d embeddings.db --attach logs  --sql  -m
  7142.22s user 3449.01s system 1320% cpu 13:21.98 total

GPU

time llm embed-multi prompts-gpu-b1-run2 -d embeddings.db --attach logs  --sql  -m jina-embeddings-v2-base-en --prefix prompt/ --batch-size 1

Output:

llm embed-multi prompts-gpu-b1-run2 -d embeddings.db --attach logs  --sql  -m  
25.44s user 11.39s system 130% cpu 28.310 total

* Add try/except block to move model to CUDA or keep it on CPU if CUDA is not available
* No changes to functionality or API of the class
@irthomasthomas
Copy link
Author

Hi @simonw I'd like to add a flag so we can choose cpu or cuda (and does metal need its own flag or will cpu work?) but I'm not familiar with click. I can make simple click apps with chatgpt, but I got lost trying to figure out exactly where and how to add a new click option to your project. Could you point me in the right direction? Thanks!

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.

None yet

1 participant