How to use multiple GPU in chainer.training.extensions.Evaluator?

234 Views Asked by At

because my train model is on multiple GPU, during training , I use trainer.extend to validate my model every epoch, But chainer.training.extensions.Evaluator has only one device argument, but my model network parameter is on 2 GPUs. how to validate in this situation?

1

There are 1 best solutions below

3
On

The device argument of Evaluator indicates to which device the input data should be put. It does nothing about model parameters.

If your model needs the input data loaded to multiple GPUs as well, Evaluator does not support such case directly so you have to customize it. The easiest way is setting a custom converter function (which is responsible on copying the data to appropriate devices). See the document of Evaluator for the details of converter. https://docs.chainer.org/en/stable/reference/generated/chainer.training.extensions.Evaluator.html