# Why the GPU will cost more time when train the net

I'm in Windows 10

\$Version

11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)

net = LinearLayer[];
AbsoluteTiming[
trained = NetTrain[net, {1 -> 1.9, 2 -> 4.1, 3 -> 6.0, 4 -> 8.1}]]

net = LinearLayer[];
AbsoluteTiming[
trained = NetTrain[net, {1 -> 1.9, 2 -> 4.1, 3 -> 6.0, 4 -> 8.1},TargetDevice -> "GPU"]]

I can reproduce this case,but actually I have a very powerfull gpu as you see

Needs["MXNetLink"];

{<|TotalMemory->-2147483648,ComputeCapability->61/10,Name->GeForce GTX1060|>}

Do I have triggered the bug of MMA? I'm in the v11.2. Can anyone reproduce it?

• GPUs are good at performing the same calculations on large arrays. Training a single linear mapping may well be slower on the GPU. If you train networks with millions of parameters, the GPU is much much faster, in my experience. I don't think this is a bug. Sep 28 '17 at 6:08
• What @nikie says one with caveat: training/inference is only fast if all activation maps and gradients fit in GPU memory. Sep 28 '17 at 6:22
• stackoverflow.com/questions/41948406/… Sep 28 '17 at 8:52
• Actually simply increasing the size of the training data, thus allowing larger batch size, makes the GPU training faster. Try this NetTrain[net, RandomReal[1, 10^5] -> RandomReal[1, 10^5]]. GPUs are only better than CPUs when a lot of computations can be done in parallel. Sep 28 '17 at 23:59