Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 357026,7 "name": null,8 "username": "hitbuyi",9 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png",10 "created_at": "2022-07-18T13:27:52.528Z",11 "cooked": "<p>I need some help on parameters of torch.onnx.export(…)</p>\n<p>1, dynamic axes.what are backgrounds or application requirements for us to set dynamic axes?</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 5,15 "updated_at": "2022-07-18T13:37:32.999Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 369,20 "reads": 9,21 "readers_count": 8,22 "score": 1821.8,23 "yours": false,24 "topic_id": 156882,25 "topic_slug": "on-torch-onnx-export",26 "display_username": null,27 "primary_group_name": null,28 "flair_name": null,29 "flair_url": null,30 "flair_bg_color": null,31 "flair_color": null,32 "flair_group_id": null,33 "badges_granted": [],34 "version": 2,35 "can_edit": false,36 "can_delete": false,37 "can_recover": false,38 "can_see_hidden_post": false,39 "can_wiki": false,40 "read": true,41 "user_title": null,42 "bookmarked": false,43 "actions_summary": [],44 "moderator": false,45 "admin": false,46 "staff": false,47 "user_id": 50569,48 "hidden": false,49 "trust_level": 1,50 "deleted_at": null,51 "user_deleted": false,52 "edit_reason": null,53 "can_view_edit_history": true,54 "wiki": false,55 "post_url": "/t/on-torch-onnx-export/156882/1",56 "can_accept_answer": false,57 "can_unaccept_answer": false,58 "accepted_answer": false,59 "topic_accepted_answer": true,60 "can_vote": false61 },62 {63 "id": 357074,64 "name": "",65 "username": "ptrblck",66 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",67 "created_at": "2022-07-18T18:37:54.179Z",68 "cooked": "<p><code>dynamic_axes</code> can be used to specify dimensions with a dynamic shape (i.e. the shape is known at runtime and can change). Usually dynamic shapes are used in a temporal dimension or spatial dimensions.</p>",69 "post_number": 2,70 "post_type": 1,71 "posts_count": 5,72 "updated_at": "2022-07-18T18:37:54.179Z",73 "reply_count": 1,74 "reply_to_post_number": null,75 "quote_count": 0,76 "incoming_link_count": 0,77 "reads": 8,78 "readers_count": 7,79 "score": 6.6,80 "yours": false,81 "topic_id": 156882,82 "topic_slug": "on-torch-onnx-export",83 "display_username": "",84 "primary_group_name": null,85 "flair_name": null,86 "flair_url": null,87 "flair_bg_color": null,88 "flair_color": null,89 "flair_group_id": null,90 "badges_granted": [],91 "version": 1,92 "can_edit": false,93 "can_delete": false,94 "can_recover": false,95 "can_see_hidden_post": false,96 "can_wiki": false,97 "read": true,98 "user_title": "",99 "bookmarked": false,100 "actions_summary": [],101 "moderator": true,102 "admin": true,103 "staff": true,104 "user_id": 3534,105 "hidden": false,106 "trust_level": 2,107 "deleted_at": null,108 "user_deleted": false,109 "edit_reason": null,110 "can_view_edit_history": true,111 "wiki": false,112 "post_url": "/t/on-torch-onnx-export/156882/2",113 "can_accept_answer": false,114 "can_unaccept_answer": false,115 "accepted_answer": false,116 "topic_accepted_answer": true117 },118 {119 "id": 357114,120 "name": null,121 "username": "hitbuyi",122 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png",123 "created_at": "2022-07-19T03:12:28.166Z",124 "cooked": "<p>I’m still not very clear, take temporal as example, if we take time as a dimension of input ,we can write the input tensor as</p>\n<p>input_image = [W H T]</p>\n<p>where W is width, H is height, T is temporal</p>\n<p>dimension of input_image is 3(fixed), the value of T is changed at every frame, in this example ,we should set T as dynamic axis?</p>\n<p>What I understand about dynamic shape is changing of dimensions, not value of a specified dimension, e.g.,</p>\n<p>at frame 1: input_image = [W H T]<br>\nat frame 2: input_image =[W H]</p>\n<p>this is called dynamic shape of input, right?</p>",125 "post_number": 3,126 "post_type": 1,127 "posts_count": 5,128 "updated_at": "2022-07-19T04:22:06.095Z",129 "reply_count": 1,130 "reply_to_post_number": 2,131 "quote_count": 0,132 "incoming_link_count": 2,133 "reads": 8,134 "readers_count": 7,135 "score": 16.6,136 "yours": false,137 "topic_id": 156882,138 "topic_slug": "on-torch-onnx-export",139 "display_username": null,140 "primary_group_name": null,141 "flair_name": null,142 "flair_url": null,143 "flair_bg_color": null,144 "flair_color": null,145 "flair_group_id": null,146 "badges_granted": [],147 "version": 2,148 "can_edit": false,149 "can_delete": false,150 "can_recover": false,151 "can_see_hidden_post": false,152 "can_wiki": false,153 "read": true,154 "user_title": null,155 "reply_to_user": {156 "id": 3534,157 "username": "ptrblck",158 "name": "",159 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"160 },161 "bookmarked": false,162 "actions_summary": [],163 "moderator": false,164 "admin": false,165 "staff": false,166 "user_id": 50569,167 "hidden": false,168 "trust_level": 1,169 "deleted_at": null,170 "user_deleted": false,171 "edit_reason": null,172 "can_view_edit_history": true,173 "wiki": false,174 "post_url": "/t/on-torch-onnx-export/156882/3",175 "can_accept_answer": false,176 "can_unaccept_answer": false,177 "accepted_answer": false,178 "topic_accepted_answer": true179 },180 {181 "id": 357120,182 "name": "",183 "username": "ptrblck",184 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",185 "created_at": "2022-07-19T04:18:20.597Z",186 "cooked": "<aside class=\"quote no-group\" data-username=\"hitbuyi\" data-post=\"3\" data-topic=\"156882\">\n<div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img loading=\"lazy\" alt=\"\" width=\"24\" height=\"24\" src=\"https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/h/ee59a6/48.png\" class=\"avatar\"> hitbuyi:</div>\n<blockquote>\n<p>What I understand about dynamic shape is changing of dimensions, not value of a specified dimension,</p>\n</blockquote>\n</aside>\n<p>No, usually you refer to a change in the actual shape. I.e. in one iteration the input shape could be <code>[1, 1, 1]</code> in the next it could be <code>[2, 3, 4]</code>.<br>\nDropping or adding an entire dimension would usually just fail at a layer input as a specific number of dimensions is expected.</p>",187 "post_number": 4,188 "post_type": 1,189 "posts_count": 5,190 "updated_at": "2022-07-19T04:18:20.597Z",191 "reply_count": 1,192 "reply_to_post_number": 3,193 "quote_count": 1,194 "incoming_link_count": 4,195 "reads": 8,196 "readers_count": 7,197 "score": 21.6,198 "yours": false,199 "topic_id": 156882,200 "topic_slug": "on-torch-onnx-export",201 "display_username": "",202 "primary_group_name": null,203 "flair_name": null,204 "flair_url": null,205 "flair_bg_color": null,206 "flair_color": null,207 "flair_group_id": null,208 "badges_granted": [],209 "version": 1,210 "can_edit": false,211 "can_delete": false,212 "can_recover": false,213 "can_see_hidden_post": false,214 "can_wiki": false,215 "read": true,216 "user_title": "",217 "bookmarked": false,218 "actions_summary": [],219 "moderator": true,220 "admin": true,221 "staff": true,222 "user_id": 3534,223 "hidden": false,224 "trust_level": 2,225 "deleted_at": null,226 "user_deleted": false,227 "edit_reason": null,228 "can_view_edit_history": true,229 "wiki": false,230 "post_url": "/t/on-torch-onnx-export/156882/4",231 "can_accept_answer": false,232 "can_unaccept_answer": false,233 "accepted_answer": true,234 "topic_accepted_answer": true235 },236 {237 "id": 357122,238 "name": null,239 "username": "hitbuyi",240 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png",241 "created_at": "2022-07-19T04:22:31.469Z",242 "cooked": "<p>Now I get the point, thanks a lot</p>",243 "post_number": 5,244 "post_type": 1,245 "posts_count": 5,246 "updated_at": "2022-07-19T04:22:31.469Z",247 "reply_count": 0,248 "reply_to_post_number": 4,249 "quote_count": 0,250 "incoming_link_count": 2,251 "reads": 7,252 "readers_count": 6,253 "score": 11.4,254 "yours": false,255 "topic_id": 156882,256 "topic_slug": "on-torch-onnx-export",257 "display_username": null,258 "primary_group_name": null,259 "flair_name": null,260 "flair_url": null,261 "flair_bg_color": null,262 "flair_color": null,263 "flair_group_id": null,264 "badges_granted": [],265 "version": 1,266 "can_edit": false,267 "can_delete": false,268 "can_recover": false,269 "can_see_hidden_post": false,270 "can_wiki": false,271 "read": true,272 "user_title": null,273 "reply_to_user": {274 "id": 3534,275 "username": "ptrblck",276 "name": "",277 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"278 },279 "bookmarked": false,280 "actions_summary": [],281 "moderator": false,282 "admin": false,283 "staff": false,284 "user_id": 50569,285 "hidden": false,286 "trust_level": 1,287 "deleted_at": null,288 "user_deleted": false,289 "edit_reason": null,290 "can_view_edit_history": true,291 "wiki": false,292 "post_url": "/t/on-torch-onnx-export/156882/5",293 "can_accept_answer": false,294 "can_unaccept_answer": false,295 "accepted_answer": false,296 "topic_accepted_answer": true297 }298 ],299 "stream": [300 357026,301 357074,302 357114,303 357120,304 357122305 ]306 },307 "timeline_lookup": [308 [309 1,310 1195311 ]312 ],313 "suggested_topics": [314 {315 "fancy_title": "Automatic Differentiation for RNN Leads to Issues",316 "id": 220966,317 "title": "Automatic Differentiation for RNN Leads to Issues",318 "slug": "automatic-differentiation-for-rnn-leads-to-issues",319 "posts_count": 6,320 "reply_count": 3,321 "highest_post_number": 6,322 "image_url": null,323 "created_at": "2025-06-21T15:53:45.715Z",324 "last_posted_at": "2025-06-30T20:41:33.166Z",325 "bumped": true,326 "bumped_at": "2025-06-30T20:41:33.166Z",327 "archetype": "regular",328 "unseen": false,329 "pinned": false,330 "unpinned": null,331 "visible": true,332 "closed": false,333 "archived": false,334 "bookmarked": null,335 "liked": null,336 "tags_descriptions": {},337 "like_count": 0,338 "views": 74,339 "category_id": 1,340 "featured_link": null,341 "has_accepted_answer": false,342 "posters": [343 {344 "extras": null,345 "description": "Original Poster",346 "user": {347 "id": 84774,348 "username": "sactoa",349 "name": "",350 "avatar_template": "/user_avatar/discuss.pytorch.org/sactoa/{size}/77430_2.png",351 "trust_level": 1352 }353 },354 {355 "extras": null,356 "description": "Frequent Poster",357 "user": {358 "id": 1438,359 "username": "vdw",360 "name": "Chris",361 "avatar_template": "/user_avatar/discuss.pytorch.org/vdw/{size}/10074_2.png",362 "trust_level": 2363 }364 },365 {366 "extras": "latest",367 "description": "Most Recent Poster",368 "user": {369 "id": 30062,370 "username": "tonyr",371 "name": "Tony Robinson",372 "avatar_template": "/user_avatar/discuss.pytorch.org/tonyr/{size}/74253_2.png",373 "trust_level": 2374 }375 }376 ]377 },378 {379 "fancy_title": "Pytorch geometric temporal mamba installation",380 "id": 212651,381 "title": "Pytorch geometric temporal mamba installation",382 "slug": "pytorch-geometric-temporal-mamba-installation",383 "posts_count": 4,384 "reply_count": 2,385 "highest_post_number": 4,386 "image_url": null,387 "created_at": "2024-11-07T08:55:00.714Z",388 "last_posted_at": "2024-11-07T09:40:49.990Z",389 "bumped": true,390 "bumped_at": "2024-11-07T09:40:49.990Z",391 "archetype": "regular",392 "unseen": false,393 "pinned": false,394 "unpinned": null,395 "visible": true,396 "closed": false,397 "archived": false,398 "bookmarked": null,399 "liked": null,400 "tags_descriptions": {},401 "like_count": 0,402 "views": 615,403 "category_id": 1,404 "featured_link": null,405 "has_accepted_answer": false,406 "posters": [407 {408 "extras": null,409 "description": "Original Poster",410 "user": {411 "id": 80744,412 "username": "Charitini_S",413 "name": "Charitini S",414 "avatar_template": "/user_avatar/discuss.pytorch.org/charitini_s/{size}/73099_2.png",415 "trust_level": 1416 }417 },418 {419 "extras": "latest",420 "description": "Most Recent Poster",421 "user": {422 "id": 80724,423 "username": "paulge",424 "name": "",425 "avatar_template": "/letter_avatar_proxy/v4/letter/p/82dd89/{size}.png",426 "trust_level": 2427 }428 }429 ]430 },431 {432 "fancy_title": "after reload model training loss keep increasing",433 "id": 217345,434 "title": "after reload model training loss keep increasing",435 "slug": "after-reload-model-training-loss-keep-increasing",436 "posts_count": 1,437 "reply_count": 0,438 "highest_post_number": 1,439 "image_url": null,440 "created_at": "2025-03-02T15:09:49.796Z",441 "last_posted_at": "2025-03-02T15:09:49.828Z",442 "bumped": true,443 "bumped_at": "2025-03-02T15:09:49.828Z",444 "archetype": "regular",445 "unseen": false,446 "pinned": false,447 "unpinned": null,448 "visible": true,449 "closed": false,450 "archived": false,451 "bookmarked": null,452 "liked": null,453 "tags_descriptions": {},454 "like_count": 0,455 "views": 37,456 "category_id": 1,457 "featured_link": null,458 "has_accepted_answer": false,459 "posters": [460 {461 "extras": "latest single",462 "description": "Original Poster, Most Recent Poster",463 "user": {464 "id": 83015,465 "username": "LOYINuts",466 "name": "LOYINuts",467 "avatar_template": "/letter_avatar_proxy/v4/letter/l/91b2a8/{size}.png",468 "trust_level": 0469 }470 }471 ]472 },473 {474 "fancy_title": "Matmul from OneDNN is 10x slower than MKL_BLAS_Sgemm?",475 "id": 218473,476 "title": "Matmul from OneDNN is 10x slower than MKL_BLAS_Sgemm?",477 "slug": "matmul-from-onednn-is-10x-slower-than-mkl-blas-sgemm",478 "posts_count": 2,479 "reply_count": 0,480 "highest_post_number": 2,481 "image_url": null,482 "created_at": "2025-04-01T03:55:21.129Z",483 "last_posted_at": "2025-04-01T03:56:17.103Z",484 "bumped": true,485 "bumped_at": "2025-04-01T03:56:17.103Z",486 "archetype": "regular",487 "unseen": false,488 "pinned": false,489 "unpinned": null,490 "visible": true,491 "closed": false,492 "archived": false,493 "bookmarked": null,494 "liked": null,495 "tags_descriptions": {},496 "like_count": 0,497 "views": 107,498 "category_id": 1,499 "featured_link": null,500 "has_accepted_answer": false,501 "posters": [502 {503 "extras": "latest single",504 "description": "Original Poster, Most Recent Poster",505 "user": {506 "id": 83562,507 "username": "Rubic_ZHANG",508 "name": "Rubic ZHANG",509 "avatar_template": "/user_avatar/discuss.pytorch.org/rubic_zhang/{size}/76425_2.png",510 "trust_level": 0511 }512 }513 ]514 },515 {516 "fancy_title": "Torch compile comsumes very high gpu memory",517 "id": 222068,518 "title": "Torch compile comsumes very high gpu memory",519 "slug": "torch-compile-comsumes-very-high-gpu-memory",520 "posts_count": 1,521 "reply_count": 0,522 "highest_post_number": 1,523 "image_url": null,524 "created_at": "2025-08-05T07:05:11.692Z",525 "last_posted_at": "2025-08-05T07:05:11.746Z",526 "bumped": true,527 "bumped_at": "2025-08-05T07:05:11.746Z",528 "archetype": "regular",529 "unseen": false,530 "pinned": false,531 "unpinned": null,532 "visible": true,533 "closed": false,534 "archived": false,535 "bookmarked": null,536 "liked": null,537 "tags_descriptions": {},538 "like_count": 0,539 "views": 41,540 "category_id": 1,541 "featured_link": null,542 "has_accepted_answer": false,543 "posters": [544 {545 "extras": "latest single",546 "description": "Original Poster, Most Recent Poster",547 "user": {548 "id": 38501,549 "username": "wadewang",550 "name": "weida wang",551 "avatar_template": "/letter_avatar_proxy/v4/letter/w/85f322/{size}.png",552 "trust_level": 1553 }554 }555 ]556 }557 ],558 "tags_descriptions": {},559 "fancy_title": "On torch.onnx.export()",560 "id": 156882,561 "title": "On torch.onnx.export()",562 "posts_count": 5,563 "created_at": "2022-07-18T13:27:52.462Z",564 "views": 811,565 "reply_count": 4,566 "like_count": 0,567 "last_posted_at": "2022-07-19T04:22:31.469Z",568 "visible": true,569 "closed": false,570 "archived": false,571 "has_summary": false,572 "archetype": "regular",573 "slug": "on-torch-onnx-export",574 "category_id": 1,575 "word_count": 253,576 "deleted_at": null,577 "user_id": 50569,578 "featured_link": null,579 "pinned_globally": false,580 "pinned_at": null,581 "pinned_until": null,582 "image_url": null,583 "slow_mode_seconds": 0,584 "draft": null,585 "draft_key": "topic_156882",586 "draft_sequence": null,587 "unpinned": null,588 "pinned": false,589 "current_post_number": 1,590 "highest_post_number": 5,591 "deleted_by": null,592 "actions_summary": [593 {594 "id": 4,595 "count": 0,596 "hidden": false,597 "can_act": false598 },599 {600 "id": 8,601 "count": 0,602 "hidden": false,603 "can_act": false604 },605 {606 "id": 10,607 "count": 0,608 "hidden": false,609 "can_act": false610 },611 {612 "id": 7,613 "count": 0,614 "hidden": false,615 "can_act": false616 }617 ],618 "chunk_size": 20,619 "bookmarked": false,620 "topic_timer": null,621 "message_bus_last_id": 0,622 "participant_count": 2,623 "show_read_indicator": false,624 "thumbnails": null,625 "slow_mode_enabled_until": null,626 "accepted_answer": {627 "post_number": 4,628 "username": "ptrblck",629 "name": "",630 "excerpt": "No, usually you refer to a change in the actual shape. I.e. in one iteration the input shape could be [1, 1, 1] in the next it could be [2, 3, 4]. \nDropping or adding an entire dimension would usually just fail at a layer input as a specific number of dimensions is expected."631 },632 "can_vote": false,633 "vote_count": 0,634 "user_voted": false,635 "discourse_zendesk_plugin_zendesk_id": null,636 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",637 "details": {638 "can_edit": false,639 "notification_level": 1,640 "participants": [641 {642 "id": 50569,643 "username": "hitbuyi",644 "name": null,645 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png",646 "post_count": 3,647 "primary_group_name": null,648 "flair_name": null,649 "flair_url": null,650 "flair_color": null,651 "flair_bg_color": null,652 "flair_group_id": null,653 "trust_level": 1654 },655 {656 "id": 3534,657 "username": "ptrblck",658 "name": "",659 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",660 "post_count": 2,661 "primary_group_name": null,662 "flair_name": null,663 "flair_url": null,664 "flair_color": null,665 "flair_bg_color": null,666 "flair_group_id": null,667 "admin": true,668 "moderator": true,669 "trust_level": 2670 }671 ],672 "created_by": {673 "id": 50569,674 "username": "hitbuyi",675 "name": null,676 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png"677 },678 "last_poster": {679 "id": 50569,680 "username": "hitbuyi",681 "name": null,682 "avatar_template": "/letter_avatar_proxy/v4/letter/h/ee59a6/{size}.png"683 }684 },685 "bookmarks": []686 },687 {688 "post_stream": {689 "posts": [690 {691 "id": 357264,692 "name": "Apprehensive Oil 284",693 "username": "Apprehensive-oil-284",694 "avatar_template": "/user_avatar/discuss.pytorch.org/apprehensive-oil-284/{size}/51596_2.png",695 "created_at": "2022-07-19T20:07:59.923Z",696 "cooked": "<p>Consider the following code:</p>\n<pre><code class=\"lang-auto\">import time\n\nimport torch\n\n\nif __name__ == '__main__':\n seed = 0\n torch.manual_seed(seed)\n torch.cuda.manual_seed(seed)\n torch.cuda.manual_seed_all(seed)\n\n x = torch.rand(32, 256, 220, 220).cuda()\n\n t = (x.min() - x.max()).to(torch.device(\"cpu\"), non_blocking=True)\n print(t)\n time.sleep(2.)\n print(t)\n</code></pre>\n<p>and it will print:</p>\n<pre><code class=\"lang-auto\">tensor(0.)\ntensor(-1.0000)\n</code></pre>\n<p>as in the first print, the data is not transmitted to host yet. My question is, is there some way to synchronize with it? In particular, is there something I can do with CUDA stream and Event?</p>",697 "post_number": 1,698 "post_type": 1,699 "posts_count": 5,700 "updated_at": "2022-07-19T20:07:59.923Z",701 "reply_count": 0,702 "reply_to_post_number": null,703 "quote_count": 0,704 "incoming_link_count": 1648,705 "reads": 68,706 "readers_count": 67,707 "score": 8218.6,708 "yours": false,709 "topic_id": 157010,710 "topic_slug": "how-to-wait-on-non-blocking-copying-from-gpu-to-cpu",711 "display_username": "Apprehensive Oil 284",712 "primary_group_name": null,713 "flair_name": null,714 "flair_url": null,715 "flair_bg_color": null,716 "flair_color": null,717 "flair_group_id": null,718 "badges_granted": [],719 "version": 1,720 "can_edit": false,721 "can_delete": false,722 "can_recover": false,723 "can_see_hidden_post": false,724 "can_wiki": false,725 "read": true,726 "user_title": null,727 "bookmarked": false,728 "actions_summary": [729 {730 "id": 2,731 "count": 1732 }733 ],734 "moderator": false,735 "admin": false,736 "staff": false,737 "user_id": 57802,738 "hidden": false,739 "trust_level": 1,740 "deleted_at": null,741 "user_deleted": false,742 "edit_reason": null,743 "can_view_edit_history": true,744 "wiki": false,745 "post_url": "/t/how-to-wait-on-non-blocking-copying-from-gpu-to-cpu/157010/1",746 "can_accept_answer": false,747 "can_unaccept_answer": false,748 "accepted_answer": false,749 "topic_accepted_answer": true,750 "can_vote": false751 },752 {753 "id": 357266,754 "name": "",755 "username": "ptrblck",756 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",757 "created_at": "2022-07-19T20:50:42.301Z",758 "cooked": "<p>Which PyTorch version are you using as I cannot reproduce it in the latest release?</p>",759 "post_number": 2,760 "post_type": 1,761 "posts_count": 5,762 "updated_at": "2022-07-19T20:50:42.301Z",763 "reply_count": 1,764 "reply_to_post_number": null,765 "quote_count": 0,766 "incoming_link_count": 17,767 "reads": 65,768 "readers_count": 64,769 "score": 103.0,770 "yours": false,771 "topic_id": 157010,772 "topic_slug": "how-to-wait-on-non-blocking-copying-from-gpu-to-cpu",773 "display_username": "",774 "primary_group_name": null,775 "flair_name": null,776 "flair_url": null,777 "flair_bg_color": null,778 "flair_color": null,779 "flair_group_id": null,780 "badges_granted": [],781 "version": 1,782 "can_edit": false,783 "can_delete": false,784 "can_recover": false,785 "can_see_hidden_post": false,786 "can_wiki": false,787 "read": true,788 "user_title": "",789 "bookmarked": false,790 "actions_summary": [],791 "moderator": true,792 "admin": true,793 "staff": true,794 "user_id": 3534,795 "hidden": false,796 "trust_level": 2,797 "deleted_at": null,798 "user_deleted": false,799 "edit_reason": null,800 "can_view_edit_history": true,801 "wiki": false,802 "post_url": "/t/how-to-wait-on-non-blocking-copying-from-gpu-to-cpu/157010/2",803 "can_accept_answer": false,804 "can_unaccept_answer": false,805 "accepted_answer": false,806 "topic_accepted_answer": true807 },808 {809 "id": 357307,810 "name": "Apprehensive Oil 284",811 "username": "Apprehensive-oil-284",812 "avatar_template": "/user_avatar/discuss.pytorch.org/apprehensive-oil-284/{size}/51596_2.png",813 "created_at": "2022-07-20T03:08:13.879Z",814 "cooked": "<p>maybe that’s because I have my GPU on a slow PCIE x4 link, and thus slowing down the transmission. Maybe you can increase the size of x?</p>\n<p>I’m using 1.12</p>",815 "post_number": 3,816 "post_type": 1,817 "posts_count": 5,818 "updated_at": "2022-07-20T03:08:13.879Z",819 "reply_count": 1,820 "reply_to_post_number": 2,821 "quote_count": 0,822 "incoming_link_count": 33,823 "reads": 68,824 "readers_count": 67,825 "score": 183.6,826 "yours": false,827 "topic_id": 157010,828 "topic_slug": "how-to-wait-on-non-blocking-copying-from-gpu-to-cpu",829 "display_username": "Apprehensive Oil 284",830 "primary_group_name": null,831 "flair_name": null,832 "flair_url": null,833 "flair_bg_color": null,834 "flair_color": null,835 "flair_group_id": null,836 "badges_granted": [],837 "version": 1,838 "can_edit": false,839 "can_delete": false,840 "can_recover": false,841 "can_see_hidden_post": false,842 "can_wiki": false,843 "read": true,844 "user_title": null,845 "reply_to_user": {846 "id": 3534,847 "username": "ptrblck",848 "name": "",849 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"850 },851 "bookmarked": false,852 "actions_summary": [],853 "moderator": false,854 "admin": false,855 "staff": false,856 "user_id": 57802,857 "hidden": false,858 "trust_level": 1,859 "deleted_at": null,860 "user_deleted": false,861 "edit_reason": null,862 "can_view_edit_history": true,863 "wiki": false,864 "post_url": "/t/how-to-wait-on-non-blocking-copying-from-gpu-to-cpu/157010/3",865 "can_accept_answer": false,866 "can_unaccept_answer": false,867 "accepted_answer": false,868 "topic_accepted_answer": true869 },870 {871 "id": 357322,872 "name": "",873 "username": "ptrblck",874 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",875 "created_at": "2022-07-20T05:05:00.289Z",876 "cooked": "<p>Yes, you are right and you would need to synchronize the current stream e.g. via:</p>\n<pre><code class=\"lang-python\">if __name__ == '__main__':\n seed = 0\n torch.manual_seed(seed)\n torch.cuda.manual_seed(seed)\n torch.cuda.manual_seed_all(seed)\n \n stream = torch.cuda.current_stream()\n\n x = torch.rand(32, 256, 220, 220).cuda()\n\n t = (x.min() - x.max()).to(torch.device(\"cpu\"), non_blocking=True)\n print(stream.query()) # False - work not done yet\n stream.synchronize() # wait for stream to finish the work\n print(t)\n \n time.sleep(2.)\n print(stream.query()) # True - work done\n print(t)\n</code></pre>",877 "post_number": 4,878 "post_type": 1,879 "posts_count": 5,880 "updated_at": "2022-07-20T05:05:00.289Z",881 "reply_count": 0,882 "reply_to_post_number": 3,883 "quote_count": 0,884 "incoming_link_count": 67,885 "reads": 67,886 "readers_count": 66,887 "score": 378.4,888 "yours": false,889 "topic_id": 157010,890 "topic_slug": "how-to-wait-on-non-blocking-copying-from-gpu-to-cpu",891 "display_username": "",892 "primary_group_name": null,893 "flair_name": null,894 "flair_url": null,895 "flair_bg_color": null,896 "flair_color": null,897 "flair_group_id": null,898 "badges_granted": [],899 "version": 1,900 "can_edit": false,901 "can_delete": false,902 "can_recover": false,903 "can_see_hidden_post": false,904 "can_wiki": false,905 "link_counts": [906 {907 "url": "https://discuss.pytorch.org/t/should-we-set-non-blocking-to-true/38234/27",908 "internal": true,909 "reflection": true,910 "title": "Should we set non_blocking to True?",911 "clicks": 12912 }913 ],914 "read": true,915 "user_title": "",916 "reply_to_user": {917 "id": 57802,918 "username": "Apprehensive-oil-284",919 "name": "Apprehensive Oil 284",920 "avatar_template": "/user_avatar/discuss.pytorch.org/apprehensive-oil-284/{size}/51596_2.png"921 },922 "bookmarked": false,923 "actions_summary": [924 {925 "id": 2,926 "count": 2927 }928 ],929 "moderator": true,930 "admin": true,931 "staff": true,932 "user_id": 3534,933 "hidden": false,934 "trust_level": 2,935 "deleted_at": null,936 "user_deleted": false,937 "edit_reason": null,938 "can_view_edit_history": true,939 "wiki": false,940 "post_url": "/t/how-to-wait-on-non-blocking-copying-from-gpu-to-cpu/157010/4",941 "can_accept_answer": false,942 "can_unaccept_answer": false,943 "accepted_answer": true,944 "topic_accepted_answer": true945 },946 {947 "id": 357331,948 "name": "Apprehensive Oil 284",949 "username": "Apprehensive-oil-284",950 "avatar_template": "/user_avatar/discuss.pytorch.org/apprehensive-oil-284/{size}/51596_2.png",951 "created_at": "2022-07-20T05:57:27.371Z",952 "cooked": "<p>Thank you. Yes for the record, here is another example that uses cuda events:</p>\n<pre><code class=\"lang-auto\">import time\n\nimport torch\n\nclass Timer:\n def __init__(self):\n self.start = time.monotonic()\n\n def __call__(self):\n k = time.monotonic()\n v = k - self.start\n self.start = k\n return v\n\nif __name__ == '__main__':\n\n\n seed = 0\n torch.manual_seed(seed)\n torch.cuda.manual_seed(seed)\n torch.cuda.manual_seed_all(seed)\n\n stream = torch.cuda.Stream()\n\n with torch.cuda.stream(stream):\n # print(torch.cuda.current_stream())\n\n x = torch.ones((32, 256, 220, 220), pin_memory=True)\n tim = Timer() \n c = torch.empty((2, 32, 256, 220, 220), device='cuda')\n print(tim())\n # x = x.to(torch.device('cuda'), non_blocking=True)\n print(tim())\n c[0, :, :, :, :].copy_(x, non_blocking=True)\n print(tim())\n\n # t = (x.min() - x.max()).to(torch.device(\"cpu\"), non_blocking=True)\n\n t = c[0].min()\n print('mark0', tim())\n t = t.to('cpu', non_blocking=True)\n print('mark', tim())\n ev = torch.cuda.Event()\n ev.record()\n # print(torch.cuda.current_stream())\n print(tim())\n print(t)\n ev.synchronize()\n print(tim())\n print(t)\n</code></pre>\n<p>You will observe that only the last operation <code>ev.synchronize</code> takes substantial amount of time. All other operations are almost instant.</p>",953 "post_number": 5,954 "post_type": 1,955 "posts_count": 5,956 "updated_at": "2022-07-20T05:57:27.371Z",957 "reply_count": 0,958 "reply_to_post_number": null,959 "quote_count": 0,960 "incoming_link_count": 44,961 "reads": 64,962 "readers_count": 63,963 "score": 247.8,964 "yours": false,965 "topic_id": 157010,966 "topic_slug": "how-to-wait-on-non-blocking-copying-from-gpu-to-cpu",967 "display_username": "Apprehensive Oil 284",968 "primary_group_name": null,969 "flair_name": null,970 "flair_url": null,971 "flair_bg_color": null,972 "flair_color": null,973 "flair_group_id": null,974 "badges_granted": [],975 "version": 1,976 "can_edit": false,977 "can_delete": false,978 "can_recover": false,979 "can_see_hidden_post": false,980 "can_wiki": false,981 "read": true,982 "user_title": null,983 "bookmarked": false,984 "actions_summary": [985 {986 "id": 2,987 "count": 1988 }989 ],990 "moderator": false,991 "admin": false,992 "staff": false,993 "user_id": 57802,994 "hidden": false,995 "trust_level": 1,996 "deleted_at": null,997 "user_deleted": false,998 "edit_reason": null,999 "can_view_edit_history": true,1000 "wiki": false,1001 "post_url": "/t/how-to-wait-on-non-blocking-copying-from-gpu-to-cpu/157010/5",1002 "can_accept_answer": false,1003 "can_unaccept_answer": false,1004 "accepted_answer": false,1005 "topic_accepted_answer": true1006 }1007 ],1008 "stream": [1009 357264,1010 357266,1011 357307,1012 357322,1013 3573311014 ]1015 },1016 "timeline_lookup": [1017 [1018 1,1019 11941020 ]1021 ],1022 "suggested_topics": [1023 {1024 "fancy_title": "Pickling entire dataloader when n_workers > 0 causing GCP issues",1025 "id": 217100,1026 "title": "Pickling entire dataloader when n_workers > 0 causing GCP issues",1027 "slug": "pickling-entire-dataloader-when-n-workers-0-causing-gcp-issues",1028 "posts_count": 1,1029 "reply_count": 0,1030 "highest_post_number": 1,1031 "image_url": null,1032 "created_at": "2025-02-24T15:08:21.491Z",1033 "last_posted_at": "2025-02-24T15:08:21.530Z",1034 "bumped": true,1035 "bumped_at": "2025-02-24T15:08:21.530Z",1036 "archetype": "regular",1037 "unseen": false,1038 "pinned": false,1039 "unpinned": null,1040 "visible": true,1041 "closed": false,1042 "archived": false,1043 "bookmarked": null,1044 "liked": null,1045 "tags_descriptions": {},1046 "like_count": 0,1047 "views": 34,1048 "category_id": 37,1049 "featured_link": null,1050 "has_accepted_answer": false,1051 "posters": [1052 {1053 "extras": "latest single",1054 "description": "Original Poster, Most Recent Poster",1055 "user": {1056 "id": 62809,1057 "username": "JLenz",1058 "name": "Julian Lenz",1059 "avatar_template": "/user_avatar/discuss.pytorch.org/jlenz/{size}/56737_2.png",1060 "trust_level": 11061 }1062 }1063 ]1064 },1065 {1066 "fancy_title": "Question about pin_memory and Dataloaders",1067 "id": 213280,1068 "title": "Question about pin_memory and Dataloaders",1069 "slug": "question-about-pin-memory-and-dataloaders",1070 "posts_count": 2,1071 "reply_count": 0,1072 "highest_post_number": 2,1073 "image_url": null,1074 "created_at": "2024-11-21T16:18:02.229Z",1075 "last_posted_at": "2024-11-21T19:31:53.824Z",1076 "bumped": true,1077 "bumped_at": "2024-11-21T19:31:53.824Z",1078 "archetype": "regular",1079 "unseen": false,1080 "pinned": false,1081 "unpinned": null,1082 "visible": true,1083 "closed": false,1084 "archived": false,1085 "bookmarked": null,1086 "liked": null,1087 "tags_descriptions": {},1088 "like_count": 0,1089 "views": 76,1090 "category_id": 37,1091 "featured_link": null,1092 "has_accepted_answer": false,1093 "posters": [1094 {1095 "extras": null,1096 "description": "Original Poster",1097 "user": {1098 "id": 79059,1099 "username": "Anthony_Weaver",1100 "name": "Anthony Weaver",1101 "avatar_template": "/user_avatar/discuss.pytorch.org/anthony_weaver/{size}/72576_2.png",1102 "trust_level": 01103 }1104 },1105 {1106 "extras": "latest",1107 "description": "Most Recent Poster",1108 "user": {1109 "id": 3534,1110 "username": "ptrblck",1111 "name": "",1112 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1113 "admin": true,1114 "moderator": true,1115 "trust_level": 21116 }1117 }1118 ]1119 },1120 {1121 "fancy_title": "Imbalance in training data",1122 "id": 217076,1123 "title": "Imbalance in training data",1124 "slug": "imbalance-in-training-data",1125 "posts_count": 3,1126 "reply_count": 0,1127 "highest_post_number": 3,1128 "image_url": null,1129 "created_at": "2025-02-24T04:58:51.582Z",1130 "last_posted_at": "2025-03-01T12:04:58.647Z",1131 "bumped": true,1132 "bumped_at": "2025-03-01T12:04:58.647Z",1133 "archetype": "regular",1134 "unseen": false,1135 "pinned": false,1136 "unpinned": null,1137 "visible": true,1138 "closed": false,1139 "archived": false,1140 "bookmarked": null,1141 "liked": null,1142 "tags_descriptions": {},1143 "like_count": 0,1144 "views": 147,1145 "category_id": 37,1146 "featured_link": null,1147 "has_accepted_answer": false,1148 "posters": [1149 {1150 "extras": null,1151 "description": "Original Poster",1152 "user": {1153 "id": 82885,1154 "username": "Parthiv_Narayan",1155 "name": "Parthiv",1156 "avatar_template": "/user_avatar/discuss.pytorch.org/parthiv_narayan/{size}/75840_2.png",1157 "trust_level": 01158 }1159 },1160 {1161 "extras": null,1162 "description": "Frequent Poster",1163 "user": {1164 "id": 82888,1165 "username": "manan",1166 "name": "",1167 "avatar_template": "/letter_avatar_proxy/v4/letter/m/51bf81/{size}.png",1168 "trust_level": 01169 }1170 },1171 {1172 "extras": "latest",1173 "description": "Most Recent Poster",1174 "user": {1175 "id": 41458,1176 "username": "J_Johnson",1177 "name": "J Johnson",1178 "avatar_template": "/user_avatar/discuss.pytorch.org/j_johnson/{size}/55494_2.png",1179 "trust_level": 21180 }1181 }1182 ]1183 },1184 {1185 "fancy_title": "Why doesn’t torch have a memmap-like function?",1186 "id": 215060,1187 "title": "Why doesn't torch have a memmap-like function?",1188 "slug": "why-doesnt-torch-have-a-memmap-like-function",1189 "posts_count": 2,1190 "reply_count": 0,1191 "highest_post_number": 2,1192 "image_url": null,1193 "created_at": "2025-01-07T09:54:34.142Z",1194 "last_posted_at": "2025-01-07T11:11:32.025Z",1195 "bumped": true,1196 "bumped_at": "2025-01-07T11:11:32.025Z",1197 "archetype": "regular",1198 "unseen": false,1199 "pinned": false,1200 "unpinned": null,