Filter löschen
Filter löschen

why GPUarray is slower than CPU?

17 Ansichten (letzte 30 Tage)
mankang
mankang am 1 Mär. 2018
Beantwortet: Priyank Sharma am 12 Mär. 2018
Hi. GPU vs CPU speed check. why GPUarray is slower than CPU? GPU : GTX 1080, CPU i7-8700K
% ----------------CPU ---------------
for m=1:100
for n=1:100
aa = rand(m,n);
bb= rand(m,n);
cc = corr2(aa,bb);
end
end
fprintf('\n CPU Run time [%2f]', toc);
% ----------------GPU ---------------
for m=1:100
for n=1:100
aaa= rand(m,n,'gpuArray');
bbb= rand(m,n,'gpuArray');
ccc = corr2(aaa,bbb);
end
end
fprintf('\n GPU Run time [%2f]', toc);
Result : CPU Run time [0.320389], GPU Run time [9.299645]

Akzeptierte Antwort

Priyank Sharma
Priyank Sharma am 12 Mär. 2018
There are multiple factors which determine a GPU's performance. The headline number of cores a GPU has is not enough to accurately gauge performance for double precision computing. You can follow the steps below to test your GPU performance:
1. Run a standard benchmark test.
2. If the benchmark shows different behavior between the precision types: calculate the expected ratio between Single and Double Precision for their GPU card.
3. If the card is a laptop (mobile) card, adjust expectation for performance.
4. If there is a kernel timeout, the paralleldemo_gpu_benchmark benchmark is likely to trigger it.
5. If performance in the benchmarks is good and clear then it is likely a problem originating in code.
Standard GPU Benchmark:
There is a benchmarking test written by MathWorks Parallel Computing Team and available on the File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/34080-gpubench
This test will do a variety of tests involving both memory and compute intensive tasks in both single and double precision.
One thing to understand is most GPUs are optimized for single-precision maths (as is used by OpenGL etc.). GeForce cards, mobile or otherwise, are quite good for single-precision performance but usually about 8x worse for double.
MATLAB defaults to using double-precision everywhere. Of the NVIDIA cards, only the Tesla and top-end Quadro series do well at double-precision. Add to that the fact that a mobile GPU typically has far fewer cores than a desktop one.
Try the benchmark and check the result for your GPU.

Weitere Antworten (0)

Kategorien

Mehr zu GPU 연산 finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!