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

fix gpus -1 for CPU #8766

Closed
wants to merge 10 commits into from
Closed

fix gpus -1 for CPU #8766

wants to merge 10 commits into from

Conversation

Borda
Copy link
Member

@Borda Borda commented Aug 6, 2021

What does this PR do?

the gpus=-1 shall be robust even if you do not have any GPU

Does your PR introduce any breaking changes? If yes, please list them.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@Borda Borda added the bug Something isn't working label Aug 6, 2021
@Borda Borda added this to the v1.4.x milestone Aug 6, 2021
@codecov
Copy link

codecov bot commented Aug 6, 2021

Codecov Report

Merging #8766 (6cd50d2) into master (69f287e) will decrease coverage by 1%.
The diff coverage is 67%.

@@           Coverage Diff           @@
##           master   #8766    +/-   ##
=======================================
- Coverage      93%     92%    -1%     
=======================================
  Files         169     169            
  Lines       14077   14079     +2     
=======================================
- Hits        13045   12934   -111     
- Misses       1032    1145   +113     

@Borda Borda requested review from awaelchli, ethanwharris and a team August 6, 2021 10:46
Copy link
Member

@ethanwharris ethanwharris left a comment

Choose a reason for hiding this comment

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

Looks good 😃 Maybe update a CPU test to use gpus=-1 to show that it is working

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

would be nice to include this change in the changelog :)

@awaelchli
Copy link
Contributor

I would also like to suggest not classifying this as bugfix :)
We have documented the current behavior here: https://pytorch-lightning.readthedocs.io/en/latest/advanced/multi_gpu.html#select-gpu-devices

@Borda Borda self-assigned this Sep 10, 2021
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

@@ -581,6 +579,8 @@ def parallel_devices(self) -> List[Union[torch.device, int]]:
# https://github.com/PyTorchLightning/pytorch-lightning/issues/3169
if isinstance(self.tpu_cores, int):
devices = list(range(self.tpu_cores))
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you there ? tpu_cores=[5] is also a valid value.

Copy link
Member Author

Choose a reason for hiding this comment

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

so far reading code not...
cc: @kaushikb11 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: Aki Nitta <nitta@akihironitta.com>
@Borda Borda requested review from akihironitta and tchaton October 15, 2021 08:11
pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
tests/__init__.py Outdated Show resolved Hide resolved
@mergify mergify bot removed the has conflicts label Oct 26, 2021
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
@Borda Borda requested a review from carmocca October 26, 2021 21:34
CHANGELOG.md Show resolved Hide resolved
@Borda Borda closed this Oct 27, 2021
@carmocca carmocca deleted the gpus/-1 branch October 27, 2021 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants