aimet-model-zoo icon indicating copy to clipboard operation
aimet-model-zoo copied to clipboard

`--use-cuda` flag is useless - unable to run any code without cuda

Open FelixSchwarz opened this issue 9 months ago • 2 comments

Currently the code 1 uses

parser.add_argument('--use-cuda', help='Use cuda', default=True, type=bool)

to parse the CLI parameters. The documentation mentions that this CLI flag should be used to tell the code "whether to run on GPU or cpu".

However argparse does not work that way: When --use-cuda is specified, it will store True but if the user omits the flag, default=True kicks in and sets use_cuda := True.

To make the parameter work as intended I see the following options:

  • use default=False with the consequence that cuda will be off by default which is likely not what you want.
  • parser.add_argument('--use-cuda', nargs='?', default=True, help='Enable CUDA') and add some custom code to convert str inputs like "False" to a boolean value (example from StackOverflow).

On top of that at least the torch/resnet code uses .cuda() unconditionally so the user setting will not have an effect anyway. I think the cleanest solution would be to pass a device parameter from the script to ResNet.

FelixSchwarz avatar Oct 10 '23 09:10 FelixSchwarz