Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Updated docker files to use uv for installing packages #36957

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

Merged
merged 5 commits into from
Mar 25, 2025

Conversation

Sai-Suraj-27
Copy link
Contributor

@Sai-Suraj-27 Sai-Suraj-27 commented Mar 25, 2025

What does this PR do?

In many Dockerfiles uv is installed but still it is not used for installing packages at some places. I think using uv at all these places will increase the speed of respective Docker image builds by a considerable amount.

Fixes # (issue)

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@ydshieh @ArthurZucker

@github-actions github-actions bot marked this pull request as draft March 25, 2025 12:30
Copy link

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers.

@Sai-Suraj-27 Sai-Suraj-27 marked this pull request as ready for review March 25, 2025 12:30
Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

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

Thank you. Makes a lot of sense.

I have to trigger a build for the images to make sure it works before I merge.

@ydshieh
Copy link
Collaborator

ydshieh commented Mar 25, 2025

Hi @Sai-Suraj-27 Could you check the error logs in this run: https://github.com/huggingface/transformers/actions/runs/14060656795/job/39370346086

Maybe it's as simple as using -- -y but I never try this myself.

 > [7/8] RUN uv pip uninstall -y transformers:
0.051 error: unexpected argument '-y' found
0.051 
0.051   tip: to pass '-y' as a value, use '-- -y'

@ydshieh ydshieh self-requested a review March 25, 2025 13:25
@Sai-Suraj-27
Copy link
Contributor Author

Sai-Suraj-27 commented Mar 25, 2025

Hi @Sai-Suraj-27 Could you check the error logs in this run: https://github.com/huggingface/transformers/actions/runs/14060656795/job/39370346086

Maybe it's as simple as using -- -y but I never try this myself.

 > [7/8] RUN uv pip uninstall -y transformers:
0.051 error: unexpected argument '-y' found
0.051 
0.051   tip: to pass '-y' as a value, use '-- -y'

Hi, Looks like, uv pip uninstall does not support the -y flag unlike pip uninstall. I tested locally, just using
uv pip uninstall transformers works fine. The fix is simple, I will remove the -y flag wherever it is being used and update the PR.

@ydshieh
Copy link
Collaborator

ydshieh commented Mar 25, 2025

ok thank you. I will try later today.

@ydshieh
Copy link
Collaborator

ydshieh commented Mar 25, 2025

There is remaining one failing job

https://github.com/huggingface/transformers/actions/runs/14063433382/job/39379784581

if you could take a look 🙏

@Sai-Suraj-27
Copy link
Contributor Author

Sai-Suraj-27 commented Mar 25, 2025

There is remaining one failing job

https://github.com/huggingface/transformers/actions/runs/14063433382/job/39379784581

if you could take a look 🙏

Yes, I think this is actually because detectron2's setup script requires torch but it does not explicitly list it as a build dependency. By default uv performs isolated builds when building packages from source. So, here it is not able to access torch. Passing the --no-build-isolation flag for this installation line, fixed the issue. I tested it locally by building the docker image, the build was successful.

image

@ydshieh
Copy link
Collaborator

ydshieh commented Mar 25, 2025

Nice ✅ https://github.com/huggingface/transformers/actions/runs/14064927430

Copy link
Collaborator

@ydshieh ydshieh left a comment

Choose a reason for hiding this comment

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

Thank you for the iteration.

Since this PR only add uv before pip and the images are successfully built, I will merge!

@Sai-Suraj-27
Copy link
Contributor Author

Sai-Suraj-27 commented Mar 25, 2025

Nice ✅ https://github.com/huggingface/transformers/actions/runs/14064927430

I see that we are not using uv anywhere in the Dockerfiles for gpu tasks. Is there any particular reason for this?

@ydshieh
Copy link
Collaborator

ydshieh commented Mar 25, 2025

I see that we are not using uv anywhere in the Dockerfiles for gpu tasks. Is there any particular reason for this? Good speedup will come by using uv right? Would be happy to raise a PR.

No particular reason :-)

It is built in a daily basis, and during the CI run time, we rarely install new stuff, So using uv or not is not is not super important here.

But open to such changes if you want to give it a try. You might first focus on docker/transformers-all-latest-gpu/Dockerfile, see how it goes, and we can see if we want to apply the changes to other files.

@ydshieh ydshieh merged commit a41677a into huggingface:main Mar 25, 2025
8 checks passed
ydshieh added a commit that referenced this pull request Mar 26, 2025
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.

2 participants