Skip to content
New issue

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

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

Already on GitHub? # to your account

Add multi cpu example #3048

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

baslia
Copy link

@baslia baslia commented Nov 9, 2024

This pull request adds an example demonstrating how to use parallel computing with the tqdm package to show progress while encoding sentences using the SentenceTransformer model. The example leverages the multiprocessing module to parallelize the encoding process and tqdm to display a progress bar.

@tomaarsen
Copy link
Collaborator

Hello!

I believe you should also be able to do multi-CPU processing with this script: https://github.com/UKPLab/sentence-transformers/blob/master/examples/applications/computing-embeddings/computing_embeddings_multi_gpu.py
Although please do let me know if your script is stronger than this one! I'm always open to approaches for faster inference.

I think perhaps the docstrings/comments in there are unclear. What do you think?

  • Tom Aarsen

@baslia
Copy link
Author

baslia commented Nov 11, 2024

Hello,
Thank you for your reply.
I am not sure that the code you mentioned is working on CPUs, especially on the M1 Macs.
Since I often use this package, I wanted to give a working example of what I frequently use.

@tomaarsen
Copy link
Collaborator

I am not sure that the code you mentioned is working on CPUs, especially on the M1 Macs.

Oh, that is fair. I don't have access to a Mac, so it's a bit hard for me to test whether https://github.com/UKPLab/sentence-transformers/blob/master/examples/applications/computing-embeddings/computing_embeddings_multi_gpu.py already works. Could you perhaps give it a try?

  • Tom Aarsen

@baslia
Copy link
Author

baslia commented Nov 11, 2024

Sure, here is the error message.
I am not sure about the exact root cause but I believe it is coming from not having a CUDA device.

2024-11-11 12:32:59 - Load pretrained SentenceTransformer: all-MiniLM-L6-v2
/opt/homebrew/Caskroom/miniforge/base/envs/py312/lib/python3.12/site-packages/huggingface_hub/file_download.py:1150: FutureWarning:
`resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
/opt/homebrew/Caskroom/miniforge/base/envs/py312/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning:
resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants