跳到正文
r/MachineLearning· /u/makneeee·· 17 天前AI 评分54

作者在 B300 上把 cudaMemcpy 提速 5 倍

Making cudaMemcpy 5x faster on a B300 [P]

AI 导读

作者发布 cudamemcpy-tuner 工具,用于加速 cudaMemcpy 的 pageable 传输。在 B300 上把 1 GB tensor 拷贝到 GPU 再拷回,基准从 10.2 GB/s 提升到 51.5 GB/s。代码已在 GitHub 开源,并附有博客说明。

正文
Making cudaMemcpy 5x faster on a B300 [P]

https://preview.redd.it/cjz9xy3rht1i1.png?width=1600&format=png&auto=webp&s=0eea8a5d9e53d5ea4593ce1a629bc7342a049ffa

Hi everyone,

I made a tool that can speed up pageable transfers for cudaMemcpy. For example:

# B300, copying a 1 GB tensor to the GPU and back: import time, torch x = torch.ones(1 << 30, dtype=torch.uint8) y = x.to("cuda"); y.cpu() for name, copy in [("CPU -> GPU", lambda: (x.to("cuda"), torch.cuda.synchronize()))]: t = time.perf_counter() for _ in range(5): copy() print(f"{name}: {5 * x.nbytes / (time.perf_counter() - t) / 1e9:.1f} GB/s") $ python bench.py CPU -> GPU: 10.2 GB/s $ cmt tune -- python bench.py CPU -> GPU: 51.5 GB/s 

blog: https://maknee.github.io/blog/2026/CudaMemcpy/

code: https://github.com/Maknee/cudamemcpy-tuner

submitted by /u/makneeee
[link] [留言]

来源:r/MachineLearning · reddit.com