Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 428501,7 "name": "Chandan",8 "username": "ShaRinGan",9 "avatar_template": "/user_avatar/discuss.pytorch.org/sharingan/{size}/59100_2.png",10 "created_at": "2023-12-28T05:26:01.447Z",11 "cooked": "<p>I’m building a multi-task-learning network (Segmentation and Depth) and for that I choose U-Net Architecture. I used common encoder , separate bottle-neck and decoder. <strong>The issue I found after debugging is; I have defined two nn.ModuleList() , one for decoder_seg and another for decoder_depth; in both of them I have added layers ; but while looping through layers in forward() method, it’s only looping through decoder_seg but not through decoder_depth (it’s length is showing 0), although both are build in similar way</strong></p>\n<p>Here’s the code:</p>\n<pre><code class=\"lang-auto\">\nimport torch\nimport torch.nn as nn\nimport torchvision.transforms.functional as F\nimport torch.optim\n\n\nclass IntermediateBlocks(nn.Module):\n def __init__(self, block_in_channels, block_out_channels):\n super(IntermediateBlocks, self).__init__()\n self.block = nn.Sequential(\n\n nn.Conv2d(block_in_channels, block_out_channels,\n kernel_size=3, stride=1, padding=1, bias=False),\n nn.BatchNorm2d(block_out_channels),\n nn.ReLU(inplace=True),\n\n nn.Conv2d(block_out_channels, block_out_channels,\n kernel_size=3, stride=1, padding=1, bias=False),\n nn.BatchNorm2d(block_out_channels),\n nn.ReLU(inplace=True),\n\n )\n\n def forward(self, x):\n return self.block(x)\n\n\nclass DepthSegmentation(nn.Module):\n def __init__(self, in_channels=3, out_channels=3, intermediate_channels=None):\n super(DepthSegmentation, self).__init__()\n self.out_channels = out_channels\n\n if intermediate_channels is None:\n intermediate_channels = [64, 128, 256, 512]\n\n \"\"\" ---------------- Down-Sampling Layers --------------- \"\"\"\n self.encoder = nn.ModuleList()\n for num_channels in intermediate_channels:\n self.encoder.append(IntermediateBlocks(block_in_channels=in_channels, block_out_channels=num_channels))\n in_channels = num_channels\n self.pool = nn.MaxPool2d(kernel_size=2, stride=2)\n\n \"\"\" ---------------- Bottle Neck Layers ------------------ \"\"\"\n # One for Segmentation\n self.bottleneck_seg = IntermediateBlocks(intermediate_channels[-1], intermediate_channels[-1] * 2)\n # one for Depth Estimation\n self.bottleneck_depth = IntermediateBlocks(intermediate_channels[-1], intermediate_channels[-1] * 2)\n\n \"\"\" ----------------- Up-Sampling Layers ---------------- \"\"\"\n self.decoder_intermediate_channels = reversed(intermediate_channels) # [512, 256, 128, 64]\n\n # for segmentation\n self.decoder_seg = nn.ModuleList()\n for num_channels in self.decoder_intermediate_channels:\n self.decoder_seg.append(\n nn.ConvTranspose2d(\n num_channels * 2, num_channels, kernel_size=2, stride=2\n )\n )\n self.decoder_seg.append(IntermediateBlocks(num_channels * 2, num_channels))\n\n # for depth estimation\n self.decoder_depth = nn.ModuleList()\n for num_channels in self.decoder_intermediate_channels:\n self.decoder_depth.append(\n nn.ConvTranspose2d(\n num_channels * 2, num_channels, kernel_size=2, stride=2\n )\n )\n self.decoder_depth.append(IntermediateBlocks(num_channels * 2, num_channels))\n\n \"\"\" -------------------- Final Layers ---------------------\"\"\"\n self.final_seg = nn.Conv2d(\n in_channels=intermediate_channels[0], out_channels=self.out_channels,\n kernel_size=1, stride=1, padding=0)\n self.final_depth = nn.Conv2d(\n in_channels=intermediate_channels[0], out_channels=self.out_channels,\n kernel_size=1, stride=1, padding=0)\n\n\n def forward(self, x):\n skip_connections_layers = []\n\n for layers in self.encoder:\n # First, processing it through Intermediate Block consisting of few conv layers\n x = layers(x)\n\n \"\"\" Since, the encoder was made from few IntermediateBlocks,--- \n so for getting the skip_connections_layers (for concatenation in Decoder part),\n --- we are going to append the last layer of each IntermediateBlocks \"\"\"\n skip_connections_layers.append(x) # here the x supplied is from last layer of each Intermediate Block\n\n # MaxPooling is applied after every Intermediate Blocks (for Down-Sampling)\n x = self.pool(x)\n\n common_encoder_seg_output = x\n common_encoder_depth_output = x\n\n seg_out = self.bottleneck_seg(common_encoder_seg_output)\n depth_out = self.bottleneck_depth(common_encoder_depth_output)\n\n # As, every up-sampled layer need to be concatenated with last element(layer) present in\n # skip_connections_layers list so, it's better to reverse the list\n skip_connections_layers = skip_connections_layers[::-1]\n\n \"\"\" Since, self.decoder_seg is like ==>\n # [convTranspose2D, IntermediateBlocks, convTranspose2D, IntermediateBlocks, ..... ]\n # Here, the concatenation will be happening with only convTranspose2D layers, therefore\n # while looping, we have to use step = 2 \"\"\"\n\n print(f'Length of decoder_depth: {len(self.decoder_depth)}')\n\n print(f'Length of decoder_seg: {len(self.decoder_seg)}',\"\\n\")\n\n for i_seg in range(0, len(self.decoder_seg), 2):\n print(f\"seg_out - Before {i_seg // 2} convTranspose2D: {seg_out.shape}\")\n # First processing with convTranspose2D\n seg_out = self.decoder_seg[i_seg](seg_out)\n print(f\"seg_out - After {i_seg // 2} convTranspose2D: {seg_out.shape}\")\n required_skip_layer = skip_connections_layers[i_seg // 2]\n\n # While concatenation, we set dim = 1, because we want to do it along depth(channels)\n # Since a batch consist of ==> (batch_size, channels_dim, height, width)\n # Also, we need to make sure the shape matches\n if seg_out.shape != required_skip_layer.shape:\n # [2:] ==> height, width\n seg_out = F.resize(seg_out, size=required_skip_layer.shape[2:])\n concatenated_layer_seg = torch.cat((required_skip_layer, seg_out), dim=1)\n\n print(f\"seg_out - Before {i_seg // 2} IntermediateBlocks: {seg_out.shape}\")\n # After that, processing with IntermediateBlocks\n seg_out = self.decoder_seg[i_seg + 1](concatenated_layer_seg)\n print(f\"seg_out - After {i_seg // 2} IntermediateBlocks: {seg_out.shape}\", '\\n')\n\n\n print(f'seg_out - Before passing to final layer: {seg_out.shape}')\n\n print(\"\\n\",f'Length of decoder_depth: {len(self.decoder_depth)}')\n\n\n # Similarly for Depth Estimation head\n for i_depth in range(0, len(self.decoder_depth), 2):\n print(f\"Before depth_out: {depth_out.shape}\")\n # First processing with convTranspose2D\n depth_out = self.decoder_depth[i_depth](depth_out)\n print(f\"After depth_out: {depth_out.shape}\")\n required_skip_layer = skip_connections_layers[i_depth // 2]\n\n if depth_out.shape != required_skip_layer.shape:\n # [2:] ==> height, width\n depth_out = F.resize(depth_out, size=required_skip_layer.shape[2:])\n concatenated_layer_depth = torch.cat((required_skip_layer, depth_out), dim=1)\n\n # After that, processing with IntermediateBlocks\n depth_out = self.decoder_depth[i_depth + 1](concatenated_layer_depth)\n print(f\"After concatenated_layer_depth: {depth_out.shape}\")\n\n\n return self.final_seg(seg_out), self.final_depth(depth_out)\n\n\n\n# Dummy Input\ninput_batch = torch.randn((16, 3, 160, 160))\nmodel = DepthSegmentation(in_channels=3, out_channels=3, intermediate_channels=[64,128,256,512])\nseg_output, depth_output = model(input_batch)\n\nprint(seg_output.shape)\nprint(depth_output.shape)\n</code></pre>\n<h2><a name=\"this-is-the-error-i-got-1\" class=\"anchor\" href=\"#this-is-the-error-i-got-1\"></a>This is the error I got :</h2>\n<p>RuntimeError: Given groups=1, weight of size [3, 64, 1, 1], expected input[16, 1024, 10, 10] to have 64 channels, but got 1024 channels instead.</p>\n<p><strong>This is full error with debugging output:</strong><br>\n<div class=\"lightbox-wrapper\"><a class=\"lightbox\" href=\"https://discuss.pytorch.org/uploads/default/original/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7.png\" data-download-href=\"https://discuss.pytorch.org/uploads/default/3a0c5f4adf6beb87643eace459a78f33d73e45a7\" title=\"image\"><img src=\"https://discuss.pytorch.org/uploads/default/optimized/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7_2_690x474.png\" alt=\"image\" data-base62-sha1=\"8hwcrpDtUxTyuctHt6Tw7vyjagT\" width=\"690\" height=\"474\" srcset=\"https://discuss.pytorch.org/uploads/default/optimized/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7_2_690x474.png, https://discuss.pytorch.org/uploads/default/optimized/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7_2_1035x711.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7.png 2x\" data-dominant-color=\"242529\"><div class=\"meta\"><svg class=\"fa d-icon d-icon-far-image svg-icon\" aria-hidden=\"true\"><use href=\"#far-image\"></use></svg><span class=\"filename\">image</span><span class=\"informations\">1270×873 130 KB</span><svg class=\"fa d-icon d-icon-discourse-expand svg-icon\" aria-hidden=\"true\"><use href=\"#discourse-expand\"></use></svg></div></a></div></p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 3,15 "updated_at": "2023-12-28T06:50:53.602Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 40,20 "reads": 10,21 "readers_count": 9,22 "score": 202.0,23 "yours": false,24 "topic_id": 194472,25 "topic_slug": "defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine",26 "display_username": "Chandan",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 "link_counts": [41 {42 "url": "https://discuss.pytorch.org/uploads/default/original/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7.png",43 "internal": true,44 "reflection": false,45 "clicks": 046 }47 ],48 "read": true,49 "user_title": null,50 "bookmarked": false,51 "actions_summary": [],52 "moderator": false,53 "admin": false,54 "staff": false,55 "user_id": 64910,56 "hidden": false,57 "trust_level": 1,58 "deleted_at": null,59 "user_deleted": false,60 "edit_reason": null,61 "can_view_edit_history": true,62 "wiki": false,63 "post_url": "/t/defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine/194472/1",64 "can_accept_answer": false,65 "can_unaccept_answer": false,66 "accepted_answer": false,67 "topic_accepted_answer": null,68 "can_vote": false69 },70 {71 "id": 428975,72 "name": "Chandan",73 "username": "ShaRinGan",74 "avatar_template": "/user_avatar/discuss.pytorch.org/sharingan/{size}/59100_2.png",75 "created_at": "2024-01-03T09:19:22.664Z",76 "cooked": "<p><a class=\"mention\" href=\"/u/ptrblck\">@ptrblck</a> Please have a look.</p>",77 "post_number": 2,78 "post_type": 1,79 "posts_count": 3,80 "updated_at": "2024-01-03T09:19:22.664Z",81 "reply_count": 1,82 "reply_to_post_number": null,83 "quote_count": 0,84 "incoming_link_count": 0,85 "reads": 5,86 "readers_count": 4,87 "score": 6.0,88 "yours": false,89 "topic_id": 194472,90 "topic_slug": "defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine",91 "display_username": "Chandan",92 "primary_group_name": null,93 "flair_name": null,94 "flair_url": null,95 "flair_bg_color": null,96 "flair_color": null,97 "flair_group_id": null,98 "badges_granted": [],99 "version": 1,100 "can_edit": false,101 "can_delete": false,102 "can_recover": false,103 "can_see_hidden_post": false,104 "can_wiki": false,105 "read": true,106 "user_title": null,107 "bookmarked": false,108 "actions_summary": [],109 "moderator": false,110 "admin": false,111 "staff": false,112 "user_id": 64910,113 "hidden": false,114 "trust_level": 1,115 "deleted_at": null,116 "user_deleted": false,117 "edit_reason": null,118 "can_view_edit_history": true,119 "wiki": false,120 "post_url": "/t/defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine/194472/2",121 "can_accept_answer": false,122 "can_unaccept_answer": false,123 "accepted_answer": false,124 "topic_accepted_answer": null125 },126 {127 "id": 429015,128 "name": "",129 "username": "ptrblck",130 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",131 "created_at": "2024-01-03T15:51:42.087Z",132 "cooked": "<p><code>self.final_depth(depth_out)</code> fails since <code>depth_out</code> has a shape of <code>[16, 1024, 10, 10]</code> while <code>self.final_depth</code> expects an activation with 64 channels.</p>",133 "post_number": 3,134 "post_type": 1,135 "posts_count": 3,136 "updated_at": "2024-01-03T15:51:42.087Z",137 "reply_count": 0,138 "reply_to_post_number": 2,139 "quote_count": 0,140 "incoming_link_count": 0,141 "reads": 5,142 "readers_count": 4,143 "score": 1.0,144 "yours": false,145 "topic_id": 194472,146 "topic_slug": "defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine",147 "display_username": "",148 "primary_group_name": null,149 "flair_name": null,150 "flair_url": null,151 "flair_bg_color": null,152 "flair_color": null,153 "flair_group_id": null,154 "badges_granted": [],155 "version": 1,156 "can_edit": false,157 "can_delete": false,158 "can_recover": false,159 "can_see_hidden_post": false,160 "can_wiki": false,161 "read": true,162 "user_title": "",163 "reply_to_user": {164 "id": 64910,165 "username": "ShaRinGan",166 "name": "Chandan",167 "avatar_template": "/user_avatar/discuss.pytorch.org/sharingan/{size}/59100_2.png"168 },169 "bookmarked": false,170 "actions_summary": [],171 "moderator": true,172 "admin": true,173 "staff": true,174 "user_id": 3534,175 "hidden": false,176 "trust_level": 2,177 "deleted_at": null,178 "user_deleted": false,179 "edit_reason": null,180 "can_view_edit_history": true,181 "wiki": false,182 "post_url": "/t/defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine/194472/3",183 "can_accept_answer": false,184 "can_unaccept_answer": false,185 "accepted_answer": false,186 "topic_accepted_answer": null187 }188 ],189 "stream": [190 428501,191 428975,192 429015193 ]194 },195 "timeline_lookup": [196 [197 1,198 668199 ],200 [201 2,202 661203 ]204 ],205 "suggested_topics": [206 {207 "fancy_title": "RuntimeError: Given groups=1, weight of size [512, 1536, 3, 3], expected input[1, 1024, 32, 32] to have 1536 channels, but got 1024 channels instead",208 "id": 215634,209 "title": "RuntimeError: Given groups=1, weight of size [512, 1536, 3, 3], expected input[1, 1024, 32, 32] to have 1536 channels, but got 1024 channels instead",210 "slug": "runtimeerror-given-groups-1-weight-of-size-512-1536-3-3-expected-input-1-1024-32-32-to-have-1536-channels-but-got-1024-channels-instead",211 "posts_count": 2,212 "reply_count": 0,213 "highest_post_number": 2,214 "image_url": null,215 "created_at": "2025-01-20T16:00:44.123Z",216 "last_posted_at": "2025-01-20T16:27:27.960Z",217 "bumped": true,218 "bumped_at": "2025-01-20T16:27:27.960Z",219 "archetype": "regular",220 "unseen": false,221 "pinned": false,222 "unpinned": null,223 "visible": true,224 "closed": false,225 "archived": false,226 "bookmarked": null,227 "liked": null,228 "tags_descriptions": {},229 "like_count": 0,230 "views": 135,231 "category_id": 5,232 "featured_link": null,233 "has_accepted_answer": false,234 "posters": [235 {236 "extras": null,237 "description": "Original Poster",238 "user": {239 "id": 82196,240 "username": "jungns7234",241 "name": "성민 박",242 "avatar_template": "/user_avatar/discuss.pytorch.org/jungns7234/{size}/75209_2.png",243 "trust_level": 0244 }245 },246 {247 "extras": "latest",248 "description": "Most Recent Poster",249 "user": {250 "id": 82194,251 "username": "Sam_d",252 "name": "Sanjay Khatik",253 "avatar_template": "/user_avatar/discuss.pytorch.org/sam_d/{size}/74717_2.png",254 "trust_level": 1255 }256 }257 ]258 },259 {260 "fancy_title": "In GPU-memory compression",261 "id": 213987,262 "title": "In GPU-memory compression",263 "slug": "in-gpu-memory-compression",264 "posts_count": 1,265 "reply_count": 0,266 "highest_post_number": 1,267 "image_url": null,268 "created_at": "2024-12-09T11:15:32.161Z",269 "last_posted_at": "2024-12-09T11:15:32.219Z",270 "bumped": true,271 "bumped_at": "2024-12-09T11:15:32.219Z",272 "archetype": "regular",273 "unseen": false,274 "pinned": false,275 "unpinned": null,276 "visible": true,277 "closed": false,278 "archived": false,279 "bookmarked": null,280 "liked": null,281 "tags_descriptions": {},282 "like_count": 0,283 "views": 125,284 "category_id": 5,285 "featured_link": null,286 "has_accepted_answer": false,287 "posters": [288 {289 "extras": "latest single",290 "description": "Original Poster, Most Recent Poster",291 "user": {292 "id": 52896,293 "username": "Theophile_Champion",294 "name": "Theophile Champion",295 "avatar_template": "/user_avatar/discuss.pytorch.org/theophile_champion/{size}/30397_2.png",296 "trust_level": 1297 }298 }299 ]300 },301 {302 "fancy_title": "Is it safe to assume labels will be the same for two different directories using datasets.ImageFolder",303 "id": 214336,304 "title": "Is it safe to assume labels will be the same for two different directories using datasets.ImageFolder",305 "slug": "is-it-safe-to-assume-labels-will-be-the-same-for-two-different-directories-using-datasets-imagefolder",306 "posts_count": 3,307 "reply_count": 1,308 "highest_post_number": 3,309 "image_url": null,310 "created_at": "2024-12-17T21:53:56.157Z",311 "last_posted_at": "2024-12-19T02:42:54.893Z",312 "bumped": true,313 "bumped_at": "2024-12-19T02:42:54.893Z",314 "archetype": "regular",315 "unseen": false,316 "pinned": false,317 "unpinned": null,318 "visible": true,319 "closed": false,320 "archived": false,321 "bookmarked": null,322 "liked": null,323 "tags_descriptions": {},324 "like_count": 0,325 "views": 45,326 "category_id": 5,327 "featured_link": null,328 "has_accepted_answer": true,329 "posters": [330 {331 "extras": "latest",332 "description": "Original Poster, Most Recent Poster",333 "user": {334 "id": 81556,335 "username": "abdul_alotaibi",336 "name": "Abdulrahman Alotaibi",337 "avatar_template": "/user_avatar/discuss.pytorch.org/abdul_alotaibi/{size}/74575_2.png",338 "trust_level": 0339 }340 },341 {342 "extras": null,343 "description": "Frequent Poster, Accepted Answer",344 "user": {345 "id": 3534,346 "username": "ptrblck",347 "name": "",348 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",349 "admin": true,350 "moderator": true,351 "trust_level": 2352 }353 }354 ]355 },356 {357 "fancy_title": "Resnet101 encoder with U-Net decoder from scratch - tensor size issue",358 "id": 212738,359 "title": "Resnet101 encoder with U-Net decoder from scratch - tensor size issue",360 "slug": "resnet101-encoder-with-u-net-decoder-from-scratch-tensor-size-issue",361 "posts_count": 1,362 "reply_count": 0,363 "highest_post_number": 1,364 "image_url": null,365 "created_at": "2024-11-09T13:32:48.917Z",366 "last_posted_at": "2024-11-09T13:32:48.977Z",367 "bumped": true,368 "bumped_at": "2024-11-09T13:32:48.977Z",369 "archetype": "regular",370 "unseen": false,371 "pinned": false,372 "unpinned": null,373 "visible": true,374 "closed": false,375 "archived": false,376 "bookmarked": null,377 "liked": null,378 "tags_descriptions": {},379 "like_count": 0,380 "views": 186,381 "category_id": 5,382 "featured_link": null,383 "has_accepted_answer": false,384 "posters": [385 {386 "extras": "latest single",387 "description": "Original Poster, Most Recent Poster",388 "user": {389 "id": 80787,390 "username": "neen4",391 "name": "",392 "avatar_template": "/letter_avatar_proxy/v4/letter/n/4af34b/{size}.png",393 "trust_level": 1394 }395 }396 ]397 },398 {399 "fancy_title": "In pytorch vision repo is 3d vision model also applied?",400 "id": 220627,401 "title": "In pytorch vision repo is 3d vision model also applied?",402 "slug": "in-pytorch-vision-repo-is-3d-vision-model-also-applied",403 "posts_count": 1,404 "reply_count": 0,405 "highest_post_number": 1,406 "image_url": null,407 "created_at": "2025-06-07T07:28:15.266Z",408 "last_posted_at": "2025-06-07T07:28:15.302Z",409 "bumped": true,410 "bumped_at": "2025-06-07T07:28:15.302Z",411 "archetype": "regular",412 "unseen": false,413 "pinned": false,414 "unpinned": null,415 "visible": true,416 "closed": false,417 "archived": false,418 "bookmarked": null,419 "liked": null,420 "tags_descriptions": {},421 "like_count": 0,422 "views": 30,423 "category_id": 5,424 "featured_link": null,425 "has_accepted_answer": false,426 "posters": [427 {428 "extras": "latest single",429 "description": "Original Poster, Most Recent Poster",430 "user": {431 "id": 84588,432 "username": "reinforced",433 "name": "꼬리 웰시코기의",434 "avatar_template": "/user_avatar/discuss.pytorch.org/reinforced/{size}/77273_2.png",435 "trust_level": 0436 }437 }438 ]439 }440 ],441 "tags_descriptions": {},442 "fancy_title": "Defined two nn.ModuleList() in similar way but only one works fine",443 "id": 194472,444 "title": "Defined two nn.ModuleList() in similar way but only one works fine",445 "posts_count": 3,446 "created_at": "2023-12-28T05:26:01.353Z",447 "views": 300,448 "reply_count": 1,449 "like_count": 0,450 "last_posted_at": "2024-01-03T15:51:42.087Z",451 "visible": true,452 "closed": false,453 "archived": false,454 "has_summary": false,455 "archetype": "regular",456 "slug": "defined-two-nn-modulelist-in-similar-way-but-only-one-works-fine",457 "category_id": 5,458 "word_count": 862,459 "deleted_at": null,460 "user_id": 64910,461 "featured_link": null,462 "pinned_globally": false,463 "pinned_at": null,464 "pinned_until": null,465 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7_2_1024x703.png",466 "slow_mode_seconds": 0,467 "draft": null,468 "draft_key": "topic_194472",469 "draft_sequence": null,470 "unpinned": null,471 "pinned": false,472 "current_post_number": 1,473 "highest_post_number": 3,474 "deleted_by": null,475 "actions_summary": [476 {477 "id": 4,478 "count": 0,479 "hidden": false,480 "can_act": false481 },482 {483 "id": 8,484 "count": 0,485 "hidden": false,486 "can_act": false487 },488 {489 "id": 10,490 "count": 0,491 "hidden": false,492 "can_act": false493 },494 {495 "id": 7,496 "count": 0,497 "hidden": false,498 "can_act": false499 }500 ],501 "chunk_size": 20,502 "bookmarked": false,503 "topic_timer": null,504 "message_bus_last_id": 0,505 "participant_count": 2,506 "show_read_indicator": false,507 "thumbnails": [508 {509 "max_width": null,510 "max_height": null,511 "width": 1270,512 "height": 873,513 "url": "https://discuss.pytorch.org/uploads/default/original/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7.png"514 },515 {516 "max_width": 1024,517 "max_height": 1024,518 "width": 1024,519 "height": 703,520 "url": "https://discuss.pytorch.org/uploads/default/optimized/3X/3/a/3a0c5f4adf6beb87643eace459a78f33d73e45a7_2_1024x703.png"521 }522 ],523 "slow_mode_enabled_until": null,524 "can_vote": false,525 "vote_count": 0,526 "user_voted": false,527 "discourse_zendesk_plugin_zendesk_id": null,528 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",529 "details": {530 "can_edit": false,531 "notification_level": 1,532 "participants": [533 {534 "id": 64910,535 "username": "ShaRinGan",536 "name": "Chandan",537 "avatar_template": "/user_avatar/discuss.pytorch.org/sharingan/{size}/59100_2.png",538 "post_count": 2,539 "primary_group_name": null,540 "flair_name": null,541 "flair_url": null,542 "flair_color": null,543 "flair_bg_color": null,544 "flair_group_id": null,545 "trust_level": 1546 },547 {548 "id": 3534,549 "username": "ptrblck",550 "name": "",551 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",552 "post_count": 1,553 "primary_group_name": null,554 "flair_name": null,555 "flair_url": null,556 "flair_color": null,557 "flair_bg_color": null,558 "flair_group_id": null,559 "admin": true,560 "moderator": true,561 "trust_level": 2562 }563 ],564 "created_by": {565 "id": 64910,566 "username": "ShaRinGan",567 "name": "Chandan",568 "avatar_template": "/user_avatar/discuss.pytorch.org/sharingan/{size}/59100_2.png"569 },570 "last_poster": {571 "id": 3534,572 "username": "ptrblck",573 "name": "",574 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"575 }576 },577 "bookmarks": []578 },579 {580 "post_stream": {581 "posts": [582 {583 "id": 258559,584 "name": "Neo",585 "username": "CuriousCat-7",586 "avatar_template": "/user_avatar/discuss.pytorch.org/curiouscat-7/{size}/14227_2.png",587 "created_at": "2021-01-21T09:38:50.987Z",588 "cooked": "<pre><code class=\"lang-cpp\"> 22 void get_optical_flow( \n 23 const cv::Mat & image1, \n 24 const cv::Mat & image2, \n 25 cv::Mat & flow, //output \n >> 26 const torch::jit::script::Module & module, \n 27 const int module_input_h, \n 28 const int module_input_w){\n</code></pre>\n<p>get error</p>\n<pre><code class=\"lang-bash\">error: passing ‘const Module {aka const torch::jit::Module}’ as ‘this’ argument discards qualifiers [-fpermissive]\n at::Tensor output = module.forward(inputs).toTensor();\n</code></pre>\n<p>looks like the <code>forward</code> will change the module</p>",589 "post_number": 1,590 "post_type": 1,591 "posts_count": 2,592 "updated_at": "2021-01-21T09:38:50.987Z",593 "reply_count": 0,594 "reply_to_post_number": null,595 "quote_count": 0,596 "incoming_link_count": 105,597 "reads": 12,598 "readers_count": 11,599 "score": 527.4,600 "yours": false,601 "topic_id": 109538,602 "topic_slug": "libtorch-cannot-pass-a-const-module-into-function",603 "display_username": "Neo",604 "primary_group_name": null,605 "flair_name": null,606 "flair_url": null,607 "flair_bg_color": null,608 "flair_color": null,609 "flair_group_id": null,610 "badges_granted": [],611 "version": 1,612 "can_edit": false,613 "can_delete": false,614 "can_recover": false,615 "can_see_hidden_post": false,616 "can_wiki": false,617 "read": true,618 "user_title": null,619 "bookmarked": false,620 "actions_summary": [],621 "moderator": false,622 "admin": false,623 "staff": false,624 "user_id": 8900,625 "hidden": false,626 "trust_level": 1,627 "deleted_at": null,628 "user_deleted": false,629 "edit_reason": null,630 "can_view_edit_history": true,631 "wiki": false,632 "post_url": "/t/libtorch-cannot-pass-a-const-module-into-function/109538/1",633 "can_accept_answer": false,634 "can_unaccept_answer": false,635 "accepted_answer": false,636 "topic_accepted_answer": null,637 "can_vote": false638 },639 {640 "id": 429014,641 "name": "",642 "username": "weitaoliu",643 "avatar_template": "/letter_avatar_proxy/v4/letter/w/35a633/{size}.png",644 "created_at": "2024-01-03T15:48:29.302Z",645 "cooked": "<p>Hey, I found the same issue. If I provide the module with const, the forward function throws the same error as you got. I am unsure if it is a good idea that const cannot be applied to the module.</p>",646 "post_number": 2,647 "post_type": 1,648 "posts_count": 2,649 "updated_at": "2024-01-03T15:48:29.302Z",650 "reply_count": 0,651 "reply_to_post_number": null,652 "quote_count": 0,653 "incoming_link_count": 0,654 "reads": 4,655 "readers_count": 3,656 "score": 0.8,657 "yours": false,658 "topic_id": 109538,659 "topic_slug": "libtorch-cannot-pass-a-const-module-into-function",660 "display_username": "",661 "primary_group_name": null,662 "flair_name": null,663 "flair_url": null,664 "flair_bg_color": null,665 "flair_color": null,666 "flair_group_id": null,667 "badges_granted": [],668 "version": 1,669 "can_edit": false,670 "can_delete": false,671 "can_recover": false,672 "can_see_hidden_post": false,673 "can_wiki": false,674 "read": true,675 "user_title": null,676 "bookmarked": false,677 "actions_summary": [],678 "moderator": false,679 "admin": false,680 "staff": false,681 "user_id": 65591,682 "hidden": false,683 "trust_level": 1,684 "deleted_at": null,685 "user_deleted": false,686 "edit_reason": null,687 "can_view_edit_history": true,688 "wiki": false,689 "post_url": "/t/libtorch-cannot-pass-a-const-module-into-function/109538/2",690 "can_accept_answer": false,691 "can_unaccept_answer": false,692 "accepted_answer": false,693 "topic_accepted_answer": null694 }695 ],696 "stream": [697 258559,698 429014699 ]700 },701 "timeline_lookup": [702 [703 1,704 1738705 ],706 [707 2,708 661709 ]710 ],711 "suggested_topics": [712 {713 "fancy_title": "Why is my generator model M_gen not training when optimizing based on the classifier model M_cls?",714 "id": 216263,715 "title": "Why is my generator model M_gen not training when optimizing based on the classifier model M_cls?",716 "slug": "why-is-my-generator-model-m-gen-not-training-when-optimizing-based-on-the-classifier-model-m-cls",717 "posts_count": 7,718 "reply_count": 4,719 "highest_post_number": 7,720 "image_url": null,721 "created_at": "2025-02-05T10:43:44.579Z",722 "last_posted_at": "2025-02-09T22:42:53.438Z",723 "bumped": true,724 "bumped_at": "2025-02-09T22:42:53.438Z",725 "archetype": "regular",726 "unseen": false,727 "pinned": false,728 "unpinned": null,729 "visible": true,730 "closed": false,731 "archived": false,732 "bookmarked": null,733 "liked": null,734 "tags_descriptions": {},735 "like_count": 0,736 "views": 119,737 "category_id": 1,738 "featured_link": null,739 "has_accepted_answer": false,740 "posters": [741 {742 "extras": "latest",743 "description": "Original Poster, Most Recent Poster",744 "user": {745 "id": 82500,746 "username": "Brayn_O_Conner",747 "name": "Brayn O'Conner",748 "avatar_template": "/user_avatar/discuss.pytorch.org/brayn_o_conner/{size}/75477_2.png",749 "trust_level": 0750 }751 },752 {753 "extras": null,754 "description": "Frequent Poster",755 "user": {756 "id": 18088,757 "username": "KFrank",758 "name": "K. Frank",759 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",760 "trust_level": 2761 }762 }763 ]764 },765 {766 "fancy_title": "Checking termination condition is exceptionally slow",767 "id": 214324,768 "title": "Checking termination condition is exceptionally slow",769 "slug": "checking-termination-condition-is-exceptionally-slow",770 "posts_count": 3,771 "reply_count": 1,772 "highest_post_number": 3,773 "image_url": null,774 "created_at": "2024-12-17T16:53:47.241Z",775 "last_posted_at": "2024-12-18T08:55:09.146Z",776 "bumped": true,777 "bumped_at": "2024-12-18T08:55:09.146Z",778 "archetype": "regular",779 "unseen": false,780 "pinned": false,781 "unpinned": null,782 "visible": true,783 "closed": false,784 "archived": false,785 "bookmarked": null,786 "liked": null,787 "tags_descriptions": {},788 "like_count": 1,789 "views": 218,790 "category_id": 1,791 "featured_link": null,792 "has_accepted_answer": false,793 "posters": [794 {795 "extras": "latest",796 "description": "Original Poster, Most Recent Poster",797 "user": {798 "id": 81163,799 "username": "ViktorAJStein",800 "name": "Viktor AJ Stein",801 "avatar_template": "/letter_avatar_proxy/v4/letter/v/47e85d/{size}.png",802 "trust_level": 0803 }804 },805 {806 "extras": null,807 "description": "Frequent Poster",808 "user": {809 "id": 3534,810 "username": "ptrblck",811 "name": "",812 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",813 "admin": true,814 "moderator": true,815 "trust_level": 2816 }817 }818 ]819 },820 {821 "fancy_title": "Construct a sparse tensor while propagating gradient?",822 "id": 214430,823 "title": "Construct a sparse tensor while propagating gradient?",824 "slug": "construct-a-sparse-tensor-while-propagating-gradient",825 "posts_count": 1,826 "reply_count": 0,827 "highest_post_number": 1,828 "image_url": null,829 "created_at": "2024-12-20T02:22:47.522Z",830 "last_posted_at": "2024-12-20T02:22:47.562Z",831 "bumped": true,832 "bumped_at": "2024-12-20T02:22:47.562Z",833 "archetype": "regular",834 "unseen": false,835 "pinned": false,836 "unpinned": null,837 "visible": true,838 "closed": false,839 "archived": false,840 "bookmarked": null,841 "liked": null,842 "tags_descriptions": {},843 "like_count": 0,844 "views": 24,845 "category_id": 1,846 "featured_link": null,847 "has_accepted_answer": false,848 "posters": [849 {850 "extras": "latest single",851 "description": "Original Poster, Most Recent Poster",852 "user": {853 "id": 79111,854 "username": "MartensCedric",855 "name": "",856 "avatar_template": "/user_avatar/discuss.pytorch.org/martenscedric/{size}/72949_2.png",857 "trust_level": 1858 }859 }860 ]861 },862 {863 "fancy_title": "Bad reconstruction with LSTM",864 "id": 216219,865 "title": "Bad reconstruction with LSTM",866 "slug": "bad-reconstruction-with-lstm",867 "posts_count": 4,868 "reply_count": 2,869 "highest_post_number": 4,870 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/2/3/23dee189b147ed111b28042b030e4eba7fc1f2c4.png",871 "created_at": "2025-02-04T12:57:11.273Z",872 "last_posted_at": "2025-02-05T21:33:55.567Z",873 "bumped": true,874 "bumped_at": "2025-02-05T21:33:55.567Z",875 "archetype": "regular",876 "unseen": false,877 "pinned": false,878 "unpinned": null,879 "visible": true,880 "closed": false,881 "archived": false,882 "bookmarked": null,883 "liked": null,884 "tags_descriptions": {},885 "like_count": 0,886 "views": 182,887 "category_id": 1,888 "featured_link": null,889 "has_accepted_answer": false,890 "posters": [891 {892 "extras": "latest single",893 "description": "Original Poster, Most Recent Poster",894 "user": {895 "id": 82476,896 "username": "remy",897 "name": "",898 "avatar_template": "/letter_avatar_proxy/v4/letter/r/71e660/{size}.png",899 "trust_level": 1900 }901 }902 ]903 },904 {905 "fancy_title": "Pytorch backward and memory release question",906 "id": 218932,907 "title": "Pytorch backward and memory release question",908 "slug": "pytorch-backward-and-memory-release-question",909 "posts_count": 5,910 "reply_count": 2,911 "highest_post_number": 5,912 "image_url": null,913 "created_at": "2025-04-10T06:35:22.095Z",914 "last_posted_at": "2025-04-15T07:40:32.390Z",915 "bumped": true,916 "bumped_at": "2025-04-15T07:40:32.390Z",917 "archetype": "regular",918 "unseen": false,919 "pinned": false,920 "unpinned": null,921 "visible": true,922 "closed": false,923 "archived": false,924 "bookmarked": null,925 "liked": null,926 "tags_descriptions": {},927 "like_count": 0,928 "views": 51,929 "category_id": 1,930 "featured_link": null,931 "has_accepted_answer": false,932 "posters": [933 {934 "extras": null,935 "description": "Original Poster",936 "user": {937 "id": 83726,938 "username": "lin_li3",939 "name": "lin li",940 "avatar_template": "/user_avatar/discuss.pytorch.org/lin_li3/{size}/76549_2.png",941 "trust_level": 1942 }943 },944 {945 "extras": null,946 "description": "Frequent Poster",947 "user": {948 "id": 68149,949 "username": "Soumya_Kundu",950 "name": "Soumya Snigdha Kundu",951 "avatar_template": "/user_avatar/discuss.pytorch.org/soumya_kundu/{size}/71716_2.png",952 "trust_level": 2953 }954 },955 {956 "extras": null,957 "description": "Frequent Poster",958 "user": {959 "id": 41396,960 "username": "soulitzer",961 "name": "",962 "avatar_template": "/letter_avatar_proxy/v4/letter/s/839c29/{size}.png",963 "trust_level": 2964 }965 },966 {967 "extras": "latest",968 "description": "Most Recent Poster",969 "user": {970 "id": 83531,971 "username": "hansc",972 "name": "Hans",973 "avatar_template": "/letter_avatar_proxy/v4/letter/h/a8b319/{size}.png",974 "trust_level": 1975 }976 }977 ]978 }979 ],980 "tags_descriptions": {},981 "fancy_title": "libTorch cannot pass a const module into function",982 "id": 109538,983 "title": "libTorch cannot pass a const module into function",984 "posts_count": 2,985 "created_at": "2021-01-21T09:38:50.920Z",986 "views": 526,987 "reply_count": 0,988 "like_count": 0,989 "last_posted_at": "2024-01-03T15:48:29.302Z",990 "visible": true,991 "closed": false,992 "archived": false,993 "has_summary": false,994 "archetype": "regular",995 "slug": "libtorch-cannot-pass-a-const-module-into-function",996 "category_id": 1,997 "word_count": 107,998 "deleted_at": null,999 "user_id": 8900,1000 "featured_link": null,1001 "pinned_globally": false,1002 "pinned_at": null,1003 "pinned_until": null,1004 "image_url": null,1005 "slow_mode_seconds": 0,1006 "draft": null,1007 "draft_key": "topic_109538",1008 "draft_sequence": null,1009 "unpinned": null,1010 "pinned": false,1011 "current_post_number": 1,1012 "highest_post_number": 2,1013 "deleted_by": null,1014 "actions_summary": [1015 {1016 "id": 4,1017 "count": 0,1018 "hidden": false,1019 "can_act": false1020 },1021 {1022 "id": 8,1023 "count": 0,1024 "hidden": false,1025 "can_act": false1026 },1027 {1028 "id": 10,1029 "count": 0,1030 "hidden": false,1031 "can_act": false1032 },1033 {1034 "id": 7,1035 "count": 0,1036 "hidden": false,1037 "can_act": false1038 }1039 ],1040 "chunk_size": 20,1041 "bookmarked": false,1042 "topic_timer": null,1043 "message_bus_last_id": 0,1044 "participant_count": 2,1045 "show_read_indicator": false,1046 "thumbnails": null,1047 "slow_mode_enabled_until": null,1048 "can_vote": false,1049 "vote_count": 0,1050 "user_voted": false,1051 "discourse_zendesk_plugin_zendesk_id": null,1052 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1053 "details": {1054 "can_edit": false,1055 "notification_level": 1,1056 "participants": [1057 {1058 "id": 8900,1059 "username": "CuriousCat-7",1060 "name": "Neo",1061 "avatar_template": "/user_avatar/discuss.pytorch.org/curiouscat-7/{size}/14227_2.png",1062 "post_count": 1,1063 "primary_group_name": null,1064 "flair_name": null,1065 "flair_url": null,1066 "flair_color": null,1067 "flair_bg_color": null,1068 "flair_group_id": null,1069 "trust_level": 11070 },1071 {1072 "id": 65591,1073 "username": "weitaoliu",1074 "name": "",1075 "avatar_template": "/letter_avatar_proxy/v4/letter/w/35a633/{size}.png",1076 "post_count": 1,1077 "primary_group_name": null,1078 "flair_name": null,1079 "flair_url": null,1080 "flair_color": null,1081 "flair_bg_color": null,1082 "flair_group_id": null,1083 "trust_level": 11084 }1085 ],1086 "created_by": {1087 "id": 8900,1088 "username": "CuriousCat-7",1089 "name": "Neo",1090 "avatar_template": "/user_avatar/discuss.pytorch.org/curiouscat-7/{size}/14227_2.png"1091 },1092 "last_poster": {1093 "id": 65591,1094 "username": "weitaoliu",1095 "name": "",1096 "avatar_template": "/letter_avatar_proxy/v4/letter/w/35a633/{size}.png"1097 }1098 },1099 "bookmarks": []1100 },1101 {1102 "post_stream": {1103 "posts": [1104 {1105 "id": 428912,1106 "name": "Jean Patrick Pommier",1107 "username": "dip4fish",1108 "avatar_template": "/user_avatar/discuss.pytorch.org/dip4fish/{size}/914_2.png",1109 "created_at": "2024-01-02T16:00:17.050Z",1110 "cooked": "<p>Hi,<br>\nMy computer has a non AVX CPU (xeon x5570). Can a pytorch 2.x based code run on my computer?<br>\nThanks</p>",1111 "post_number": 1,1112 "post_type": 1,1113 "posts_count": 4,1114 "updated_at": "2024-01-02T16:00:17.050Z",1115 "reply_count": 0,1116 "reply_to_post_number": null,1117 "quote_count": 0,1118 "incoming_link_count": 748,1119 "reads": 12,1120 "readers_count": 11,1121 "score": 3697.4,1122 "yours": false,1123 "topic_id": 194717,1124 "topic_slug": "an-avx512-capable-cpu-mandatory-for-pytorch-2-pytorch-lightning",1125 "display_username": "Jean Patrick Pommier",1126 "primary_group_name": null,1127 "flair_name": null,1128 "flair_url": null,1129 "flair_bg_color": null,1130 "flair_color": null,1131 "flair_group_id": null,1132 "badges_granted": [],1133 "version": 1,1134 "can_edit": false,1135 "can_delete": false,1136 "can_recover": false,1137 "can_see_hidden_post": false,1138 "can_wiki": false,1139 "read": true,1140 "user_title": null,1141 "bookmarked": false,1142 "actions_summary": [],1143 "moderator": false,1144 "admin": false,1145 "staff": false,1146 "user_id": 546,1147 "hidden": false,1148 "trust_level": 1,1149 "deleted_at": null,1150 "user_deleted": false,1151 "edit_reason": null,1152 "can_view_edit_history": true,1153 "wiki": false,1154 "post_url": "/t/an-avx512-capable-cpu-mandatory-for-pytorch-2-pytorch-lightning/194717/1",1155 "can_accept_answer": false,1156 "can_unaccept_answer": false,1157 "accepted_answer": false,1158 "topic_accepted_answer": null,1159 "can_vote": false1160 },1161 {1162 "id": 428924,1163 "name": "",1164 "username": "smth",1165 "avatar_template": "/user_avatar/discuss.pytorch.org/smth/{size}/13_2.png",1166 "created_at": "2024-01-02T18:16:18.181Z",1167 "cooked": "<p>AVX512 is not mandatory. The minimal assumption is AVX1 I believe.</p>\n<p>The default PyTorch binaries are built with AVX1, AVX2 and AVX512 optimizations but AVX512 is gated behind runtime dispatch.</p>\n<p>If for some reason you are seeing <code>illegal instruction</code> errors, you can build PyTorch from source.</p>",1168 "post_number": 2,1169 "post_type": 1,1170 "posts_count": 4,1171 "updated_at": "2024-01-02T18:16:18.181Z",1172 "reply_count": 1,1173 "reply_to_post_number": null,1174 "quote_count": 0,1175 "incoming_link_count": 6,1176 "reads": 12,1177 "readers_count": 11,1178 "score": 37.4,1179 "yours": false,1180 "topic_id": 194717,1181 "topic_slug": "an-avx512-capable-cpu-mandatory-for-pytorch-2-pytorch-lightning",1182 "display_username": "",1183 "primary_group_name": null,1184 "flair_name": null,1185 "flair_url": null,1186 "flair_bg_color": null,1187 "flair_color": null,1188 "flair_group_id": null,1189 "badges_granted": [],1190 "version": 1,1191 "can_edit": false,1192 "can_delete": false,1193 "can_recover": false,1194 "can_see_hidden_post": false,1195 "can_wiki": false,1196 "read": true,1197 "user_title": "PyTorch Dev, Facebook AI Research",1198 "title_is_group": false,1199 "bookmarked": false,1200 "actions_summary": [],