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

Accuracy incurs a GPU/CPU sync point #2638

Closed
ndrwrbgs opened this issue Jul 22, 2024 · 3 comments · Fixed by #2640
Closed

Accuracy incurs a GPU/CPU sync point #2638

ndrwrbgs opened this issue Jul 22, 2024 · 3 comments · Fixed by #2640
Labels
bug / fix Something isn't working help wanted Extra attention is needed v1.4.x

Comments

@ndrwrbgs
Copy link
Contributor

ndrwrbgs commented Jul 22, 2024

🐛 Bug

If running Accuracy inside the training loop, training is slowed due to CPU/GPU sync point

To Reproduce

Steps to reproduce the behavior...

Pull Request includes reproduction, a unit test which fails before the modification and passes after.
#1 Update _safe_divide to allow Accuracy to run on the GPU

P.S. I opened it in the fork due to the question # 1 under "Before submitting", but Contributing.md does not mandate discussion prior "Submit a PR!", would it be possible to update one or the other with the latest guidance?

Expected behavior

Accuracy can be calculated on the GPU, without syncing

Environment

  • TorchMetrics version (and how you installed TM, e.g. conda, pip, build from source): conda torchmetrics 1.4.0.post0 pyhd8ed1ab_0 conda-forge
  • Python & PyTorch Version (e.g., 1.0): python 3.11.9 hb806964_0_cpython conda-forge
  • Any other relevant information such as OS (e.g., Linux):
@ndrwrbgs ndrwrbgs added bug / fix Something isn't working help wanted Extra attention is needed labels Jul 22, 2024
Copy link

Hi! thanks for your contribution!, great first issue!

@SkafteNicki
Copy link
Member

Hi @ndrwrbgs, thanks for reporting this issue and thanks for already having a fix and unittest for the bug!
Could you open a PR directly to the main torchmetrics repository so we can get the fix incorporated?

@ndrwrbgs
Copy link
Contributor Author

Thank you, all done at #2640

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug / fix Something isn't working help wanted Extra attention is needed v1.4.x
Projects
None yet
3 participants