Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 261863,7 "name": "",8 "username": "111439",9 "avatar_template": "/user_avatar/discuss.pytorch.org/111439/{size}/29874_2.png",10 "created_at": "2021-02-05T16:33:13.830Z",11 "cooked": "<p>Good day,<br>\nI am wondering if there are any best practices on how to use the cuda memory effectively or how to overcome the out of memory error if it is possible (except for reducing the batch size or the complexity of the model)?</p>\n<p>The thing is, I am stacking the output of the neural network to put it to the consecutive layers and I receive ‘cuda out of memory’ error.<br>\nMy input size is [1,1,128,256,256], batch size=1. I have 40gb of VRAM. Without this stacking step the simpler model took about 26gb of VRAM. With the stacking step, the out of memory error occurs on the 91 iteration of this code</p>\n<pre><code class=\"lang-auto\">def stack(self, x):\n output = torch.zeros(x.shape,dtype=torch.float16)\n for i in range(x.shape[2]):\n print(i)\n output[:,:,i,:,:] = neural_net(x[:,:,i,:,:])\n</code></pre>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 1,15 "updated_at": "2021-02-05T16:40:00.601Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 28,20 "reads": 6,21 "readers_count": 5,22 "score": 141.2,23 "yours": false,24 "topic_id": 111051,25 "topic_slug": "memory-usage-best-practices",26 "display_username": "",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": 40101,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/memory-usage-best-practices/111051/1",56 "can_accept_answer": false,57 "can_unaccept_answer": false,58 "accepted_answer": false,59 "topic_accepted_answer": null,60 "can_vote": false61 }62 ],63 "stream": [64 26186365 ]66 },67 "timeline_lookup": [68 [69 1,70 172371 ]72 ],73 "suggested_topics": [74 {75 "fancy_title": "What is wrong with my ViT",76 "id": 212409,77 "title": "What is wrong with my ViT",78 "slug": "what-is-wrong-with-my-vit",79 "posts_count": 1,80 "reply_count": 0,81 "highest_post_number": 1,82 "image_url": null,83 "created_at": "2024-11-01T13:16:28.397Z",84 "last_posted_at": "2024-11-01T13:16:28.454Z",85 "bumped": true,86 "bumped_at": "2024-11-01T13:16:28.454Z",87 "archetype": "regular",88 "unseen": false,89 "pinned": false,90 "unpinned": null,91 "visible": true,92 "closed": false,93 "archived": false,94 "bookmarked": null,95 "liked": null,96 "tags_descriptions": {},97 "like_count": 0,98 "views": 98,99 "category_id": 5,100 "featured_link": null,101 "has_accepted_answer": false,102 "posters": [103 {104 "extras": "latest single",105 "description": "Original Poster, Most Recent Poster",106 "user": {107 "id": 74031,108 "username": "amm90",109 "name": "Ahmad Mustapha",110 "avatar_template": "/letter_avatar_proxy/v4/letter/a/9de0a6/{size}.png",111 "trust_level": 0112 }113 }114 ]115 },116 {117 "fancy_title": "RuntimeError: Unsupported value kind: Tensor",118 "id": 218267,119 "title": "RuntimeError: Unsupported value kind: Tensor",120 "slug": "runtimeerror-unsupported-value-kind-tensor",121 "posts_count": 1,122 "reply_count": 0,123 "highest_post_number": 1,124 "image_url": null,125 "created_at": "2025-03-25T21:20:15.941Z",126 "last_posted_at": "2025-03-25T21:20:15.982Z",127 "bumped": true,128 "bumped_at": "2025-03-25T21:20:15.982Z",129 "archetype": "regular",130 "unseen": false,131 "pinned": false,132 "unpinned": null,133 "visible": true,134 "closed": false,135 "archived": false,136 "bookmarked": null,137 "liked": null,138 "tags_descriptions": {},139 "like_count": 0,140 "views": 64,141 "category_id": 5,142 "featured_link": null,143 "has_accepted_answer": false,144 "posters": [145 {146 "extras": "latest single",147 "description": "Original Poster, Most Recent Poster",148 "user": {149 "id": 82436,150 "username": "ettu",151 "name": "",152 "avatar_template": "/user_avatar/discuss.pytorch.org/ettu/{size}/75419_2.png",153 "trust_level": 1154 }155 }156 ]157 },158 {159 "fancy_title": "`nms` and `batched_nms` are not working properly for predictions made by pretrained `ssd300_vgg16`",160 "id": 216749,161 "title": "`nms` and `batched_nms` are not working properly for predictions made by pretrained `ssd300_vgg16`",162 "slug": "nms-and-batched-nms-are-not-working-properly-for-predictions-made-by-pretrained-ssd300-vgg16",163 "posts_count": 3,164 "reply_count": 1,165 "highest_post_number": 3,166 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/f/0/f0670295634a434f74dfb79b25ecb6241be08085.png",167 "created_at": "2025-02-16T18:11:06.150Z",168 "last_posted_at": "2025-04-09T04:23:37.689Z",169 "bumped": true,170 "bumped_at": "2025-04-09T04:23:37.689Z",171 "archetype": "regular",172 "unseen": false,173 "pinned": false,174 "unpinned": null,175 "visible": true,176 "closed": false,177 "archived": false,178 "bookmarked": null,179 "liked": null,180 "tags_descriptions": {},181 "like_count": 0,182 "views": 63,183 "category_id": 5,184 "featured_link": null,185 "has_accepted_answer": false,186 "posters": [187 {188 "extras": "latest",189 "description": "Original Poster, Most Recent Poster",190 "user": {191 "id": 82180,192 "username": "Amit_Sur",193 "name": "Amit Sur",194 "avatar_template": "/user_avatar/discuss.pytorch.org/amit_sur/{size}/75195_2.png",195 "trust_level": 1196 }197 },198 {199 "extras": null,200 "description": "Frequent Poster",201 "user": {202 "id": 3580,203 "username": "JigyasaKatrolia",204 "name": "Jigyasa Katrolia",205 "avatar_template": "/letter_avatar_proxy/v4/letter/j/b19c9b/{size}.png",206 "trust_level": 1207 }208 }209 ]210 },211 {212 "fancy_title": "CNN loss is not decreasing",213 "id": 218017,214 "title": "CNN loss is not decreasing",215 "slug": "cnn-loss-is-not-decreasing",216 "posts_count": 1,217 "reply_count": 0,218 "highest_post_number": 1,219 "image_url": null,220 "created_at": "2025-03-19T09:14:16.252Z",221 "last_posted_at": "2025-03-19T09:14:16.295Z",222 "bumped": true,223 "bumped_at": "2025-03-19T09:14:16.295Z",224 "archetype": "regular",225 "unseen": false,226 "pinned": false,227 "unpinned": null,228 "visible": true,229 "closed": false,230 "archived": false,231 "bookmarked": null,232 "liked": null,233 "tags_descriptions": {},234 "like_count": 0,235 "views": 63,236 "category_id": 5,237 "featured_link": null,238 "has_accepted_answer": false,239 "posters": [240 {241 "extras": "latest single",242 "description": "Original Poster, Most Recent Poster",243 "user": {244 "id": 83357,245 "username": "Saqlain_Afroz",246 "name": "Saqlain Afroz",247 "avatar_template": "/user_avatar/discuss.pytorch.org/saqlain_afroz/{size}/76244_2.png",248 "trust_level": 0249 }250 }251 ]252 },253 {254 "fancy_title": "We are not getting gradients after custom loss creation",255 "id": 220288,256 "title": "We are not getting gradients after custom loss creation",257 "slug": "we-are-not-getting-gradients-after-custom-loss-creation",258 "posts_count": 2,259 "reply_count": 0,260 "highest_post_number": 2,261 "image_url": null,262 "created_at": "2025-05-23T21:09:11.453Z",263 "last_posted_at": "2025-05-23T21:19:33.489Z",264 "bumped": true,265 "bumped_at": "2025-05-23T21:19:33.489Z",266 "archetype": "regular",267 "unseen": false,268 "pinned": false,269 "unpinned": null,270 "visible": true,271 "closed": false,272 "archived": false,273 "bookmarked": null,274 "liked": null,275 "tags_descriptions": {},276 "like_count": 0,277 "views": 40,278 "category_id": 5,279 "featured_link": null,280 "has_accepted_answer": false,281 "posters": [282 {283 "extras": null,284 "description": "Original Poster",285 "user": {286 "id": 32561,287 "username": "Filippo_Portera",288 "name": "Filippo Portera",289 "avatar_template": "/user_avatar/discuss.pytorch.org/filippo_portera/{size}/11874_2.png",290 "trust_level": 1291 }292 },293 {294 "extras": "latest",295 "description": "Most Recent Poster",296 "user": {297 "id": 3534,298 "username": "ptrblck",299 "name": "",300 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",301 "admin": true,302 "moderator": true,303 "trust_level": 2304 }305 }306 ]307 }308 ],309 "tags_descriptions": {},310 "fancy_title": "Memory usage, best practices",311 "id": 111051,312 "title": "Memory usage, best practices",313 "posts_count": 1,314 "created_at": "2021-02-05T16:33:13.781Z",315 "views": 358,316 "reply_count": 0,317 "like_count": 0,318 "last_posted_at": "2021-02-05T16:33:13.830Z",319 "visible": true,320 "closed": false,321 "archived": false,322 "has_summary": false,323 "archetype": "regular",324 "slug": "memory-usage-best-practices",325 "category_id": 5,326 "word_count": 143,327 "deleted_at": null,328 "user_id": 40101,329 "featured_link": null,330 "pinned_globally": false,331 "pinned_at": null,332 "pinned_until": null,333 "image_url": null,334 "slow_mode_seconds": 0,335 "draft": null,336 "draft_key": "topic_111051",337 "draft_sequence": null,338 "unpinned": null,339 "pinned": false,340 "current_post_number": 1,341 "highest_post_number": 1,342 "deleted_by": null,343 "actions_summary": [344 {345 "id": 4,346 "count": 0,347 "hidden": false,348 "can_act": false349 },350 {351 "id": 8,352 "count": 0,353 "hidden": false,354 "can_act": false355 },356 {357 "id": 10,358 "count": 0,359 "hidden": false,360 "can_act": false361 },362 {363 "id": 7,364 "count": 0,365 "hidden": false,366 "can_act": false367 }368 ],369 "chunk_size": 20,370 "bookmarked": false,371 "topic_timer": null,372 "message_bus_last_id": 0,373 "participant_count": 1,374 "show_read_indicator": false,375 "thumbnails": null,376 "slow_mode_enabled_until": null,377 "can_vote": false,378 "vote_count": 0,379 "user_voted": false,380 "discourse_zendesk_plugin_zendesk_id": null,381 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",382 "details": {383 "can_edit": false,384 "notification_level": 1,385 "participants": [386 {387 "id": 40101,388 "username": "111439",389 "name": "",390 "avatar_template": "/user_avatar/discuss.pytorch.org/111439/{size}/29874_2.png",391 "post_count": 1,392 "primary_group_name": null,393 "flair_name": null,394 "flair_url": null,395 "flair_color": null,396 "flair_bg_color": null,397 "flair_group_id": null,398 "trust_level": 1399 }400 ],401 "created_by": {402 "id": 40101,403 "username": "111439",404 "name": "",405 "avatar_template": "/user_avatar/discuss.pytorch.org/111439/{size}/29874_2.png"406 },407 "last_poster": {408 "id": 40101,409 "username": "111439",410 "name": "",411 "avatar_template": "/user_avatar/discuss.pytorch.org/111439/{size}/29874_2.png"412 }413 },414 "bookmarks": []415 },416 {417 "post_stream": {418 "posts": [419 {420 "id": 261861,421 "name": "",422 "username": "bergentruckung",423 "avatar_template": "/letter_avatar_proxy/v4/letter/b/958977/{size}.png",424 "created_at": "2021-02-05T16:27:21.382Z",425 "cooked": "<p>Hello,</p>\n<p>Is there a probable roadmap for when we can expect pytorch stable release to have support for CUDA 11.1? I have pytorch-1.7.1 (built for CUDA 11.0) installed on a box with CUDA 11.1, but I’m a bit paranoid if there could be potential bugs lurking underneath. This may just be a duplicate of <a href=\"https://github.com/pytorch/pytorch/issues/47109\" class=\"inline-onebox\" rel=\"noopener nofollow ugc\">Pytorch 1.7/Cuda 11.1 binaries · Issue #47109 · pytorch/pytorch · GitHub</a>, but a rough timeline is much appreciated.</p>\n<p>Thanks,<br>\nbergentruckung</p>",426 "post_number": 1,427 "post_type": 1,428 "posts_count": 1,429 "updated_at": "2021-02-05T16:27:21.382Z",430 "reply_count": 0,431 "reply_to_post_number": null,432 "quote_count": 0,433 "incoming_link_count": 214,434 "reads": 8,435 "readers_count": 7,436 "score": 1071.6,437 "yours": false,438 "topic_id": 111050,439 "topic_slug": "cuda-11-1-support-for-pytorch",440 "display_username": "",441 "primary_group_name": null,442 "flair_name": null,443 "flair_url": null,444 "flair_bg_color": null,445 "flair_color": null,446 "flair_group_id": null,447 "badges_granted": [],448 "version": 1,449 "can_edit": false,450 "can_delete": false,451 "can_recover": false,452 "can_see_hidden_post": false,453 "can_wiki": false,454 "link_counts": [455 {456 "url": "https://github.com/pytorch/pytorch/issues/47109",457 "internal": false,458 "reflection": false,459 "title": "Pytorch 1.7/Cuda 11.1 binaries · Issue #47109 · pytorch/pytorch · GitHub",460 "clicks": 26461 }462 ],463 "read": true,464 "user_title": null,465 "bookmarked": false,466 "actions_summary": [],467 "moderator": false,468 "admin": false,469 "staff": false,470 "user_id": 41794,471 "hidden": false,472 "trust_level": 0,473 "deleted_at": null,474 "user_deleted": false,475 "edit_reason": null,476 "can_view_edit_history": true,477 "wiki": false,478 "post_url": "/t/cuda-11-1-support-for-pytorch/111050/1",479 "can_accept_answer": false,480 "can_unaccept_answer": false,481 "accepted_answer": false,482 "topic_accepted_answer": null,483 "can_vote": false484 }485 ],486 "stream": [487 261861488 ]489 },490 "timeline_lookup": [491 [492 1,493 1723494 ]495 ],496 "suggested_topics": [497 {498 "fancy_title": "How to create a DataLoader with nested tensors",499 "id": 216165,500 "title": "How to create a DataLoader with nested tensors",501 "slug": "how-to-create-a-dataloader-with-nested-tensors",502 "posts_count": 1,503 "reply_count": 0,504 "highest_post_number": 1,505 "image_url": null,506 "created_at": "2025-02-03T06:25:04.602Z",507 "last_posted_at": "2025-02-03T06:25:04.651Z",508 "bumped": true,509 "bumped_at": "2025-02-03T06:25:04.651Z",510 "archetype": "regular",511 "unseen": false,512 "pinned": false,513 "unpinned": null,514 "visible": true,515 "closed": false,516 "archived": false,517 "bookmarked": null,518 "liked": null,519 "tags_descriptions": {},520 "like_count": 0,521 "views": 73,522 "category_id": 1,523 "featured_link": null,524 "has_accepted_answer": false,525 "posters": [526 {527 "extras": "latest single",528 "description": "Original Poster, Most Recent Poster",529 "user": {530 "id": 82450,531 "username": "Parijat_Das",532 "name": "Parijat Das",533 "avatar_template": "/user_avatar/discuss.pytorch.org/parijat_das/{size}/75436_2.png",534 "trust_level": 1535 }536 }537 ]538 },539 {540 "fancy_title": "A problem about cuda graph when input and output are the same",541 "id": 215715,542 "title": "A problem about cuda graph when input and output are the same",543 "slug": "a-problem-about-cuda-graph-when-input-and-output-are-the-same",544 "posts_count": 6,545 "reply_count": 3,546 "highest_post_number": 6,547 "image_url": null,548 "created_at": "2025-01-22T12:47:30.513Z",549 "last_posted_at": "2025-01-23T20:04:21.268Z",550 "bumped": true,551 "bumped_at": "2025-01-23T20:04:21.268Z",552 "archetype": "regular",553 "unseen": false,554 "pinned": false,555 "unpinned": null,556 "visible": true,557 "closed": false,558 "archived": false,559 "bookmarked": null,560 "liked": null,561 "tags_descriptions": {},562 "like_count": 1,563 "views": 85,564 "category_id": 1,565 "featured_link": null,566 "has_accepted_answer": false,567 "posters": [568 {569 "extras": null,570 "description": "Original Poster",571 "user": {572 "id": 79055,573 "username": "hello_e",574 "name": "hhhh",575 "avatar_template": "/letter_avatar_proxy/v4/letter/h/f9ae1b/{size}.png",576 "trust_level": 1577 }578 },579 {580 "extras": "latest",581 "description": "Most Recent Poster",582 "user": {583 "id": 3534,584 "username": "ptrblck",585 "name": "",586 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",587 "admin": true,588 "moderator": true,589 "trust_level": 2590 }591 }592 ]593 },594 {595 "fancy_title": "Nvrtc error with CUDA",596 "id": 213804,597 "title": "Nvrtc error with CUDA",598 "slug": "nvrtc-error-with-cuda",599 "posts_count": 4,600 "reply_count": 1,601 "highest_post_number": 4,602 "image_url": null,603 "created_at": "2024-12-04T16:22:20.635Z",604 "last_posted_at": "2025-01-24T10:53:05.066Z",605 "bumped": true,606 "bumped_at": "2025-01-24T10:53:05.066Z",607 "archetype": "regular",608 "unseen": false,609 "pinned": false,610 "unpinned": null,611 "visible": true,612 "closed": false,613 "archived": false,614 "bookmarked": null,615 "liked": null,616 "tags_descriptions": {},617 "like_count": 0,618 "views": 1112,619 "category_id": 1,620 "featured_link": null,621 "has_accepted_answer": false,622 "posters": [623 {624 "extras": null,625 "description": "Original Poster",626 "user": {627 "id": 50209,628 "username": "Laya1",629 "name": "",630 "avatar_template": "/letter_avatar_proxy/v4/letter/l/8c91f0/{size}.png",631 "trust_level": 1632 }633 },634 {635 "extras": null,636 "description": "Frequent Poster",637 "user": {638 "id": 3534,639 "username": "ptrblck",640 "name": "",641 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",642 "admin": true,643 "moderator": true,644 "trust_level": 2645 }646 },647 {648 "extras": "latest",649 "description": "Most Recent Poster",650 "user": {651 "id": 44509,652 "username": "Mole_Turner",653 "name": "Mole Turner",654 "avatar_template": "/user_avatar/discuss.pytorch.org/mole_turner/{size}/37337_2.png",655 "trust_level": 2656 }657 }658 ]659 },660 {661 "fancy_title": "torch.cudnn.benchmark=True picks slower algorithm",662 "id": 215906,663 "title": "torch.cudnn.benchmark=True picks slower algorithm",664 "slug": "torch-cudnn-benchmark-true-picks-slower-algorithm",665 "posts_count": 7,666 "reply_count": 4,667 "highest_post_number": 7,668 "image_url": null,669 "created_at": "2025-01-26T21:29:30.709Z",670 "last_posted_at": "2025-01-29T05:02:54.062Z",671 "bumped": true,672 "bumped_at": "2025-01-29T11:33:31.111Z",673 "archetype": "regular",674 "unseen": false,675 "pinned": false,676 "unpinned": null,677 "visible": true,678 "closed": false,679 "archived": false,680 "bookmarked": null,681 "liked": null,682 "tags_descriptions": {},683 "like_count": 1,684 "views": 161,685 "category_id": 1,686 "featured_link": null,687 "has_accepted_answer": false,688 "posters": [689 {690 "extras": "latest",691 "description": "Original Poster, Most Recent Poster",692 "user": {693 "id": 82331,694 "username": "nkem",695 "name": "Nico",696 "avatar_template": "/user_avatar/discuss.pytorch.org/nkem/{size}/75310_2.png",697 "trust_level": 1698 }699 },700 {701 "extras": null,702 "description": "Frequent Poster",703 "user": {704 "id": 3534,705 "username": "ptrblck",706 "name": "",707 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",708 "admin": true,709 "moderator": true,710 "trust_level": 2711 }712 },713 {714 "extras": null,715 "description": "Frequent Poster",716 "user": {717 "id": 35275,718 "username": "eqy",719 "name": "",720 "avatar_template": "/user_avatar/discuss.pytorch.org/eqy/{size}/46233_2.png",721 "trust_level": 2722 }723 }724 ]725 },726 {727 "fancy_title": "Apply linalg.solve if matrix is not singular, return arbitrary vector otherwise",728 "id": 218914,729 "title": "Apply linalg.solve if matrix is not singular, return arbitrary vector otherwise",730 "slug": "apply-linalg-solve-if-matrix-is-not-singular-return-arbitrary-vector-otherwise",731 "posts_count": 2,732 "reply_count": 0,733 "highest_post_number": 2,734 "image_url": null,735 "created_at": "2025-04-09T17:23:08.540Z",736 "last_posted_at": "2025-04-10T00:59:42.916Z",737 "bumped": true,738 "bumped_at": "2025-04-10T00:59:42.916Z",739 "archetype": "regular",740 "unseen": false,741 "pinned": false,742 "unpinned": null,743 "visible": true,744 "closed": false,745 "archived": false,746 "bookmarked": null,747 "liked": null,748 "tags_descriptions": {},749 "like_count": 0,750 "views": 68,751 "category_id": 1,752 "featured_link": null,753 "has_accepted_answer": false,754 "posters": [755 {756 "extras": null,757 "description": "Original Poster",758 "user": {759 "id": 70117,760 "username": "Stingpie_52",761 "name": "Stingpie 52",762 "avatar_template": "/user_avatar/discuss.pytorch.org/stingpie_52/{size}/62527_2.png",763 "trust_level": 1764 }765 },766 {767 "extras": "latest",768 "description": "Most Recent Poster",769 "user": {770 "id": 18088,771 "username": "KFrank",772 "name": "K. Frank",773 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",774 "trust_level": 2775 }776 }777 ]778 }779 ],780 "tags_descriptions": {},781 "fancy_title": "CUDA 11.1 support for pytorch",782 "id": 111050,783 "title": "CUDA 11.1 support for pytorch",784 "posts_count": 1,785 "created_at": "2021-02-05T16:27:21.328Z",786 "views": 830,787 "reply_count": 0,788 "like_count": 0,789 "last_posted_at": "2021-02-05T16:27:21.382Z",790 "visible": true,791 "closed": false,792 "archived": false,793 "has_summary": false,794 "archetype": "regular",795 "slug": "cuda-11-1-support-for-pytorch",796 "category_id": 1,797 "word_count": 77,798 "deleted_at": null,799 "user_id": 41794,800 "featured_link": null,801 "pinned_globally": false,802 "pinned_at": null,803 "pinned_until": null,804 "image_url": null,805 "slow_mode_seconds": 0,806 "draft": null,807 "draft_key": "topic_111050",808 "draft_sequence": null,809 "unpinned": null,810 "pinned": false,811 "current_post_number": 1,812 "highest_post_number": 1,813 "deleted_by": null,814 "actions_summary": [815 {816 "id": 4,817 "count": 0,818 "hidden": false,819 "can_act": false820 },821 {822 "id": 8,823 "count": 0,824 "hidden": false,825 "can_act": false826 },827 {828 "id": 10,829 "count": 0,830 "hidden": false,831 "can_act": false832 },833 {834 "id": 7,835 "count": 0,836 "hidden": false,837 "can_act": false838 }839 ],840 "chunk_size": 20,841 "bookmarked": false,842 "topic_timer": null,843 "message_bus_last_id": 0,844 "participant_count": 1,845 "show_read_indicator": false,846 "thumbnails": null,847 "slow_mode_enabled_until": null,848 "can_vote": false,849 "vote_count": 0,850 "user_voted": false,851 "discourse_zendesk_plugin_zendesk_id": null,852 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",853 "details": {854 "can_edit": false,855 "notification_level": 1,856 "participants": [857 {858 "id": 41794,859 "username": "bergentruckung",860 "name": "",861 "avatar_template": "/letter_avatar_proxy/v4/letter/b/958977/{size}.png",862 "post_count": 1,863 "primary_group_name": null,864 "flair_name": null,865 "flair_url": null,866 "flair_color": null,867 "flair_bg_color": null,868 "flair_group_id": null,869 "trust_level": 0870 }871 ],872 "created_by": {873 "id": 41794,874 "username": "bergentruckung",875 "name": "",876 "avatar_template": "/letter_avatar_proxy/v4/letter/b/958977/{size}.png"877 },878 "last_poster": {879 "id": 41794,880 "username": "bergentruckung",881 "name": "",882 "avatar_template": "/letter_avatar_proxy/v4/letter/b/958977/{size}.png"883 },884 "links": [885 {886 "url": "https://github.com/pytorch/pytorch/issues/47109",887 "title": "Pytorch 1.7/Cuda 11.1 binaries · Issue #47109 · pytorch/pytorch · GitHub",888 "internal": false,889 "attachment": false,890 "reflection": false,891 "clicks": 26,892 "user_id": 41794,893 "domain": "github.com",894 "root_domain": "github.com"895 }896 ]897 },898 "bookmarks": []899 },900 {901 "post_stream": {902 "posts": [903 {904 "id": 261442,905 "name": "poojan patel",906 "username": "pdp",907 "avatar_template": "/user_avatar/discuss.pytorch.org/pdp/{size}/34217_2.png",908 "created_at": "2021-02-03T19:37:26.265Z",909 "cooked": "<p>After the execution of code mentioned below,The output shape of c1 variable after using torch.count_nonzero is torch.Size([]).</p>\n<p>1.) When “vb.backward(torch.ones(va.size()))” is called, it gives following error as c1 shape is torch.Size([])</p>\n<p><strong>RuntimeError: Mismatch in shape: grad_output[0] has a shape of torch.Size([1, 1, 256, 256]) and output[0] has a shape of torch.Size([]).</strong></p>\n<p>2.) If I replace “c1=torch.count_nonzero(input)” with “c1 = torch.tensor([1.1], dtype=torch.float)” , then it gives the following error.</p>\n<p><strong>RuntimeError: Mismatch in shape: grad_output[0] has a shape of torch.Size([1, 1, 256, 256]) and output[0] has a shape of torch.Size([1]).</strong></p>\n<p>Code is as below.</p>\n<p>class fun(Function):<br>\n<span class=\"mention\">@staticmethod</span><br>\ndef forward(cxt,input):<br>\ncxt.save_for_backward(input)<br>\nc1=torch.count_nonzero(input)<br>\nprint(c1.shape)<br>\nreturn c1<br>\n<span class=\"mention\">@staticmethod</span><br>\ndef backward(cxt, grad_output):<br>\ninput, = cxt.saved_tensors<br>\ngrad_input = grad_output.clone()<br>\ngrad_input[input < 0] = 0<br>\nreturn grad_input<br>\nfun1 = fun.apply<br>\nif <strong>name</strong> == “<strong>main</strong>”:<br>\nfrom torch.autograd import Variable<br>\na=torch.rand(1,1,256,256)<br>\nva = Variable(a, requires_grad=True)<br>\nvb = fun1(va)<br>\nvb.backward(torch.ones(va.size()))</p>",910 "post_number": 1,911 "post_type": 1,912 "posts_count": 2,913 "updated_at": "2021-02-03T19:41:31.062Z",914 "reply_count": 1,915 "reply_to_post_number": null,916 "quote_count": 0,917 "incoming_link_count": 42,918 "reads": 7,919 "readers_count": 6,920 "score": 216.4,921 "yours": false,922 "topic_id": 110836,923 "topic_slug": "output-shape-of-torch-count-nonzero",924 "display_username": "poojan patel",925 "primary_group_name": null,926 "flair_name": null,927 "flair_url": null,928 "flair_bg_color": null,929 "flair_color": null,930 "flair_group_id": null,931 "badges_granted": [],932 "version": 1,933 "can_edit": false,934 "can_delete": false,935 "can_recover": false,936 "can_see_hidden_post": false,937 "can_wiki": false,938 "read": true,939 "user_title": null,940 "bookmarked": false,941 "actions_summary": [],942 "moderator": false,943 "admin": false,944 "staff": false,945 "user_id": 41707,946 "hidden": false,947 "trust_level": 1,948 "deleted_at": null,949 "user_deleted": false,950 "edit_reason": null,951 "can_view_edit_history": true,952 "wiki": false,953 "post_url": "/t/output-shape-of-torch-count-nonzero/110836/1",954 "can_accept_answer": false,955 "can_unaccept_answer": false,956 "accepted_answer": false,957 "topic_accepted_answer": null,958 "can_vote": false959 },960 {961 "id": 261856,962 "name": "poojan patel",963 "username": "pdp",964 "avatar_template": "/user_avatar/discuss.pytorch.org/pdp/{size}/34217_2.png",965 "created_at": "2021-02-05T16:15:09.815Z",966 "cooked": "<aside class=\"quote no-group\" data-username=\"pdp\" data-post=\"1\" data-topic=\"110836\">\n<div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img loading=\"lazy\" alt=\"\" width=\"24\" height=\"24\" src=\"https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/pdp/48/34217_2.png\" class=\"avatar\"> pdp:</div>\n<blockquote>\n<p>if <strong>name</strong> == “<strong>main</strong>”:</p>\n</blockquote>\n</aside>\n<p>There is a correction here.</p>\n<p>Its if <strong>__name == __main</strong></p>",967 "post_number": 2,968 "post_type": 1,969 "posts_count": 2,970 "updated_at": "2021-02-05T16:15:09.815Z",971 "reply_count": 0,972 "reply_to_post_number": null,973 "quote_count": 1,974 "incoming_link_count": 0,975 "reads": 6,976 "readers_count": 5,977 "score": 1.2,978 "yours": false,979 "topic_id": 110836,980 "topic_slug": "output-shape-of-torch-count-nonzero",981 "display_username": "poojan patel",982 "primary_group_name": null,983 "flair_name": null,984 "flair_url": null,985 "flair_bg_color": null,986 "flair_color": null,987 "flair_group_id": null,988 "badges_granted": [],989 "version": 1,990 "can_edit": false,991 "can_delete": false,992 "can_recover": false,993 "can_see_hidden_post": false,994 "can_wiki": false,995 "read": true,996 "user_title": null,997 "bookmarked": false,998 "actions_summary": [],999 "moderator": false,1000 "admin": false,1001 "staff": false,1002 "user_id": 41707,1003 "hidden": false,1004 "trust_level": 1,1005 "deleted_at": null,1006 "user_deleted": false,1007 "edit_reason": null,1008 "can_view_edit_history": true,1009 "wiki": false,1010 "post_url": "/t/output-shape-of-torch-count-nonzero/110836/2",1011 "can_accept_answer": false,1012 "can_unaccept_answer": false,1013 "accepted_answer": false,1014 "topic_accepted_answer": null1015 }1016 ],1017 "stream": [1018 261442,1019 2618561020 ]1021 },1022 "timeline_lookup": [1023 [1024 1,1025 17251026 ],1027 [1028 2,1029 17231030 ]1031 ],1032 "suggested_topics": [1033 {1034 "fancy_title": "Convert Conv3d to Conv2d but outputs different",1035 "id": 212246,1036 "title": "Convert Conv3d to Conv2d but outputs different",1037 "slug": "convert-conv3d-to-conv2d-but-outputs-different",1038 "posts_count": 2,1039 "reply_count": 0,1040 "highest_post_number": 2,1041 "image_url": null,1042 "created_at": "2024-10-29T06:46:01.486Z",1043 "last_posted_at": "2024-10-29T19:39:20.194Z",1044 "bumped": true,1045 "bumped_at": "2024-10-29T19:39:20.194Z",1046 "archetype": "regular",1047 "unseen": false,1048 "pinned": false,1049 "unpinned": null,1050 "visible": true,1051 "closed": false,1052 "archived": false,1053 "bookmarked": null,1054 "liked": null,1055 "tags_descriptions": {},1056 "like_count": 1,1057 "views": 205,1058 "category_id": 5,1059 "featured_link": null,1060 "has_accepted_answer": true,1061 "posters": [1062 {1063 "extras": null,1064 "description": "Original Poster",1065 "user": {1066 "id": 80556,1067 "username": "fengpings",1068 "name": "Tristan",1069 "avatar_template": "/user_avatar/discuss.pytorch.org/fengpings/{size}/73648_2.png",1070 "trust_level": 01071 }1072 },1073 {1074 "extras": "latest",1075 "description": "Most Recent Poster, Accepted Answer",1076 "user": {1077 "id": 3534,1078 "username": "ptrblck",1079 "name": "",1080 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1081 "admin": true,1082 "moderator": true,1083 "trust_level": 21084 }1085 }1086 ]1087 },1088 {1089 "fancy_title": "Why did my customized KL divergence cause NAN?",1090 "id": 214339,1091 "title": "Why did my customized KL divergence cause NAN?",1092 "slug": "why-did-my-customized-kl-divergence-cause-nan",1093 "posts_count": 2,1094 "reply_count": 0,1095 "highest_post_number": 2,1096 "image_url": null,1097 "created_at": "2024-12-18T00:23:20.532Z",1098 "last_posted_at": "2024-12-22T03:13:56.957Z",1099 "bumped": true,1100 "bumped_at": "2024-12-22T03:13:56.957Z",1101 "archetype": "regular",1102 "unseen": false,1103 "pinned": false,1104 "unpinned": null,1105 "visible": true,1106 "closed": false,1107 "archived": false,1108 "bookmarked": null,1109 "liked": null,1110 "tags_descriptions": {},1111 "like_count": 2,1112 "views": 206,1113 "category_id": 5,1114 "featured_link": null,1115 "has_accepted_answer": true,1116 "posters": [1117 {1118 "extras": null,1119 "description": "Original Poster",1120 "user": {1121 "id": 45116,1122 "username": "JimW",1123 "name": "",1124 "avatar_template": "/user_avatar/discuss.pytorch.org/jimw/{size}/38000_2.png",1125 "trust_level": 11126 }1127 },1128 {1129 "extras": "latest",1130 "description": "Most Recent Poster, Accepted Answer",1131 "user": {1132 "id": 18088,1133 "username": "KFrank",1134 "name": "K. Frank",1135 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",1136 "trust_level": 21137 }1138 }1139 ]1140 },1141 {1142 "fancy_title": "TypeError: ‘int’ object is not callable for claculating training accuracy",1143 "id": 212609,1144 "title": "TypeError: 'int' object is not callable for claculating training accuracy",1145 "slug": "typeerror-int-object-is-not-callable-for-claculating-training-accuracy",1146 "posts_count": 2,1147 "reply_count": 0,1148 "highest_post_number": 2,1149 "image_url": null,1150 "created_at": "2024-11-06T11:04:54.598Z",1151 "last_posted_at": "2024-11-06T17:20:42.372Z",1152 "bumped": true,1153 "bumped_at": "2024-11-06T17:20:42.372Z",1154 "archetype": "regular",1155 "unseen": false,1156 "pinned": false,1157 "unpinned": null,1158 "visible": true,1159 "closed": false,1160 "archived": false,1161 "bookmarked": null,1162 "liked": null,1163 "tags_descriptions": {},1164 "like_count": 0,1165 "views": 30,1166 "category_id": 5,1167 "featured_link": null,1168 "has_accepted_answer": false,1169 "posters": [1170 {1171 "extras": null,1172 "description": "Original Poster",1173 "user": {1174 "id": 68222,1175 "username": "amy2",1176 "name": "amy",1177 "avatar_template": "/user_avatar/discuss.pytorch.org/amy2/{size}/62675_2.png",1178 "trust_level": 11179 }1180 },1181 {1182 "extras": "latest",1183 "description": "Most Recent Poster",1184 "user": {1185 "id": 3534,1186 "username": "ptrblck",1187 "name": "",1188 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1189 "admin": true,1190 "moderator": true,1191 "trust_level": 21192 }1193 }1194 ]1195 },1196 {1197 "fancy_title": "Simple CNN model takes too much memory when forward() is called",1198 "id": 217883,1199 "title": "Simple CNN model takes too much memory when forward() is called",1200 "slug": "simple-cnn-model-takes-too-much-memory-when-forward-is-called",