#run.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--device', type=str, default='cpu:0',help='use which device')
parser.add_argument('--worker', type=int, default=1,help='num of workers')
parser.add_argument('--cpu_worker', type=int, default=1,help='num of cpu workers')
args = parser.parse_args()
main(args)
调用
python3 -u run.py \
--worker 4 \
--device cuda:0 \
--cpu_worker 2
查看帮助
python3 run.py -h
其中,_与-没有区别,cpu_worker也可以写成cpu-worker