`--use-cuda` flag is useless - unable to run any code without cuda
Opened this issue · 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 convertstr
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
.
@quic-hanwxion could you please look at this as well. Thanks
Thank you, I added PR #43 to make the resnet eval code runnable without cuda.