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

Don't start PyTorch thread just doing import. #516

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Conversation

alexaryn
Copy link
Contributor

@alexaryn alexaryn commented Jul 7, 2024

The following modules:

  • easyocr
  • sentence_transformers
  • transformers
  • torchvision

all pull some shennanigans with __init__.py whereby the mere act of importing them starts a PyTorch thread. Aside from being rude, this has the side effect of attaching to the GPU and holding a reference count on the GPU devices in /dev/. In a Ray context, we don't want the driver to use the GPU, just the workers. Also, just generally, importing something should not be so heavy-handed.

Copy link
Contributor

@bsowell bsowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexaryn alexaryn merged commit 59c13cf into main Jul 8, 2024
9 of 12 checks passed
@alexaryn alexaryn deleted the no-start-pt-thread branch July 8, 2024 04:15
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

2 participants