question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cli: Confused on (str, int, List[int]) variants for argparse for --gpus flag?

See original GitHub issue

🐛 Bug

A colleague (@siyuanfeng-tri) and I sometimes get confused on how the --gpus flag is to be interpreted by argparse. I see the following docs: https://pytorch-lightning.readthedocs.io/en/1.2.1/advanced/multi_gpu.html#select-gpu-devices

But we’re sometimes confused about when argparse interpretation will either assume it’s the count of the gpu (int/str) or the device index (List[int]).

Are there docs for this? If not, can that be clarified somehow?

Please reproduce using the BoringModel

see notebook

The main complaint is that gpus=3 implies gpus=[3], while gpus="3" implies gpus=[0,1,2]. Mix that with implicit conversion from argparse from str to int, and you get a kinda weird public interface.

To Reproduce

example notebook: https://colab.research.google.com/drive/1pe9_F2S73-gQ3hOeh_MMiGhmbXmGURDQ?usp=sharing

Expected behavior

Less confusing / more explicit options? (maybe my complaint is with weird implicit behavior of Trainer(gpus=...)?)

Environment

  • PyTorch Version (e.g., 1.7.1):
  • OS: Ubuntu 18.04
  • How you installed PyTorch: pip
  • Python version: 3.6.9
  • CUDA/cuDNN version: N/A
  • GPU models and configuration: N/A
  • Any other relevant information: N/A

Additional context

N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
williamFalconcommented, May 2, 2021

i vote for making it consistent!

2reactions
edgarribacommented, May 3, 2021

vote for @awaelchli proposal - got some confusion in that too some time ago.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confused on (str, int, List[int]) variants for argparse for --gpus ...
Bug A colleague (@siyuanfeng-tri) and I sometimes get confused on how the --gpus flag is to be interpreted by argparse.
Read more >
Rami/multi-label-class-github-issues-text-classification
"cli: Confused on (str, int, List[int]) variants for argparse for --gpus flag?" ... get confused on how the --gpus flag is to be...
Read more >
Python, argparse, and command line arguments
In this tutorial I discuss what command line arguments are, why we use them, and how to use argparse + Python for command...
Read more >
PyTorch-Lightning Documentation
In short, by refactoring your PyTorch code: 1. You STILL keep pure PyTorch. 2. You DON't lose any flexibility.
Read more >
Available CRAN Packages By Date of Publication
2022-11-17, cffr, Generate Citation File Format ('cff') Metadata for R Packages. 2022-11-17, ClusROC, ROC Analysis in Three-Class Classification Problems ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found