Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 69368,7 "name": "Laoreja",8 "username": "laoreja",9 "avatar_template": "/user_avatar/discuss.pytorch.org/laoreja/{size}/5482_2.png",10 "created_at": "2018-10-06T06:49:07.701Z",11 "cooked": "<p>How to check if NCCL is installed correctly and can be used by PyTorch? I can import torch.cuda.nccl, but I’m not sure how to test if it’s installed correctly.</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 3,15 "updated_at": "2018-10-06T06:49:07.701Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 11389,20 "reads": 313,21 "readers_count": 312,22 "score": 57012.6,23 "yours": false,24 "topic_id": 26646,25 "topic_slug": "how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch",26 "display_username": "Laoreja",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": 1,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 {45 "id": 2,46 "count": 247 }48 ],49 "moderator": false,50 "admin": false,51 "staff": false,52 "user_id": 6472,53 "hidden": false,54 "trust_level": 2,55 "deleted_at": null,56 "user_deleted": false,57 "edit_reason": null,58 "can_view_edit_history": true,59 "wiki": false,60 "post_url": "/t/how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch/26646/1",61 "can_accept_answer": false,62 "can_unaccept_answer": false,63 "accepted_answer": false,64 "topic_accepted_answer": true,65 "can_vote": false66 },67 {68 "id": 116697,69 "name": "",70 "username": "XinDongol",71 "avatar_template": "/user_avatar/discuss.pytorch.org/xindongol/{size}/10476_2.png",72 "created_at": "2019-06-12T22:20:30.540Z",73 "cooked": "<p>You can try</p>\n<pre><code class=\"lang-auto\">torch.cuda.nccl.version()\n</code></pre>",74 "post_number": 2,75 "post_type": 1,76 "posts_count": 3,77 "updated_at": "2019-12-04T00:50:33.510Z",78 "reply_count": 1,79 "reply_to_post_number": null,80 "quote_count": 0,81 "incoming_link_count": 55,82 "reads": 289,83 "readers_count": 288,84 "score": 427.8,85 "yours": false,86 "topic_id": 26646,87 "topic_slug": "how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch",88 "display_username": "",89 "primary_group_name": null,90 "flair_name": null,91 "flair_url": null,92 "flair_bg_color": null,93 "flair_color": null,94 "flair_group_id": null,95 "badges_granted": [],96 "version": 1,97 "can_edit": false,98 "can_delete": false,99 "can_recover": false,100 "can_see_hidden_post": false,101 "can_wiki": false,102 "link_counts": [103 {104 "url": "https://discuss.pytorch.org/t/how-to-get-cuda-cudnn-nccl-build-version/59345/2",105 "internal": true,106 "reflection": true,107 "title": "How to get cuda cudnn nccl build version?",108 "clicks": 41109 }110 ],111 "read": true,112 "user_title": "",113 "bookmarked": false,114 "actions_summary": [115 {116 "id": 2,117 "count": 6118 }119 ],120 "moderator": false,121 "admin": false,122 "staff": false,123 "user_id": 12060,124 "hidden": false,125 "trust_level": 1,126 "deleted_at": null,127 "user_deleted": false,128 "edit_reason": null,129 "can_view_edit_history": true,130 "wiki": false,131 "post_url": "/t/how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch/26646/2",132 "can_accept_answer": false,133 "can_unaccept_answer": false,134 "accepted_answer": true,135 "topic_accepted_answer": true136 },137 {138 "id": 273144,139 "name": "MirandaAgent",140 "username": "Brando_Miranda",141 "avatar_template": "/user_avatar/discuss.pytorch.org/brando_miranda/{size}/14355_2.png",142 "created_at": "2021-03-27T01:10:46.914Z",143 "cooked": "<p>is there a way to check it with a command line without pytorch?</p>",144 "post_number": 3,145 "post_type": 1,146 "posts_count": 3,147 "updated_at": "2021-03-27T01:10:46.914Z",148 "reply_count": 0,149 "reply_to_post_number": 2,150 "quote_count": 0,151 "incoming_link_count": 38,152 "reads": 122,153 "readers_count": 121,154 "score": 214.4,155 "yours": false,156 "topic_id": 26646,157 "topic_slug": "how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch",158 "display_username": "MirandaAgent",159 "primary_group_name": null,160 "flair_name": null,161 "flair_url": null,162 "flair_bg_color": null,163 "flair_color": null,164 "flair_group_id": null,165 "badges_granted": [],166 "version": 1,167 "can_edit": false,168 "can_delete": false,169 "can_recover": false,170 "can_see_hidden_post": false,171 "can_wiki": false,172 "read": true,173 "user_title": "",174 "reply_to_user": {175 "id": 12060,176 "username": "XinDongol",177 "name": "",178 "avatar_template": "/user_avatar/discuss.pytorch.org/xindongol/{size}/10476_2.png"179 },180 "bookmarked": false,181 "actions_summary": [],182 "moderator": false,183 "admin": false,184 "staff": false,185 "user_id": 2282,186 "hidden": false,187 "trust_level": 2,188 "deleted_at": null,189 "user_deleted": false,190 "edit_reason": null,191 "can_view_edit_history": true,192 "wiki": false,193 "post_url": "/t/how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch/26646/3",194 "can_accept_answer": false,195 "can_unaccept_answer": false,196 "accepted_answer": false,197 "topic_accepted_answer": true198 }199 ],200 "stream": [201 69368,202 116697,203 273144204 ]205 },206 "timeline_lookup": [207 [208 1,209 2577210 ],211 [212 2,213 2327214 ],215 [216 3,217 1674218 ]219 ],220 "suggested_topics": [221 {222 "fancy_title": "Torchrun vllm error:TCPStore.cpp:358] [c10d] TCP client failed to connect/validate to host",223 "id": 217341,224 "title": "Torchrun vllm error:TCPStore.cpp:358] [c10d] TCP client failed to connect/validate to host",225 "slug": "torchrun-vllm-error-tcpstore-cpp-358-c10d-tcp-client-failed-to-connect-validate-to-host",226 "posts_count": 4,227 "reply_count": 1,228 "highest_post_number": 4,229 "image_url": null,230 "created_at": "2025-03-02T12:39:14.160Z",231 "last_posted_at": "2025-04-08T07:41:17.412Z",232 "bumped": true,233 "bumped_at": "2025-04-08T07:41:17.412Z",234 "archetype": "regular",235 "unseen": false,236 "pinned": false,237 "unpinned": null,238 "visible": true,239 "closed": false,240 "archived": false,241 "bookmarked": null,242 "liked": null,243 "tags_descriptions": {},244 "like_count": 1,245 "views": 1039,246 "category_id": 1,247 "featured_link": null,248 "has_accepted_answer": false,249 "posters": [250 {251 "extras": null,252 "description": "Original Poster",253 "user": {254 "id": 83021,255 "username": "yishuizhao",256 "name": "",257 "avatar_template": "/letter_avatar_proxy/v4/letter/y/e68b1a/{size}.png",258 "trust_level": 0259 }260 },261 {262 "extras": null,263 "description": "Frequent Poster",264 "user": {265 "id": 7414,266 "username": "zhanwenchen",267 "name": "Zhanwen \"Phil\" Chen",268 "avatar_template": "/user_avatar/discuss.pytorch.org/zhanwenchen/{size}/10362_2.png",269 "trust_level": 2270 }271 },272 {273 "extras": "latest",274 "description": "Most Recent Poster",275 "user": {276 "id": 83698,277 "username": "bcml",278 "name": null,279 "avatar_template": "/letter_avatar_proxy/v4/letter/b/bcef8e/{size}.png",280 "trust_level": 1281 }282 }283 ]284 },285 {286 "fancy_title": "When I use the optimizer, there is no gradient due to the use of unit8, but I have to use unit8",287 "id": 214893,288 "title": "When I use the optimizer, there is no gradient due to the use of unit8, but I have to use unit8",289 "slug": "when-i-use-the-optimizer-there-is-no-gradient-due-to-the-use-of-unit8-but-i-have-to-use-unit8",290 "posts_count": 9,291 "reply_count": 5,292 "highest_post_number": 9,293 "image_url": null,294 "created_at": "2025-01-02T14:06:04.839Z",295 "last_posted_at": "2025-01-13T12:39:45.943Z",296 "bumped": true,297 "bumped_at": "2025-01-13T12:39:45.943Z",298 "archetype": "regular",299 "unseen": false,300 "pinned": false,301 "unpinned": null,302 "visible": true,303 "closed": false,304 "archived": false,305 "bookmarked": null,306 "liked": null,307 "tags_descriptions": {},308 "like_count": 2,309 "views": 67,310 "category_id": 1,311 "featured_link": null,312 "has_accepted_answer": false,313 "posters": [314 {315 "extras": "latest",316 "description": "Original Poster, Most Recent Poster",317 "user": {318 "id": 81832,319 "username": "wang1528186571",320 "name": "Wang1528186571",321 "avatar_template": "/user_avatar/discuss.pytorch.org/wang1528186571/{size}/74860_2.png",322 "trust_level": 0323 }324 },325 {326 "extras": null,327 "description": "Frequent Poster",328 "user": {329 "id": 41396,330 "username": "soulitzer",331 "name": "",332 "avatar_template": "/letter_avatar_proxy/v4/letter/s/839c29/{size}.png",333 "trust_level": 2334 }335 },336 {337 "extras": null,338 "description": "Frequent Poster",339 "user": {340 "id": 27175,341 "username": "Sayed_Nadim",342 "name": "",343 "avatar_template": "/user_avatar/discuss.pytorch.org/sayed_nadim/{size}/34051_2.png",344 "trust_level": 2345 }346 }347 ]348 },349 {350 "fancy_title": "Pytorch on 3.10 python version of jetson orin",351 "id": 216032,352 "title": "Pytorch on 3.10 python version of jetson orin",353 "slug": "pytorch-on-3-10-python-version-of-jetson-orin",354 "posts_count": 3,355 "reply_count": 1,356 "highest_post_number": 3,357 "image_url": null,358 "created_at": "2025-01-29T19:13:23.937Z",359 "last_posted_at": "2025-01-29T21:26:40.385Z",360 "bumped": true,361 "bumped_at": "2025-01-29T21:37:17.202Z",362 "archetype": "regular",363 "unseen": false,364 "pinned": false,365 "unpinned": null,366 "visible": true,367 "closed": false,368 "archived": false,369 "bookmarked": null,370 "liked": null,371 "tags_descriptions": {},372 "like_count": 0,373 "views": 399,374 "category_id": 1,375 "featured_link": null,376 "has_accepted_answer": false,377 "posters": [378 {379 "extras": "latest",380 "description": "Original Poster, Most Recent Poster",381 "user": {382 "id": 82374,383 "username": "Vaibhavi_Kavathekar",384 "name": "Vaibhavi Kavathekar",385 "avatar_template": "/user_avatar/discuss.pytorch.org/vaibhavi_kavathekar/{size}/75361_2.png",386 "trust_level": 0387 }388 },389 {390 "extras": null,391 "description": "Frequent Poster",392 "user": {393 "id": 3534,394 "username": "ptrblck",395 "name": "",396 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",397 "admin": true,398 "moderator": true,399 "trust_level": 2400 }401 }402 ]403 },404 {405 "fancy_title": "Does the license allow to copy/modify code and how to properly credit pytorch?",406 "id": 214719,407 "title": "Does the license allow to copy/modify code and how to properly credit pytorch?",408 "slug": "does-the-license-allow-to-copy-modify-code-and-how-to-properly-credit-pytorch",409 "posts_count": 1,410 "reply_count": 0,411 "highest_post_number": 1,412 "image_url": null,413 "created_at": "2024-12-28T09:23:25.179Z",414 "last_posted_at": "2024-12-28T09:23:25.222Z",415 "bumped": true,416 "bumped_at": "2024-12-28T09:23:25.222Z",417 "archetype": "regular",418 "unseen": false,419 "pinned": false,420 "unpinned": null,421 "visible": true,422 "closed": false,423 "archived": false,424 "bookmarked": null,425 "liked": null,426 "tags_descriptions": {},427 "like_count": 0,428 "views": 42,429 "category_id": 1,430 "featured_link": null,431 "has_accepted_answer": false,432 "posters": [433 {434 "extras": "latest single",435 "description": "Original Poster, Most Recent Poster",436 "user": {437 "id": 41303,438 "username": "jeremyfix",439 "name": "Jeremy Fix",440 "avatar_template": "/user_avatar/discuss.pytorch.org/jeremyfix/{size}/33730_2.png",441 "trust_level": 1442 }443 }444 ]445 },446 {447 "fancy_title": "Lipschitz Constant of Conv2d",448 "id": 218943,449 "title": "Lipschitz Constant of Conv2d",450 "slug": "lipschitz-constant-of-conv2d",451 "posts_count": 1,452 "reply_count": 0,453 "highest_post_number": 1,454 "image_url": null,455 "created_at": "2025-04-10T10:50:22.705Z",456 "last_posted_at": "2025-04-10T10:50:22.744Z",457 "bumped": true,458 "bumped_at": "2025-04-10T10:50:22.744Z",459 "archetype": "regular",460 "unseen": false,461 "pinned": false,462 "unpinned": null,463 "visible": true,464 "closed": false,465 "archived": false,466 "bookmarked": null,467 "liked": null,468 "tags_descriptions": {},469 "like_count": 0,470 "views": 55,471 "category_id": 1,472 "featured_link": null,473 "has_accepted_answer": false,474 "posters": [475 {476 "extras": "latest single",477 "description": "Original Poster, Most Recent Poster",478 "user": {479 "id": 83742,480 "username": "Sherlock_Holmes",481 "name": "",482 "avatar_template": "/user_avatar/discuss.pytorch.org/sherlock_holmes/{size}/74585_2.png",483 "trust_level": 0484 }485 }486 ]487 }488 ],489 "tags_descriptions": {},490 "fancy_title": "How to check if NCCL is installed correctly and can be used by PyTorch?",491 "id": 26646,492 "title": "How to check if NCCL is installed correctly and can be used by PyTorch?",493 "posts_count": 3,494 "created_at": "2018-10-06T06:49:07.654Z",495 "views": 13392,496 "reply_count": 1,497 "like_count": 8,498 "last_posted_at": "2021-03-27T01:10:46.914Z",499 "visible": true,500 "closed": false,501 "archived": false,502 "has_summary": false,503 "archetype": "regular",504 "slug": "how-to-check-if-nccl-is-installed-correctly-and-can-be-used-by-pytorch",505 "category_id": 1,506 "word_count": 53,507 "deleted_at": null,508 "user_id": 6472,509 "featured_link": null,510 "pinned_globally": false,511 "pinned_at": null,512 "pinned_until": null,513 "image_url": null,514 "slow_mode_seconds": 0,515 "draft": null,516 "draft_key": "topic_26646",517 "draft_sequence": null,518 "unpinned": null,519 "pinned": false,520 "current_post_number": 1,521 "highest_post_number": 3,522 "deleted_by": null,523 "actions_summary": [524 {525 "id": 4,526 "count": 0,527 "hidden": false,528 "can_act": false529 },530 {531 "id": 8,532 "count": 0,533 "hidden": false,534 "can_act": false535 },536 {537 "id": 10,538 "count": 0,539 "hidden": false,540 "can_act": false541 },542 {543 "id": 7,544 "count": 0,545 "hidden": false,546 "can_act": false547 }548 ],549 "chunk_size": 20,550 "bookmarked": false,551 "topic_timer": null,552 "message_bus_last_id": 0,553 "participant_count": 3,554 "show_read_indicator": false,555 "thumbnails": null,556 "slow_mode_enabled_until": null,557 "accepted_answer": {558 "post_number": 2,559 "username": "XinDongol",560 "name": "",561 "excerpt": "You can try \ntorch.cuda.nccl.version()"562 },563 "can_vote": false,564 "vote_count": 0,565 "user_voted": false,566 "discourse_zendesk_plugin_zendesk_id": null,567 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",568 "details": {569 "can_edit": false,570 "notification_level": 1,571 "participants": [572 {573 "id": 2282,574 "username": "Brando_Miranda",575 "name": "MirandaAgent",576 "avatar_template": "/user_avatar/discuss.pytorch.org/brando_miranda/{size}/14355_2.png",577 "post_count": 1,578 "primary_group_name": null,579 "flair_name": null,580 "flair_url": null,581 "flair_color": null,582 "flair_bg_color": null,583 "flair_group_id": null,584 "trust_level": 2585 },586 {587 "id": 6472,588 "username": "laoreja",589 "name": "Laoreja",590 "avatar_template": "/user_avatar/discuss.pytorch.org/laoreja/{size}/5482_2.png",591 "post_count": 1,592 "primary_group_name": null,593 "flair_name": null,594 "flair_url": null,595 "flair_color": null,596 "flair_bg_color": null,597 "flair_group_id": null,598 "trust_level": 2599 },600 {601 "id": 12060,602 "username": "XinDongol",603 "name": "",604 "avatar_template": "/user_avatar/discuss.pytorch.org/xindongol/{size}/10476_2.png",605 "post_count": 1,606 "primary_group_name": null,607 "flair_name": null,608 "flair_url": null,609 "flair_color": null,610 "flair_bg_color": null,611 "flair_group_id": null,612 "trust_level": 1613 }614 ],615 "created_by": {616 "id": 6472,617 "username": "laoreja",618 "name": "Laoreja",619 "avatar_template": "/user_avatar/discuss.pytorch.org/laoreja/{size}/5482_2.png"620 },621 "last_poster": {622 "id": 2282,623 "username": "Brando_Miranda",624 "name": "MirandaAgent",625 "avatar_template": "/user_avatar/discuss.pytorch.org/brando_miranda/{size}/14355_2.png"626 },627 "links": [628 {629 "url": "https://discuss.pytorch.org/t/how-to-get-cuda-cudnn-nccl-build-version/59345/2",630 "title": "How to get cuda cudnn nccl build version?",631 "internal": true,632 "attachment": false,633 "reflection": true,634 "clicks": 41,635 "user_id": 7778,636 "domain": "discuss.pytorch.org",637 "root_domain": "pytorch.org"638 }639 ]640 },641 "bookmarks": []642 },643 {644 "post_stream": {645 "posts": [646 {647 "id": 272569,648 "name": "Stieg Nilsson",649 "username": "Stieg_Nilsson",650 "avatar_template": "/user_avatar/discuss.pytorch.org/stieg_nilsson/{size}/30473_2.png",651 "created_at": "2021-03-24T23:51:18.060Z",652 "cooked": "<p>I am new to PyTorch and Deep Learning. I am currently learning about residual blocks and res-nets and found following implementation:</p>\n<pre><code class=\"lang-auto\">class BasicBlock(nn.Module):\n\tdef __init__(self, channel_num):\n\t\tsuper(BasicBlock, self).__init__()\n\n\t\tself.conv_block1 = nn.Sequential(\n\t\t\tnn.Conv2d(channel_num, channel_num, 3, padding=1),\n\t\t\tnn.BatchNorm2d(channel_num),\n\t\t\tnn.ReLU(),\n\t\t) \n\t\tself.conv_block2 = nn.Sequential(\n\t\t\tnn.Conv2d(channel_num, channel_num, 3, padding=1),\n\t\t\tnn.BatchNorm2d(channel_num),\n\t\t)\n\t\tself.relu = nn.ReLU()\n\t\n\tdef forward(self, x):\n\t\t\n\t\tresidual = x\n\t\tx = self.conv_block1(x)\n\t\tx = self.conv_block2(x)\n\t\tx = x + residual\n\t\tout = self.relu(x)\n\t\treturn out\n</code></pre>\n<p>Now, I want to pass a 3x5x5 tensor and use three 3x3x3 sized kernel weights, and I am getting the following error.</p>\n<pre><code class=\"lang-auto\">RuntimeError Traceback (most recent call last)\n<ipython-input-35-6bab6a73e525> in <module>()\n----> 1 output_res = model_res(x)\n\n6 frames\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)\n 887 result = self._slow_forward(*input, **kwargs)\n 888 else:\n--> 889 result = self.forward(*input, **kwargs)\n 890 for hook in itertools.chain(\n 891 _global_forward_hooks.values(),\n\n<ipython-input-17-8ece58abdeeb> in forward(self, x)\n 20 #TODO: forward\n 21 residual = x\n---> 22 x = self.conv_block1(x)\n 23 x = self.conv_block2(x)\n 24 x = x + residual\n\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)\n 887 result = self._slow_forward(*input, **kwargs)\n 888 else:\n--> 889 result = self.forward(*input, **kwargs)\n 890 for hook in itertools.chain(\n 891 _global_forward_hooks.values(),\n\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/container.py in forward(self, input)\n 117 def forward(self, input):\n 118 for module in self:\n--> 119 input = module(input)\n 120 return input\n 121 \n\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)\n 887 result = self._slow_forward(*input, **kwargs)\n 888 else:\n--> 889 result = self.forward(*input, **kwargs)\n 890 for hook in itertools.chain(\n 891 _global_forward_hooks.values(),\n\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py in forward(self, input)\n 397 \n 398 def forward(self, input: Tensor) -> Tensor:\n--> 399 return self._conv_forward(input, self.weight, self.bias)\n 400 \n 401 class Conv3d(_ConvNd):\n\n/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py in _conv_forward(self, input, weight, bias)\n 394 _pair(0), self.dilation, self.groups)\n 395 return F.conv2d(input, weight, bias, self.stride,\n--> 396 self.padding, self.dilation, self.groups)\n 397 \n 398 def forward(self, input: Tensor) -> Tensor:\n\nRuntimeError: Expected 4-dimensional input for 4-dimensional weight [5, 5, 3, 3], but got 3-dimensional input of size [3, 5, 5] instead\n</code></pre>\n<p>Help, what am I doing wrong here?</p>",653 "post_number": 1,654 "post_type": 1,655 "posts_count": 2,656 "updated_at": "2021-03-24T23:51:18.060Z",657 "reply_count": 0,658 "reply_to_post_number": null,659 "quote_count": 0,660 "incoming_link_count": 82,661 "reads": 5,662 "readers_count": 4,663 "score": 411.0,664 "yours": false,665 "topic_id": 115876,666 "topic_slug": "help-passing-input-and-setting-kernel-weights-for-a-residual-block",667 "display_username": "Stieg Nilsson",668 "primary_group_name": null,669 "flair_name": null,670 "flair_url": null,671 "flair_bg_color": null,672 "flair_color": null,673 "flair_group_id": null,674 "badges_granted": [],675 "version": 1,676 "can_edit": false,677 "can_delete": false,678 "can_recover": false,679 "can_see_hidden_post": false,680 "can_wiki": false,681 "read": true,682 "user_title": null,683 "bookmarked": false,684 "actions_summary": [],685 "moderator": false,686 "admin": false,687 "staff": false,688 "user_id": 43494,689 "hidden": false,690 "trust_level": 1,691 "deleted_at": null,692 "user_deleted": false,693 "edit_reason": null,694 "can_view_edit_history": true,695 "wiki": false,696 "post_url": "/t/help-passing-input-and-setting-kernel-weights-for-a-residual-block/115876/1",697 "can_accept_answer": false,698 "can_unaccept_answer": false,699 "accepted_answer": false,700 "topic_accepted_answer": null,701 "can_vote": false702 },703 {704 "id": 273143,705 "name": "",706 "username": "ptrblck",707 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",708 "created_at": "2021-03-27T01:10:13.658Z",709 "cooked": "<p><code>nn.*2d</code> layers expect a 4-dimensional input in the shape <code>[batch_size, channels, height, width]</code>.<br>\nBased on the error message I guess the batch dimension might be missing and you can add it via:</p>\n<pre><code class=\"lang-python\">x = x.unsqueeze(0)\n</code></pre>\n<p>before passing it to the model.</p>",710 "post_number": 2,711 "post_type": 1,712 "posts_count": 2,713 "updated_at": "2021-03-27T01:10:13.658Z",714 "reply_count": 0,715 "reply_to_post_number": null,716 "quote_count": 0,717 "incoming_link_count": 3,718 "reads": 4,719 "readers_count": 3,720 "score": 15.8,721 "yours": false,722 "topic_id": 115876,723 "topic_slug": "help-passing-input-and-setting-kernel-weights-for-a-residual-block",724 "display_username": "",725 "primary_group_name": null,726 "flair_name": null,727 "flair_url": null,728 "flair_bg_color": null,729 "flair_color": null,730 "flair_group_id": null,731 "badges_granted": [],732 "version": 1,733 "can_edit": false,734 "can_delete": false,735 "can_recover": false,736 "can_see_hidden_post": false,737 "can_wiki": false,738 "read": true,739 "user_title": "",740 "bookmarked": false,741 "actions_summary": [],742 "moderator": true,743 "admin": true,744 "staff": true,745 "user_id": 3534,746 "hidden": false,747 "trust_level": 2,748 "deleted_at": null,749 "user_deleted": false,750 "edit_reason": null,751 "can_view_edit_history": true,752 "wiki": false,753 "post_url": "/t/help-passing-input-and-setting-kernel-weights-for-a-residual-block/115876/2",754 "can_accept_answer": false,755 "can_unaccept_answer": false,756 "accepted_answer": false,757 "topic_accepted_answer": null758 }759 ],760 "stream": [761 272569,762 273143763 ]764 },765 "timeline_lookup": [766 [767 1,768 1676769 ],770 [771 2,772 1674773 ]774 ],775 "suggested_topics": [776 {777 "fancy_title": "“RTX 2000 Ada Generation Laptop GPU” vs. 3000 version",778 "id": 212465,779 "title": "\"RTX 2000 Ada Generation Laptop GPU\" vs. 3000 version",780 "slug": "rtx-2000-ada-generation-laptop-gpu-vs-3000-version",781 "posts_count": 1,782 "reply_count": 0,783 "highest_post_number": 1,784 "image_url": null,785 "created_at": "2024-11-03T03:11:07.003Z",786 "last_posted_at": "2024-11-03T03:11:07.058Z",787 "bumped": true,788 "bumped_at": "2024-11-03T03:11:07.058Z",789 "archetype": "regular",790 "unseen": false,791 "pinned": false,792 "unpinned": null,793 "visible": true,794 "closed": false,795 "archived": false,796 "bookmarked": null,797 "liked": null,798 "tags_descriptions": {},799 "like_count": 0,800 "views": 739,801 "category_id": 1,802 "featured_link": null,803 "has_accepted_answer": false,804 "posters": [805 {806 "extras": "latest single",807 "description": "Original Poster, Most Recent Poster",808 "user": {809 "id": 18088,810 "username": "KFrank",811 "name": "K. Frank",812 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",813 "trust_level": 2814 }815 }816 ]817 },818 {819 "fancy_title": "Call order of hooks",820 "id": 215863,821 "title": "Call order of hooks",822 "slug": "call-order-of-hooks",823 "posts_count": 1,824 "reply_count": 0,825 "highest_post_number": 1,826 "image_url": null,827 "created_at": "2025-01-25T16:57:33.402Z",828 "last_posted_at": "2025-01-25T16:57:33.447Z",829 "bumped": true,830 "bumped_at": "2025-01-25T16:57:33.447Z",831 "archetype": "regular",832 "unseen": false,833 "pinned": false,834 "unpinned": null,835 "visible": true,836 "closed": false,837 "archived": false,838 "bookmarked": null,839 "liked": null,840 "tags_descriptions": {},841 "like_count": 0,842 "views": 70,843 "category_id": 1,844 "featured_link": null,845 "has_accepted_answer": false,846 "posters": [847 {848 "extras": "latest single",849 "description": "Original Poster, Most Recent Poster",850 "user": {851 "id": 82245,852 "username": "sternj",853 "name": null,854 "avatar_template": "/letter_avatar_proxy/v4/letter/s/b19c9b/{size}.png",855 "trust_level": 1856 }857 }858 ]859 },860 {861 "fancy_title": "What is the use of tensor.share_memory_()?",862 "id": 213481,863 "title": "What is the use of tensor.share_memory_()?",864 "slug": "what-is-the-use-of-tensor-share-memory",865 "posts_count": 1,866 "reply_count": 0,867 "highest_post_number": 1,868 "image_url": null,869 "created_at": "2024-11-26T16:17:26.814Z",870 "last_posted_at": "2024-11-26T16:17:26.866Z",871 "bumped": true,872 "bumped_at": "2024-11-26T16:17:26.866Z",873 "archetype": "regular",874 "unseen": false,875 "pinned": false,876 "unpinned": null,877 "visible": true,878 "closed": false,879 "archived": false,880 "bookmarked": null,881 "liked": null,882 "tags_descriptions": {},883 "like_count": 0,884 "views": 45,885 "category_id": 1,886 "featured_link": null,887 "has_accepted_answer": false,888 "posters": [889 {890 "extras": "latest single",891 "description": "Original Poster, Most Recent Poster",892 "user": {893 "id": 81147,894 "username": "dcusmeb",895 "name": "",896 "avatar_template": "/user_avatar/discuss.pytorch.org/dcusmeb/{size}/72677_2.png",897 "trust_level": 0898 }899 }900 ]901 },902 {903 "fancy_title": "Need Language Model Advice",904 "id": 216445,905 "title": "Need Language Model Advice",906 "slug": "need-language-model-advice",907 "posts_count": 1,908 "reply_count": 0,909 "highest_post_number": 1,910 "image_url": null,911 "created_at": "2025-02-10T03:34:02.769Z",912 "last_posted_at": "2025-02-10T03:34:02.810Z",913 "bumped": true,914 "bumped_at": "2025-02-10T12:44:59.110Z",915 "archetype": "regular",916 "unseen": false,917 "pinned": false,918 "unpinned": null,919 "visible": true,920 "closed": false,921 "archived": false,922 "bookmarked": null,923 "liked": null,924 "tags_descriptions": {},925 "like_count": 0,926 "views": 20,927 "category_id": 1,928 "featured_link": null,929 "has_accepted_answer": false,930 "posters": [931 {932 "extras": "latest single",933 "description": "Original Poster, Most Recent Poster",934 "user": {935 "id": 73472,936 "username": "TheVictor_777",937 "name": "",938 "avatar_template": "/letter_avatar_proxy/v4/letter/t/5daacb/{size}.png",939 "trust_level": 1940 }941 }942 ]943 },944 {945 "fancy_title": "Compatibility of Python 3.12 with (py)torch,",946 "id": 219215,947 "title": "Compatibility of Python 3.12 with (py)torch,",948 "slug": "compatibility-of-python-3-12-with-py-torch",949 "posts_count": 5,950 "reply_count": 3,951 "highest_post_number": 5,952 "image_url": null,953 "created_at": "2025-04-18T01:40:10.681Z",954 "last_posted_at": "2025-04-19T14:23:57.137Z",955 "bumped": true,956 "bumped_at": "2025-04-19T14:23:57.137Z",957 "archetype": "regular",958 "unseen": false,959 "pinned": false,960 "unpinned": null,961 "visible": true,962 "closed": false,963 "archived": false,964 "bookmarked": null,965 "liked": null,966 "tags_descriptions": {},967 "like_count": 0,968 "views": 980,969 "category_id": 1,970 "featured_link": null,971 "has_accepted_answer": false,972 "posters": [973 {974 "extras": "latest",975 "description": "Original Poster, Most Recent Poster",976 "user": {977 "id": 83878,978 "username": "mcswell",979 "name": "Michael B Maxwell",980 "avatar_template": "/user_avatar/discuss.pytorch.org/mcswell/{size}/75353_2.png",981 "trust_level": 0982 }983 },984 {985 "extras": null,986 "description": "Frequent Poster",987 "user": {988 "id": 3534,989 "username": "ptrblck",990 "name": "",991 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",992 "admin": true,993 "moderator": true,994 "trust_level": 2995 }996 }997 ]998 }999 ],1000 "tags_descriptions": {},1001 "fancy_title": "HELP! Passing input and setting kernel weights for a Residual Block",1002 "id": 115876,1003 "title": "HELP! Passing input and setting kernel weights for a Residual Block",1004 "posts_count": 2,1005 "created_at": "2021-03-24T23:51:18.002Z",1006 "views": 517,1007 "reply_count": 0,1008 "like_count": 0,1009 "last_posted_at": "2021-03-27T01:10:13.658Z",1010 "visible": true,1011 "closed": false,1012 "archived": false,1013 "has_summary": false,1014 "archetype": "regular",1015 "slug": "help-passing-input-and-setting-kernel-weights-for-a-residual-block",1016 "category_id": 1,1017 "word_count": 476,1018 "deleted_at": null,1019 "user_id": 43494,1020 "featured_link": null,1021 "pinned_globally": false,1022 "pinned_at": null,1023 "pinned_until": null,1024 "image_url": null,1025 "slow_mode_seconds": 0,1026 "draft": null,1027 "draft_key": "topic_115876",1028 "draft_sequence": null,1029 "unpinned": null,1030 "pinned": false,1031 "current_post_number": 1,1032 "highest_post_number": 2,1033 "deleted_by": null,1034 "actions_summary": [1035 {1036 "id": 4,1037 "count": 0,1038 "hidden": false,1039 "can_act": false1040 },1041 {1042 "id": 8,1043 "count": 0,1044 "hidden": false,1045 "can_act": false1046 },1047 {1048 "id": 10,1049 "count": 0,1050 "hidden": false,1051 "can_act": false1052 },1053 {1054 "id": 7,1055 "count": 0,1056 "hidden": false,1057 "can_act": false1058 }1059 ],1060 "chunk_size": 20,1061 "bookmarked": false,1062 "topic_timer": null,1063 "message_bus_last_id": 0,1064 "participant_count": 2,1065 "show_read_indicator": false,1066 "thumbnails": null,1067 "slow_mode_enabled_until": null,1068 "can_vote": false,1069 "vote_count": 0,1070 "user_voted": false,1071 "discourse_zendesk_plugin_zendesk_id": null,1072 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1073 "details": {1074 "can_edit": false,1075 "notification_level": 1,1076 "participants": [1077 {1078 "id": 3534,1079 "username": "ptrblck",1080 "name": "",1081 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1082 "post_count": 1,1083 "primary_group_name": null,1084 "flair_name": null,1085 "flair_url": null,1086 "flair_color": null,1087 "flair_bg_color": null,1088 "flair_group_id": null,1089 "admin": true,1090 "moderator": true,1091 "trust_level": 21092 },1093 {1094 "id": 43494,1095 "username": "Stieg_Nilsson",1096 "name": "Stieg Nilsson",1097 "avatar_template": "/user_avatar/discuss.pytorch.org/stieg_nilsson/{size}/30473_2.png",1098 "post_count": 1,1099 "primary_group_name": null,1100 "flair_name": null,1101 "flair_url": null,1102 "flair_color": null,1103 "flair_bg_color": null,1104 "flair_group_id": null,1105 "trust_level": 11106 }1107 ],1108 "created_by": {1109 "id": 43494,1110 "username": "Stieg_Nilsson",1111 "name": "Stieg Nilsson",1112 "avatar_template": "/user_avatar/discuss.pytorch.org/stieg_nilsson/{size}/30473_2.png"1113 },1114 "last_poster": {1115 "id": 3534,1116 "username": "ptrblck",1117 "name": "",1118 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"1119 }1120 },1121 "bookmarks": []1122 },1123 {1124 "post_stream": {1125 "posts": [1126 {1127 "id": 271960,1128 "name": "Paul Micaelli",1129 "username": "Paul_Micaelli",1130 "avatar_template": "/user_avatar/discuss.pytorch.org/paul_micaelli/{size}/36085_2.png",1131 "created_at": "2021-03-22T17:18:34.145Z",1132 "cooked": "<p>In meta-learning you want to differentiate through (inner) gradient updates themselves, for example to get the (outer) gradient of the validation loss wrt some hyperparameter.</p>\n<p>I had issues with my outer gradients being <code>nan</code> in mixed precision (regardless of the loss scaler value) so I made a toy example. I can’t reproduce the <code>nan</code> outer gradient with it, but it exposes another issue, namely memory consumption being larger in AMD mode:</p>\n<pre><code class=\"lang-python\">import torch\n# torch.backends.cudnn.benchmark=True\n\nDEVICE='cuda'\nN, D = 80000, 800 #may need myltiple of 8\nAMP=True\n\ndef get_data(N, D):\n x_train = torch.randn((N, D), device=DEVICE)\n x_val = torch.randn((N, D), device=DEVICE)\n true_weights = torch.randn(D, device=DEVICE)\n y_train = torch.matmul(x_train, true_weights)+ torch.randn(N, device=DEVICE)*0.05\n y_val = torch.matmul(x_val, true_weights)+ torch.randn(N, device=DEVICE)*0.05\n return x_train, y_train, x_val, y_val\n\ntorch.manual_seed(0)\ntorch.cuda.manual_seed(0)\n# with torch.cuda.amp.autocast(enabled=AMP):\nx_train, y_train, x_val, y_val = get_data(N, D)\nweights = torch.randn(D, requires_grad=True, device=DEVICE) # inner param to learn\nregularizer = torch.full((D,), 5e-4, requires_grad=True, device=DEVICE) # outer param to learn\nSCALER = 2**8 if AMP else 1\n\n## Inner loop: learn weights\nfor i in range(10):\n with torch.cuda.amp.autocast(enabled=AMP):\n y_pred_train = torch.matmul(x_train, weights)\n train_loss = torch.mean((y_train-y_pred_train)**2)\n # with torch.cuda.amp.autocast(enabled=False):\n inner_grads = torch.autograd.grad(SCALER*train_loss, weights, create_graph=True)[0]\n inner_grads = (1/SCALER)*inner_grads\n weights = weights - 0.1*inner_grads - regularizer*weights\n # print(f'train loss {train_loss:.3g} -- inner grads min {torch.min(inner_grads):.3f} max {torch.max(inner_grads):.3f}')\n print(f'memory allocated {float(torch.cuda.memory_allocated()) / (1024**3):.3g} GB')\n\n## Outer step: learn regularizer\nwith torch.cuda.amp.autocast(enabled=AMP):\n y_pred_val = torch.matmul(x_val, weights)\n val_loss = SCALER * torch.mean((y_val - y_pred_val) ** 2)\n\nval_loss.backward()\n# print(f'---> outer grads {regularizer.grad*(1/SCALER)}')\n</code></pre>\n<p>When I run this with <code>AMP=False</code> I get:</p>\n<pre><code class=\"lang-auto\">memory allocated 0.478 GB\nmemory allocated 0.479 GB\nmemory allocated 0.48 GB\nmemory allocated 0.48 GB\nmemory allocated 0.481 GB\nmemory allocated 0.481 GB\nmemory allocated 0.482 GB\nmemory allocated 0.483 GB\nmemory allocated 0.483 GB\nmemory allocated 0.484 GB\n</code></pre>\n<p>but when I run with <code>AMP=True</code> I get</p>\n<pre><code class=\"lang-auto\">memory allocated 0.597 GB\nmemory allocated 0.717 GB\nmemory allocated 0.837 GB\nmemory allocated 0.957 GB\nmemory allocated 1.08 GB\nmemory allocated 1.2 GB\nmemory allocated 1.32 GB\nmemory allocated 1.44 GB\nmemory allocated 1.56 GB\nmemory allocated 1.68 GB\n</code></pre>\n<p>What is happening here?</p>\n<p>System:<br>\nWindows 10<br>\npytorch 1.7.1<br>\nCuda 11.0<br>\nCudnn8.0<br>\nPython 3.8<br>\nRTX 3070 laptop version</p>",1133 "post_number": 1,1134 "post_type": 1,1135 "posts_count": 11,1136 "updated_at": "2021-03-22T17:18:34.145Z",1137 "reply_count": 0,1138 "reply_to_post_number": null,1139 "quote_count": 0,1140 "incoming_link_count": 183,1141 "reads": 27,1142 "readers_count": 26,1143 "score": 920.4,1144 "yours": false,1145 "topic_id": 115608,1146 "topic_slug": "mixed-precision-increases-memory-in-meta-learning",1147 "display_username": "Paul Micaelli",1148 "primary_group_name": null,1149 "flair_name": null,1150 "flair_url": null,1151 "flair_bg_color": null,1152 "flair_color": null,1153 "flair_group_id": null,1154 "badges_granted": [],1155 "version": 1,1156 "can_edit": false,1157 "can_delete": false,1158 "can_recover": false,1159 "can_see_hidden_post": false,1160 "can_wiki": false,1161 "read": true,1162 "user_title": null,1163 "bookmarked": false,1164 "actions_summary": [],1165 "moderator": false,1166 "admin": false,1167 "staff": false,1168 "user_id": 43357,1169 "hidden": false,1170 "trust_level": 1,1171 "deleted_at": null,1172 "user_deleted": false,1173 "edit_reason": null,1174 "can_view_edit_history": true,1175 "wiki": false,1176 "post_url": "/t/mixed-precision-increases-memory-in-meta-learning/115608/1",1177 "can_accept_answer": false,1178 "can_unaccept_answer": false,1179 "accepted_answer": false,1180 "topic_accepted_answer": true,1181 "can_vote": false1182 },1183 {1184 "id": 272009,1185 "name": "Paul Micaelli",1186 "username": "Paul_Micaelli",1187 "avatar_template": "/user_avatar/discuss.pytorch.org/paul_micaelli/{size}/36085_2.png",1188 "created_at": "2021-03-22T21:58:24.636Z",1189 "cooked": "<p>same behavior observed for RTX 2080 (also CUDA 11.0). Should I report this as a bug on Github <span class=\"mention\">@ptrblck_de</span> ?</p>\n<p>FYI this behavior may be specific to <code>torch.matmul</code> since replacing forward prop with some CNN leads to smaller memory allocated when <code>AMP=True</code>, which what we expect. Unfortunately the error between <code>AMD=True</code> and <code>AMD=False</code> gradients is much larger in the case of CNNs…</p>",1190 "post_number": 2,1191 "post_type": 1,1192 "posts_count": 11,1193 "updated_at": "2021-03-23T20:25:29.824Z",1194 "reply_count": 1,1195 "reply_to_post_number": null,1196 "quote_count": 0,1197 "incoming_link_count": 0,1198 "reads": 28,1199 "readers_count": 27,1200 "score": 10.6,