gpt4 book ai didi

matlab - 为什么从 CPU 向 GPU 传输数据比从 GPU 向 CPU 传输数据更快?

转载 作者:太空宇宙 更新时间:2023-11-03 19:17:26 31 4
gpt4 key购买 nike

我注意到将数据传输到最近的高端 GPU 比将数据收集回 CPU 更快。以下是使用 mathworks 技术支持提供给我的基准测试功能的结果,该功能在较旧的 Nvidia K20 和最近的带有 PCIE 的 Nvidia P100 上运行:

Using a Tesla P100-PCIE-12GB GPU.
Achieved peak send speed of 11.042 GB/s
Achieved peak gather speed of 4.20609 GB/s

Using a Tesla K20m GPU.
Achieved peak send speed of 2.5269 GB/s
Achieved peak gather speed of 2.52399 GB/s

我附上了下面的基准函数以供引用。 P100上不对称的原因是什么?这个系统是依赖的还是最近的高端 GPU 上的规范?采集速度可以提高吗?

gpu = gpuDevice();
fprintf('Using a %s GPU.\n', gpu.Name)
sizeOfDouble = 8; % Each double-precision number needs 8 bytes of storage
sizes = power(2, 14:28);

sendTimes = inf(size(sizes));
gatherTimes = inf(size(sizes));
for ii=1:numel(sizes)
numElements = sizes(ii)/sizeOfDouble;
hostData = randi([0 9], numElements, 1);
gpuData = randi([0 9], numElements, 1, 'gpuArray');
% Time sending to GPU
sendFcn = @() gpuArray(hostData);
sendTimes(ii) = gputimeit(sendFcn);
% Time gathering back from GPU
gatherFcn = @() gather(gpuData);
gatherTimes(ii) = gputimeit(gatherFcn);
end
sendBandwidth = (sizes./sendTimes)/1e9;
[maxSendBandwidth,maxSendIdx] = max(sendBandwidth);
fprintf('Achieved peak send speed of %g GB/s\n',maxSendBandwidth)
gatherBandwidth = (sizes./gatherTimes)/1e9;
[maxGatherBandwidth,maxGatherIdx] = max(gatherBandwidth);
fprintf('Achieved peak gather speed of %g GB/s\n',max(gatherBandwidth))

编辑:我们现在知道它不依赖于系统(见评论)。我仍然想知道不对称的原因或是否可以更改。

最佳答案

对于任何有兴趣从他们的机器发布基准测试的人来说,这是一个 CW。鼓励贡献者留下他们的详细信息,以防将来出现关于他们的结果的问题。



系统:Win10、32GB DDR4-2400Mhz 内存、i7 6700K。 MATLAB:R2018a。

Using a GeForce GTX 660 GPU.
Achieved peak send speed of 7.04747 GB/s
Achieved peak gather speed of 3.11048 GB/s

Warning: The measured time for F may be inaccurate because it is running too fast. Try measuring something that takes
longer.

贡献者:Dev-iL



系统:Win7、32GB RAM、i7 4790K。 MATLAB:R2018a。

Using a Quadro P6000 GPU.
Achieved peak send speed of 1.43346 GB/s
Achieved peak gather speed of 1.32355 GB/s

贡献者:Dev-iL

关于matlab - 为什么从 CPU 向 GPU 传输数据比从 GPU 向 CPU 传输数据更快?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50302112/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com