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

[ENH] Ensure CPU-only PyTorch Installation by Updating pyproject.toml and Dockerfile #15

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

sumana-2705
Copy link
Contributor

Fixes #9

Description

This PR updates the pyproject.toml and Dockerfile to ensure that only the CPU version of PyTorch is installed, preventing unintended CUDA dependencies.

Changes Made

pyproject.toml

  • Explicitly specified the CPU version of PyTorch.
  • Adjusted dependency constraints to avoid GPU-related versions.

Dockerfile

  • Added --index-strategy unsafe-best-match to uv sync to resolve dependency resolution issues.
  • As torch is installed from trusted package sources (PyPI), I think it should be fine to use --index-strategy unsafe-best-match

How Has This Been Tested?

I have tested installation by developing docker image in my local machine, I have attached the screenshot of it

Screenshot 2025-02-24 220612

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

@sumana-2705
Copy link
Contributor Author

Hello @peterdudfield

Please review the PR, and suggest me if any changes required.

@peterdudfield
Copy link
Contributor

Looks great @dfulu you ok to check this?

@dfulu
Copy link
Member

dfulu commented Feb 25, 2025

@sumana-2705 Thanks for these changes. About the testing you did via command line, you would get the same outputs

 torch.backends.mps.is_available()
>> False
 torch.cuda.is_available()

if you had a GPU version of torch installed but only had a CPU available on the machine you were testing this code.

So does the machine you tested this on have a GPU?

@sumana-2705
Copy link
Contributor Author

WhatsApp Image 2025-02-25 at 6 07 44 PM

Hello @dfulu

Earlier I checked it in a pc which does not have GPU but I have now tried it in the GPU supported pc, it worked correctly as shown in attached picture

@dfulu
Copy link
Member

dfulu commented Feb 25, 2025

Thanks @sumana-2705

@dfulu dfulu self-requested a review February 25, 2025 14:16
@dfulu dfulu merged commit fdfcbb2 into openclimatefix:main Feb 25, 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.

Make sure only cpu torch version is installed
3 participants