fix caffe train GPU initialization

Previously, the solver constructed nets before the caffe train tool read
the --gpu flag, which can cause errors due to LayerSetUp executing on
the wrong device (breaking cuDNN, for example).
Merge pull request #1083 from longjon/fix-solver-gpu-init

Fix solver GPU initialization order (e.g., training with cuDNN on non-default device)