Feedback about A guide on good usage of non_blocking and pin_memory() in PyTorch
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
调研方向
从教程章节“使用 non_blocking=True(CUDA cudaMemcpyAsync)的异步与同步操作”开始,将 benchmark_with_profiler(streamed=True, pinned=True) 的图与显示的内部函数进行比较。检查 t_star_cuda_h2d_event 和 t3_cuda_h2d_event 的同步顺序。当代码、图和解释一致,或差异已得到明确解释时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
There is the following issue on this page: https://docs.pytorch.org/tutorials/intermediate/pinmem_nonblock.html#asynchronous-vs-synchronous-operations-with-non-blocking-true-cuda-cudamemcpyasync
In section "Asynchronous vs. Synchronous Operations with non_blocking=True (CUDA cudaMemcpyAsync)", for the plot for the command benchmark_with_profiler(streamed=True, pinned=True), if we look at the pink cudaEventSynchronize blocks, it seems like first, the event on the stream on which the tensor multiplication (t3_cuda_mul = t3_cuda * t3_cuda * t3_cuda) is happening is being synchronized, and then the event on the stream on which the transfer (t1_cuda = t1_cpu_pinned.to(device, non_blocking=True)) is happening is being synchronized.
However, in the code in the same page, the order is reverse (first t_star_cuda_h2d_event is synchronized which is the event on the stream of transfer, and then t3_cuda_h2d_event which is the event of the stream of multiplication):
# The function we want to profile
def inner(pinned: bool, streamed: bool):
with [torch.cuda.stream](https://docs.pytorch.org/docs/stable/generated/torch.cuda.stream.html#torch.cuda.stream)([s](https://docs.pytorch.org/docs/stable/generated/torch.cuda.Stream.html#torch.cuda.Stream)) if streamed else contextlib.nullcontext():
if pinned:
t1_cuda = [t1_cpu_pinned](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor).to([device](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.device), non_blocking=True)
else:
t2_cuda = [t2_cpu_paged](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor).to([device](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.device), non_blocking=True)
t_star_cuda_h2d_event = [s.record_event](https://docs.pytorch.org/docs/stable/generated/torch.cuda.Stream.html#torch.cuda.Stream.record_event)()
# This operation can be executed during the CPU to GPU copy if and only if the tensor is pinned and the copy is
# done in the other stream
[t3_cuda](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor)_mul = [t3_cuda](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor) * [t3_cuda](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor) * t3_cuda
t3_cuda_h2d_event = [torch.cuda.current_stream](https://docs.pytorch.org/docs/stable/generated/torch.cuda.current_stream.html#torch.cuda.current_stream)().record_event()
t_star_cuda_h2d_event.synchronize()
t3_cuda_h2d_event.synchronize()
Hence, I think there might be a slight discrepancy between the code and the images (please correct me if I am misinterpreting anything here). It definitely doesn't change the conclusions any bit, but just thought it would be nice to bring to light, as I got confused for a second there.
Thanks a lot!
Best,
Shashank
- 主要语言
- Python
- 星标
- 9.5k
- 派生
- 4.5k
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 2
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pytorch/tutorials 的其他 Issue
-
module: vulkan
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
Feedback about Datasets & DataLoaders可能已有人在做 @hippi345 于 47 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 2 天内回复
-
💡 [REQUEST] - Add model.eval() after loading the mdoel可能已有人在做 @Justee21 于 71 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 78/100
维护者通常 2 天内回复
-
[BUG] Captum tutorial fails when visualize_image_attr() receives None for original_image可能已有人在做 @manjirisharma 于 41 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
pytorch/tutorials#3963 · 1 条评论 ·
维护者通常 2 天内回复
-
[BUG] - Incorrect ResNet18 preprocessing in Captum tutorial可能已有人在做 @austxu 于 130 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 2 天内回复
查看 pytorch/tutorials 的全部 Issue
相似的 Issue
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount due可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 79/100
developmentseed/titiler-covjson#164 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
awslabs/visual-asset-management-system#2164 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
MakazhanAlpamys/Soup#3589 ·
维护者通常 1 天内回复
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocket未关闭
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复