soumith / imagenet-multiGPU.torch

an imagenet example in torch.
BSD 2-Clause "Simplified" License
402 stars 158 forks source link

DPT Synchronize() performance fix. GPU flag fix #47

Closed lukacf closed 8 years ago

lukacf commented 8 years ago

Two fixes, one for performance with the latest DataParallelTable and one for the GPU flag.

model:apply(function(m) if m.syncParameters then m:syncParameters() end end) creates huge slowdowns on multi-GPU (an alexnet minibatch takes about 20 seconds on 4xTitan X, CUDNN R4), most likely due to breaking changes in the latest version of DPT.

The fix is simple: if model.needsSync then model:syncParameters() end

the second issue is that the GPU flag did not work as no device was chosen if nGPU was 1. Moved the setDevice so that it is called in all cases.

Luka

soumith commented 8 years ago

Thank you Luka.