scnn_pytorch icon indicating copy to clipboard operation
scnn_pytorch copied to clipboard

GPU parallel

Open HongJinZ opened this issue 6 years ago • 5 comments

Hello,I don't know how to use 2 GPUs to run this code. Could you teach me? Thank you very much.

HongJinZ avatar Apr 09 '19 03:04 HongJinZ

Passing more than one gpu ids to --gpu is supported. (For example, python main.py --gpu 0 1) Besides, if you want to test vgg_SCNN_DULR_w9.pth, you have to modify multiGPU = True in tools/t7_to_pth.py.

jcdubron avatar Apr 09 '19 03:04 jcdubron

I have followed your operations, but it still work with one GPU. At the beginning, it occurred a fault like this “'DataParallel' object has no attribute 'fc9' ”. So I add a sentence like this "model=model.module".

HongJinZ avatar Apr 09 '19 04:04 HongJinZ

Sorry about that. I make a commit to comment several lines in main.py as below. I'm not sure if "model=model.module" works and maybe replacing "model.fc9" with "model.module.fc9" is more likely to take effect.

# scheduler
optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=args.momentum, weight_decay=args.weight_decay)
# fc9_params = [id(p) for p in model.fc9.parameters()]
# fc10_params = [id(p) for p in model.fc10.parameters()]
# base_params = filter(lambda p: id(p) not in fc9_params + fc10_params, model.parameters())
# optimizer = optim.SGD([{'params': base_params},
#                        {'params': model.fc9.parameters(), 'lr': args.lr * 10},
#                        {'params': model.fc10.parameters(), 'lr': args.lr * 10}],
#                       lr=args.lr, momentum=args.momentum, weight_decay=args.weight_decay)

jcdubron avatar Apr 09 '19 05:04 jcdubron

Thank you very much. And I will have a try again.

HongJinZ avatar Apr 09 '19 05:04 HongJinZ

I have solved this problem. You are so kind that reply our questions as soon as possible. Thank you very much.

HongJinZ avatar Apr 09 '19 05:04 HongJinZ