matlab - Why gpu slower than cpu? -
i have gpu
>> d = gpudevice
d = cudadevice properties: name: 'geforce 800m' index: 1 computecapability: '2.1' supportsdouble: 1 driverversion: 6 toolkitversion: 5 maxthreadsperblock: 1024 maxshmemperblock: 49152 maxthreadblocksize: [1024 1024 64] maxgridsize: [65535 65535 65535] simdwidth: 32 totalmemory: 2.1475e+09 freememory: 1.9886e+09 multiprocessorcount: 1 clockratekhz: 1475000 computemode: 'default' gpuoverlapstransfers: 1 kernelexecutiontimeout: 1 canmaphostmemory: 1 devicesupported: 1 deviceselected: 1`
i try use gpu in neuralnetwork train, gpu slower cpu. if try use gpuarray, gpu faster cpu, haven't speed acceleration in neural network training. example
>> a1 = rand(1000); b1 = rand(1000); tic; c1 = a1 * b1; toc; elapsed time 0.044095 seconds.
>> a2 = gpuarray(rand(1000)); b2 = gpuarray(rand(1000)); tic; c2 = a2 * b2; toc; elapsed time 0.000416 seconds.
but in code
net = newff(h, f, layers, { 'tansig' 'tansig'}, 'traingdx', 'learngdm', 'mse'); net.trainparam.epochs = epochs; net.trainparam.show = 500; net.trainparam.time = 495; net.trainparam.goal = 2.0000e-11; net.trainparam.max_fail = 200000; net.trainparam.min_grad = 1.0000e-050; net.performparam.regularization = 0.05; net.divideparam.trainratio = 1; net.divideparam.valratio = 0; net.divideparam.testratio = 0; net.trainparam.showwindow = 0; net.trainparam.showcommandline = 0; if gpu1 == 1 net = train(net, h, f, 'usegpu', 'yes', 'showresources','yes'); else net = train(net, h, f, 'showresources','yes'); end; tic; net = net_example(300, [23, 9], rand(100, 1000), rand(1, 1000), 1); toc; computing resources: gpu device #1, geforce 800m
works slower than
tic; net = net_example(300, [23, 9], rand(100, 1000), rand(1, 1000), 0); toc; computing resources: mex2
Comments
Post a Comment