Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 359537,7 "name": "Nosin Ibna Mahbub",8 "username": "Nosin_Ibna_Mahbub",9 "avatar_template": "/user_avatar/discuss.pytorch.org/nosin_ibna_mahbub/{size}/44733_2.png",10 "created_at": "2022-08-02T13:02:17.844Z",11 "cooked": "<p>Hello, I am trying to segment medical image and i need help on creating a DataLoader to take into a CNN .mat images. My main image and mask are saved in a same mat file. So, I need help to create custom dataloader to read the main image and mask from the same mat file. Thank you</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 4,15 "updated_at": "2022-08-02T13:02:17.844Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 241,20 "reads": 9,21 "readers_count": 8,22 "score": 1196.8,23 "yours": false,24 "topic_id": 158129,25 "topic_slug": "custom-dataloader-using-mat-file",26 "display_username": "Nosin Ibna Mahbub",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 "moderator": false,45 "admin": false,46 "staff": false,47 "user_id": 58192,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/custom-dataloader-using-mat-file/158129/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 "id": 359547,64 "name": "Kevin T",65 "username": "nivek",66 "avatar_template": "/user_avatar/discuss.pytorch.org/nivek/{size}/39672_2.png",67 "created_at": "2022-08-02T13:57:54.904Z",68 "cooked": "<p>Hi, please have a look at our <a href=\"https://pytorch.org/tutorials/beginner/basics/data_tutorial.html\" rel=\"noopener nofollow ugc\">tutorial</a> and let us know what you have tried.</p>",69 "post_number": 2,70 "post_type": 1,71 "posts_count": 4,72 "updated_at": "2022-08-02T13:57:54.904Z",73 "reply_count": 1,74 "reply_to_post_number": null,75 "quote_count": 0,76 "incoming_link_count": 8,77 "reads": 7,78 "readers_count": 6,79 "score": 46.4,80 "yours": false,81 "topic_id": 158129,82 "topic_slug": "custom-dataloader-using-mat-file",83 "display_username": "Kevin T",84 "primary_group_name": null,85 "flair_name": null,86 "flair_url": null,87 "flair_bg_color": null,88 "flair_color": null,89 "flair_group_id": null,90 "badges_granted": [],91 "version": 1,92 "can_edit": false,93 "can_delete": false,94 "can_recover": false,95 "can_see_hidden_post": false,96 "can_wiki": false,97 "link_counts": [98 {99 "url": "https://pytorch.org/tutorials/beginner/basics/data_tutorial.html",100 "internal": false,101 "reflection": false,102 "title": "Datasets & DataLoaders — PyTorch Tutorials 1.12.0+cu102 documentation",103 "clicks": 49104 }105 ],106 "read": true,107 "user_title": "",108 "bookmarked": false,109 "actions_summary": [],110 "moderator": false,111 "admin": false,112 "staff": false,113 "user_id": 46614,114 "hidden": false,115 "trust_level": 2,116 "deleted_at": null,117 "user_deleted": false,118 "edit_reason": null,119 "can_view_edit_history": true,120 "wiki": false,121 "post_url": "/t/custom-dataloader-using-mat-file/158129/2",122 "can_accept_answer": false,123 "can_unaccept_answer": false,124 "accepted_answer": false,125 "topic_accepted_answer": null126 },127 {128 "id": 359585,129 "name": "Nosin Ibna Mahbub",130 "username": "Nosin_Ibna_Mahbub",131 "avatar_template": "/user_avatar/discuss.pytorch.org/nosin_ibna_mahbub/{size}/44733_2.png",132 "created_at": "2022-08-02T16:15:39.049Z",133 "cooked": "<p>Thanks for your reply.<br>\nI have around 4000 mat files. Each mat file contains main image and mask which is shown in the following image. I have to make custom dataloader for this dataset to train the model.<br>\n<div class=\"lightbox-wrapper\"><a class=\"lightbox\" href=\"https://discuss.pytorch.org/uploads/default/original/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d.jpeg\" data-download-href=\"https://discuss.pytorch.org/uploads/default/27cc7a4afbe6786f9be1fb619bbbaf782708001d\" title=\"mat_file_read\"><img src=\"https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d_2_690x314.jpeg\" alt=\"mat_file_read\" data-base62-sha1=\"5G4Ic3r3tOG7otElj3kvuzr1TwV\" width=\"690\" height=\"314\" srcset=\"https://discuss.pytorch.org/uploads/default/optimized/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d_2_690x314.jpeg, https://discuss.pytorch.org/uploads/default/original/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d.jpeg 2x\" data-dominant-color=\"F5F5F5\"><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\">mat_file_read</span><span class=\"informations\">724×330 50.8 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>",134 "post_number": 4,135 "post_type": 1,136 "posts_count": 4,137 "updated_at": "2022-08-02T16:15:39.049Z",138 "reply_count": 1,139 "reply_to_post_number": 2,140 "quote_count": 0,141 "incoming_link_count": 14,142 "reads": 7,143 "readers_count": 6,144 "score": 76.4,145 "yours": false,146 "topic_id": 158129,147 "topic_slug": "custom-dataloader-using-mat-file",148 "display_username": "Nosin Ibna Mahbub",149 "primary_group_name": null,150 "flair_name": null,151 "flair_url": null,152 "flair_bg_color": null,153 "flair_color": null,154 "flair_group_id": null,155 "badges_granted": [],156 "version": 1,157 "can_edit": false,158 "can_delete": false,159 "can_recover": false,160 "can_see_hidden_post": false,161 "can_wiki": false,162 "link_counts": [163 {164 "url": "https://discuss.pytorch.org/uploads/default/original/3X/2/7/27cc7a4afbe6786f9be1fb619bbbaf782708001d.jpeg",165 "internal": true,166 "reflection": false,167 "clicks": 0168 }169 ],170 "read": true,171 "user_title": null,172 "reply_to_user": {173 "id": 46614,174 "username": "nivek",175 "name": "Kevin T",176 "avatar_template": "/user_avatar/discuss.pytorch.org/nivek/{size}/39672_2.png"177 },178 "bookmarked": false,179 "actions_summary": [],180 "moderator": false,181 "admin": false,182 "staff": false,183 "user_id": 58192,184 "hidden": false,185 "trust_level": 1,186 "deleted_at": null,187 "user_deleted": false,188 "edit_reason": null,189 "can_view_edit_history": true,190 "wiki": false,191 "post_url": "/t/custom-dataloader-using-mat-file/158129/4",192 "can_accept_answer": false,193 "can_unaccept_answer": false,194 "accepted_answer": false,195 "topic_accepted_answer": null196 },197 {198 "id": 359589,199 "name": "",200 "username": "ptrblck",201 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",202 "created_at": "2022-08-02T16:29:50.225Z",203 "cooked": "<p>Writing a custom <code>Dataset</code> as mentioned by <a class=\"mention\" href=\"/u/nivek\">@nivek</a> sounds like the right approach and you could use e.g. <a href=\"https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html\"><code>scipy.io.loadmat</code></a> to load each <code>.mat</code> file.</p>",204 "post_number": 5,205 "post_type": 1,206 "posts_count": 4,207 "updated_at": "2022-08-02T16:29:50.225Z",208 "reply_count": 0,209 "reply_to_post_number": 4,210 "quote_count": 0,211 "incoming_link_count": 1,212 "reads": 7,213 "readers_count": 6,214 "score": 6.4,215 "yours": false,216 "topic_id": 158129,217 "topic_slug": "custom-dataloader-using-mat-file",218 "display_username": "",219 "primary_group_name": null,220 "flair_name": null,221 "flair_url": null,222 "flair_bg_color": null,223 "flair_color": null,224 "flair_group_id": null,225 "badges_granted": [],226 "version": 1,227 "can_edit": false,228 "can_delete": false,229 "can_recover": false,230 "can_see_hidden_post": false,231 "can_wiki": false,232 "link_counts": [233 {234 "url": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html",235 "internal": false,236 "reflection": false,237 "title": "scipy.io.loadmat — SciPy v1.9.0 Manual",238 "clicks": 13239 }240 ],241 "read": true,242 "user_title": "",243 "reply_to_user": {244 "id": 58192,245 "username": "Nosin_Ibna_Mahbub",246 "name": "Nosin Ibna Mahbub",247 "avatar_template": "/user_avatar/discuss.pytorch.org/nosin_ibna_mahbub/{size}/44733_2.png"248 },249 "bookmarked": false,250 "actions_summary": [],251 "moderator": true,252 "admin": true,253 "staff": true,254 "user_id": 3534,255 "hidden": false,256 "trust_level": 2,257 "deleted_at": null,258 "user_deleted": false,259 "edit_reason": null,260 "can_view_edit_history": true,261 "wiki": false,262 "post_url": "/t/custom-dataloader-using-mat-file/158129/5",263 "can_accept_answer": false,264 "can_unaccept_answer": false,265 "accepted_answer": false,266 "topic_accepted_answer": null267 }268 ],269 "stream": [270 359537,271 359547,272 359585,273 359589274 ]275 },276 "timeline_lookup": [277 [278 1,279 1180280 ]281 ],282 "suggested_topics": [283 {284 "fancy_title": "Handling a priori on covariate variables for RNN",285 "id": 219459,286 "title": "Handling a priori on covariate variables for RNN",287 "slug": "handling-a-priori-on-covariate-variables-for-rnn",288 "posts_count": 1,289 "reply_count": 0,290 "highest_post_number": 1,291 "image_url": null,292 "created_at": "2025-04-25T13:09:36.635Z",293 "last_posted_at": "2025-04-25T13:09:36.675Z",294 "bumped": true,295 "bumped_at": "2025-04-25T13:09:36.675Z",296 "archetype": "regular",297 "unseen": false,298 "pinned": false,299 "unpinned": null,300 "visible": true,301 "closed": false,302 "archived": false,303 "bookmarked": null,304 "liked": null,305 "tags_descriptions": {},306 "like_count": 0,307 "views": 26,308 "category_id": 37,309 "featured_link": null,310 "has_accepted_answer": false,311 "posters": [312 {313 "extras": "latest single",314 "description": "Original Poster, Most Recent Poster",315 "user": {316 "id": 83959,317 "username": "Eyzzle",318 "name": "",319 "avatar_template": "/letter_avatar_proxy/v4/letter/e/ad7895/{size}.png",320 "trust_level": 1321 }322 }323 ]324 },325 {326 "fancy_title": "Pairwise distance calc for large tensors",327 "id": 215065,328 "title": "Pairwise distance calc for large tensors",329 "slug": "pairwise-distance-calc-for-large-tensors",330 "posts_count": 2,331 "reply_count": 0,332 "highest_post_number": 2,333 "image_url": null,334 "created_at": "2025-01-07T10:27:01.090Z",335 "last_posted_at": "2025-01-07T19:41:32.411Z",336 "bumped": true,337 "bumped_at": "2025-01-07T19:41:32.411Z",338 "archetype": "regular",339 "unseen": false,340 "pinned": false,341 "unpinned": null,342 "visible": true,343 "closed": false,344 "archived": false,345 "bookmarked": null,346 "liked": null,347 "tags_descriptions": {},348 "like_count": 0,349 "views": 198,350 "category_id": 37,351 "featured_link": null,352 "has_accepted_answer": false,353 "posters": [354 {355 "extras": null,356 "description": "Original Poster",357 "user": {358 "id": 81920,359 "username": "abrahamezzeddine",360 "name": "Abrahamezzeddine",361 "avatar_template": "/user_avatar/discuss.pytorch.org/abrahamezzeddine/{size}/74944_2.png",362 "trust_level": 1363 }364 },365 {366 "extras": "latest",367 "description": "Most Recent Poster",368 "user": {369 "id": 18088,370 "username": "KFrank",371 "name": "K. Frank",372 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",373 "trust_level": 2374 }375 }376 ]377 },378 {379 "fancy_title": "Faster R-CNN Over-Detecting",380 "id": 214378,381 "title": "Faster R-CNN Over-Detecting",382 "slug": "faster-r-cnn-over-detecting",383 "posts_count": 1,384 "reply_count": 0,385 "highest_post_number": 1,386 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/0/f/0f6cd26168480523e3ac14a8816b9487826020b4_2_1024x1022.jpeg",387 "created_at": "2024-12-19T00:46:42.172Z",388 "last_posted_at": "2024-12-19T00:46:42.210Z",389 "bumped": true,390 "bumped_at": "2024-12-19T00:46:42.210Z",391 "archetype": "regular",392 "unseen": false,393 "pinned": false,394 "unpinned": null,395 "visible": true,396 "closed": false,397 "archived": false,398 "bookmarked": null,399 "liked": null,400 "tags_descriptions": {},401 "like_count": 0,402 "views": 169,403 "category_id": 37,404 "featured_link": null,405 "has_accepted_answer": false,406 "posters": [407 {408 "extras": "latest single",409 "description": "Original Poster, Most Recent Poster",410 "user": {411 "id": 81578,412 "username": "sahajp0",413 "name": null,414 "avatar_template": "/user_avatar/discuss.pytorch.org/sahajp0/{size}/74601_2.png",415 "trust_level": 1416 }417 }418 ]419 },420 {421 "fancy_title": "RuntimeError: result type Float can’t be cast to the desired output type Long—",422 "id": 215625,423 "title": "RuntimeError: result type Float can't be cast to the desired output type Long---",424 "slug": "runtimeerror-result-type-float-cant-be-cast-to-the-desired-output-type-long",425 "posts_count": 3,426 "reply_count": 2,427 "highest_post_number": 4,428 "image_url": null,429 "created_at": "2025-01-20T12:55:19.831Z",430 "last_posted_at": "2025-01-24T06:58:11.891Z",431 "bumped": true,432 "bumped_at": "2025-01-24T06:58:11.891Z",433 "archetype": "regular",434 "unseen": false,435 "pinned": false,436 "unpinned": null,437 "visible": true,438 "closed": false,439 "archived": false,440 "bookmarked": null,441 "liked": null,442 "tags_descriptions": {},443 "like_count": 0,444 "views": 101,445 "category_id": 37,446 "featured_link": null,447 "has_accepted_answer": false,448 "posters": [449 {450 "extras": "latest",451 "description": "Original Poster, Most Recent Poster",452 "user": {453 "id": 82195,454 "username": "fuad47",455 "name": "fuad",456 "avatar_template": "/user_avatar/discuss.pytorch.org/fuad47/{size}/75208_2.png",457 "trust_level": 0458 }459 },460 {461 "extras": null,462 "description": "Frequent Poster",463 "user": {464 "id": 3534,465 "username": "ptrblck",466 "name": "",467 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",468 "admin": true,469 "moderator": true,470 "trust_level": 2471 }472 }473 ]474 },475 {476 "fancy_title": "Unexpected DataLoader hanging when torch.set_num_threads in worker init",477 "id": 219991,478 "title": "Unexpected DataLoader hanging when torch.set_num_threads in worker init",479 "slug": "unexpected-dataloader-hanging-when-torch-set-num-threads-in-worker-init",480 "posts_count": 1,481 "reply_count": 0,482 "highest_post_number": 1,483 "image_url": null,484 "created_at": "2025-05-13T13:58:40.791Z",485 "last_posted_at": "2025-05-13T13:58:40.835Z",486 "bumped": true,487 "bumped_at": "2025-05-13T13:58:40.835Z",488 "archetype": "regular",489 "unseen": false,490 "pinned": false,491 "unpinned": null,492 "visible": true,493 "closed": false,494 "archived": false,495 "bookmarked": null,496 "liked": null,497 "tags_descriptions": {},498 "like_count": 0,499 "views": 43,500 "category_id": 37,501 "featured_link": null,502 "has_accepted_answer": false,503 "posters": [504 {505 "extras": "latest single",506 "description": "Original Poster, Most Recent Poster",507 "user": {508 "id": 49289,509 "username": "Sohrab_Andaz",510 "name": "Sohrab Andaz",511 "avatar_template": "/user_avatar/discuss.pytorch.org/sohrab_andaz/{size}/42486_2.png",512 "trust_level": 1513 }514 }515 ]516 }517 ],518 "tags_descriptions": {},519 "fancy_title": "Custom DataLoader using .mat file",520 "id": 158129,521 "title": "Custom DataLoader using .mat file",522 "posts_count": 4,523 "created_at": "2022-08-02T13:02:17.781Z",524 "views": 648,525 "reply_count": 2,526 "like_count": 0,527 "last_posted_at": "2022-08-02T16:29:50.225Z",528 "visible": true,529 "closed": false,530 "archived": false,531 "has_summary": false,532 "archetype": "regular",533 "slug": "custom-dataloader-using-mat-file",534 "category_id": 37,535 "word_count": 167,536 "deleted_at": null,537 "user_id": 58192,538 "featured_link": null,539 "pinned_globally": false,540 "pinned_at": null,541 "pinned_until": null,542 "image_url": null,543 "slow_mode_seconds": 0,544 "draft": null,545 "draft_key": "topic_158129",546 "draft_sequence": null,547 "unpinned": null,548 "pinned": false,549 "current_post_number": 1,550 "highest_post_number": 5,551 "deleted_by": null,552 "actions_summary": [553 {554 "id": 4,555 "count": 0,556 "hidden": false,557 "can_act": false558 },559 {560 "id": 8,561 "count": 0,562 "hidden": false,563 "can_act": false564 },565 {566 "id": 10,567 "count": 0,568 "hidden": false,569 "can_act": false570 },571 {572 "id": 7,573 "count": 0,574 "hidden": false,575 "can_act": false576 }577 ],578 "chunk_size": 20,579 "bookmarked": false,580 "topic_timer": null,581 "message_bus_last_id": 0,582 "participant_count": 3,583 "show_read_indicator": false,584 "thumbnails": null,585 "slow_mode_enabled_until": null,586 "can_vote": false,587 "vote_count": 0,588 "user_voted": false,589 "discourse_zendesk_plugin_zendesk_id": null,590 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",591 "details": {592 "can_edit": false,593 "notification_level": 1,594 "participants": [595 {596 "id": 58192,597 "username": "Nosin_Ibna_Mahbub",598 "name": "Nosin Ibna Mahbub",599 "avatar_template": "/user_avatar/discuss.pytorch.org/nosin_ibna_mahbub/{size}/44733_2.png",600 "post_count": 2,601 "primary_group_name": null,602 "flair_name": null,603 "flair_url": null,604 "flair_color": null,605 "flair_bg_color": null,606 "flair_group_id": null,607 "trust_level": 1608 },609 {610 "id": 3534,611 "username": "ptrblck",612 "name": "",613 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",614 "post_count": 1,615 "primary_group_name": null,616 "flair_name": null,617 "flair_url": null,618 "flair_color": null,619 "flair_bg_color": null,620 "flair_group_id": null,621 "admin": true,622 "moderator": true,623 "trust_level": 2624 },625 {626 "id": 46614,627 "username": "nivek",628 "name": "Kevin T",629 "avatar_template": "/user_avatar/discuss.pytorch.org/nivek/{size}/39672_2.png",630 "post_count": 1,631 "primary_group_name": null,632 "flair_name": null,633 "flair_url": null,634 "flair_color": null,635 "flair_bg_color": null,636 "flair_group_id": null,637 "trust_level": 2638 }639 ],640 "created_by": {641 "id": 58192,642 "username": "Nosin_Ibna_Mahbub",643 "name": "Nosin Ibna Mahbub",644 "avatar_template": "/user_avatar/discuss.pytorch.org/nosin_ibna_mahbub/{size}/44733_2.png"645 },646 "last_poster": {647 "id": 3534,648 "username": "ptrblck",649 "name": "",650 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"651 },652 "links": [653 {654 "url": "https://pytorch.org/tutorials/beginner/basics/data_tutorial.html",655 "title": "Datasets & DataLoaders — PyTorch Tutorials 1.12.0+cu102 documentation",656 "internal": false,657 "attachment": false,658 "reflection": false,659 "clicks": 49,660 "user_id": 46614,661 "domain": "pytorch.org",662 "root_domain": "pytorch.org"663 },664 {665 "url": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.io.loadmat.html",666 "title": "scipy.io.loadmat — SciPy v1.9.0 Manual",667 "internal": false,668 "attachment": false,669 "reflection": false,670 "clicks": 13,671 "user_id": 3534,672 "domain": "docs.scipy.org",673 "root_domain": "scipy.org"674 }675 ]676 },677 "bookmarks": []678 },679 {680 "post_stream": {681 "posts": [682 {683 "id": 352733,684 "name": "",685 "username": "peppermint",686 "avatar_template": "/letter_avatar_proxy/v4/letter/p/dfb087/{size}.png",687 "created_at": "2022-06-21T16:57:01.271Z",688 "cooked": "<p><strong>TL;DR</strong>, does computing <code>torch.var(x)</code> on a 1D tensor of n values have a quadratic runtime with autograd? Or does autograd it have a linear runtime in n?</p>\n<p><strong>Longer version:</strong><br>\nIf I have n values in a 1D tensor, and I compute var within a nn.Module, will autograd compute an n by n Jacobian in quadratic runtime?</p>\n<p>For example, if we have values<br>\n<code>x = torch.tensor([1.,2.,4.,8.,16.,32.,64.], requires_grad=True)</code><br>\nthen <code>y = torch.var(x)</code> will set <code>grad_fn</code> in <code>y</code>.</p>\n<p>The variance can be conceptualized as computing all pairwise distances (with a quadratic number of operations) and shifting and scaling:<br>\n<code>torch.sum( (x.view(-1,1) - x.view(1,-1))**2 / (2*len(x)*(len(x)-1)) )</code></p>\n<p>Or the varaince can be conceptualized as caching the mean (with a linear number of operations), computing all distances to that mean (also linear) and then scaling the result:<br>\n<code>torch.sum( (x - torch.mean(x))**2 / (len(x)-1) )</code></p>\n<p>In the first way, it’s clear that all pairs of values in <code>x</code> affect <code>torch.var</code>, and so an n by n matrix will be computed by autograd.</p>\n<p>In the second (more standard way), the mean is cached, with autograd depicting a dependency of the mean on each value from <code>x</code>. Then, the mean collides with every value from <code>x</code> to compute the variance. So in this case, it appears the gradients will be quadratic as well. Is that the case?</p>\n<p>Also, how is there a way that I could’ve delved into <code>y.grad_fn</code> to determine this for myself without asking and without empirically measuring whether the runtimes seem to grow quadratically? Thank you!</p>",689 "post_number": 1,690 "post_type": 1,691 "posts_count": 2,692 "updated_at": "2022-06-21T16:57:01.271Z",693 "reply_count": 0,694 "reply_to_post_number": null,695 "quote_count": 0,696 "incoming_link_count": 13,697 "reads": 6,698 "readers_count": 5,699 "score": 66.2,700 "yours": false,701 "topic_id": 154717,702 "topic_slug": "does-autograd-on-var-give-a-quadratic-runtime",703 "display_username": "",704 "primary_group_name": null,705 "flair_name": null,706 "flair_url": null,707 "flair_bg_color": null,708 "flair_color": null,709 "flair_group_id": null,710 "badges_granted": [],711 "version": 1,712 "can_edit": false,713 "can_delete": false,714 "can_recover": false,715 "can_see_hidden_post": false,716 "can_wiki": false,717 "read": true,718 "user_title": null,719 "bookmarked": false,720 "actions_summary": [],721 "moderator": false,722 "admin": false,723 "staff": false,724 "user_id": 52851,725 "hidden": false,726 "trust_level": 1,727 "deleted_at": null,728 "user_deleted": false,729 "edit_reason": null,730 "can_view_edit_history": true,731 "wiki": false,732 "post_url": "/t/does-autograd-on-var-give-a-quadratic-runtime/154717/1",733 "can_accept_answer": false,734 "can_unaccept_answer": false,735 "accepted_answer": false,736 "topic_accepted_answer": null,737 "can_vote": false738 },739 {740 "id": 359587,741 "name": "",742 "username": "peppermint",743 "avatar_template": "/letter_avatar_proxy/v4/letter/p/dfb087/{size}.png",744 "created_at": "2022-08-02T16:25:59.808Z",745 "cooked": "<p>Just bumping this in case it got lost during summer holidays. Any thoughts are appreciated!</p>",746 "post_number": 2,747 "post_type": 1,748 "posts_count": 2,749 "updated_at": "2022-08-02T16:25:59.808Z",750 "reply_count": 0,751 "reply_to_post_number": null,752 "quote_count": 0,753 "incoming_link_count": 0,754 "reads": 5,755 "readers_count": 4,756 "score": 1.0,757 "yours": false,758 "topic_id": 154717,759 "topic_slug": "does-autograd-on-var-give-a-quadratic-runtime",760 "display_username": "",761 "primary_group_name": null,762 "flair_name": null,763 "flair_url": null,764 "flair_bg_color": null,765 "flair_color": null,766 "flair_group_id": null,767 "badges_granted": [],768 "version": 1,769 "can_edit": false,770 "can_delete": false,771 "can_recover": false,772 "can_see_hidden_post": false,773 "can_wiki": false,774 "read": true,775 "user_title": null,776 "bookmarked": false,777 "actions_summary": [],778 "moderator": false,779 "admin": false,780 "staff": false,781 "user_id": 52851,782 "hidden": false,783 "trust_level": 1,784 "deleted_at": null,785 "user_deleted": false,786 "edit_reason": null,787 "can_view_edit_history": true,788 "wiki": false,789 "post_url": "/t/does-autograd-on-var-give-a-quadratic-runtime/154717/2",790 "can_accept_answer": false,791 "can_unaccept_answer": false,792 "accepted_answer": false,793 "topic_accepted_answer": null794 }795 ],796 "stream": [797 352733,798 359587799 ]800 },801 "timeline_lookup": [802 [803 1,804 1222805 ],806 [807 2,808 1180809 ]810 ],811 "suggested_topics": [812 {813 "fancy_title": "Wrong dimension of per sample gradients",814 "id": 213902,815 "title": "Wrong dimension of per sample gradients",816 "slug": "wrong-dimension-of-per-sample-gradients",817 "posts_count": 2,818 "reply_count": 0,819 "highest_post_number": 2,820 "image_url": null,821 "created_at": "2024-12-06T08:56:22.607Z",822 "last_posted_at": "2024-12-09T15:45:35.401Z",823 "bumped": true,824 "bumped_at": "2024-12-09T15:45:35.401Z",825 "archetype": "regular",826 "unseen": false,827 "pinned": false,828 "unpinned": null,829 "visible": true,830 "closed": false,831 "archived": false,832 "bookmarked": null,833 "liked": null,834 "tags_descriptions": {},835 "like_count": 0,836 "views": 39,837 "category_id": 7,838 "featured_link": null,839 "has_accepted_answer": false,840 "posters": [841 {842 "extras": "latest single",843 "description": "Original Poster, Most Recent Poster",844 "user": {845 "id": 81353,846 "username": "jspieler",847 "name": "",848 "avatar_template": "/letter_avatar_proxy/v4/letter/j/aeb1de/{size}.png",849 "trust_level": 1850 }851 }852 ]853 },854 {855 "fancy_title": "Initializing tensor inside custom loss fn causes cuda memory err",856 "id": 217711,857 "title": "Initializing tensor inside custom loss fn causes cuda memory err",858 "slug": "initializing-tensor-inside-custom-loss-fn-causes-cuda-memory-err",859 "posts_count": 6,860 "reply_count": 4,861 "highest_post_number": 6,862 "image_url": null,863 "created_at": "2025-03-11T19:26:00.836Z",864 "last_posted_at": "2025-03-12T20:54:40.956Z",865 "bumped": true,866 "bumped_at": "2025-03-12T20:54:40.956Z",867 "archetype": "regular",868 "unseen": false,869 "pinned": false,870 "unpinned": null,871 "visible": true,872 "closed": false,873 "archived": false,874 "bookmarked": null,875 "liked": null,876 "tags_descriptions": {},877 "like_count": 0,878 "views": 150,879 "category_id": 7,880 "featured_link": null,881 "has_accepted_answer": false,882 "posters": [883 {884 "extras": null,885 "description": "Original Poster",886 "user": {887 "id": 29555,888 "username": "hectorist",889 "name": "Yusuf B. Tanriverdi",890 "avatar_template": "/user_avatar/discuss.pytorch.org/hectorist/{size}/76097_2.png",891 "trust_level": 1892 }893 },894 {895 "extras": "latest",896 "description": "Most Recent Poster",897 "user": {898 "id": 3534,899 "username": "ptrblck",900 "name": "",901 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",902 "admin": true,903 "moderator": true,904 "trust_level": 2905 }906 }907 ]908 },909 {910 "fancy_title": "Freezing CNN Channels",911 "id": 216265,912 "title": "Freezing CNN Channels",913 "slug": "freezing-cnn-channels",914 "posts_count": 3,915 "reply_count": 0,916 "highest_post_number": 3,917 "image_url": null,918 "created_at": "2025-02-05T11:04:17.000Z",919 "last_posted_at": "2025-02-07T14:41:56.375Z",920 "bumped": true,921 "bumped_at": "2025-02-07T14:41:56.375Z",922 "archetype": "regular",923 "unseen": false,924 "pinned": false,925 "unpinned": null,926 "visible": true,927 "closed": false,928 "archived": false,929 "bookmarked": null,930 "liked": null,931 "tags_descriptions": {},932 "like_count": 0,933 "views": 184,934 "category_id": 7,935 "featured_link": null,936 "has_accepted_answer": false,937 "posters": [938 {939 "extras": "latest",940 "description": "Original Poster, Most Recent Poster",941 "user": {942 "id": 82501,943 "username": "SudakshK",944 "name": "",945 "avatar_template": "/user_avatar/discuss.pytorch.org/sudakshk/{size}/75478_2.png",946 "trust_level": 1947 }948 },949 {950 "extras": null,951 "description": "Frequent Poster",952 "user": {953 "id": 19553,954 "username": "anantguptadbl",955 "name": "Anant Gupta",956 "avatar_template": "/user_avatar/discuss.pytorch.org/anantguptadbl/{size}/17784_2.png",957 "trust_level": 2958 }959 }960 ]961 },962 {963 "fancy_title": "How to preserve computational graph while initializing a network with weights",964 "id": 217388,965 "title": "How to preserve computational graph while initializing a network with weights",966 "slug": "how-to-preserve-computational-graph-while-initializing-a-network-with-weights",967 "posts_count": 3,968 "reply_count": 1,969 "highest_post_number": 3,970 "image_url": null,971 "created_at": "2025-03-03T16:08:29.829Z",972 "last_posted_at": "2025-03-04T05:38:35.265Z",973 "bumped": true,974 "bumped_at": "2025-03-04T05:38:35.265Z",975 "archetype": "regular",976 "unseen": false,977 "pinned": false,978 "unpinned": null,979 "visible": true,980 "closed": false,981 "archived": false,982 "bookmarked": null,983 "liked": null,984 "tags_descriptions": {},985 "like_count": 0,986 "views": 50,987 "category_id": 7,988 "featured_link": null,989 "has_accepted_answer": true,990 "posters": [991 {992 "extras": "latest",993 "description": "Original Poster, Most Recent Poster",994 "user": {995 "id": 83043,996 "username": "Charley_Xiao",997 "name": "Charley Xiao",998 "avatar_template": "/user_avatar/discuss.pytorch.org/charley_xiao/{size}/75963_2.png",999 "trust_level": 11000 }1001 },1002 {1003 "extras": null,1004 "description": "Frequent Poster, Accepted Answer",1005 "user": {1006 "id": 18088,1007 "username": "KFrank",1008 "name": "K. Frank",1009 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",1010 "trust_level": 21011 }1012 }1013 ]1014 },1015 {1016 "fancy_title": "Get softmax_lse value for sdpa kernel?",1017 "id": 218079,1018 "title": "Get softmax_lse value for sdpa kernel?",1019 "slug": "get-softmax-lse-value-for-sdpa-kernel",1020 "posts_count": 1,1021 "reply_count": 0,1022 "highest_post_number": 1,1023 "image_url": null,1024 "created_at": "2025-03-20T14:59:54.746Z",1025 "last_posted_at": "2025-03-20T14:59:54.784Z",1026 "bumped": true,1027 "bumped_at": "2025-03-20T14:59:54.784Z",1028 "archetype": "regular",1029 "unseen": false,1030 "pinned": false,1031 "unpinned": null,1032 "visible": true,1033 "closed": false,1034 "archived": false,1035 "bookmarked": null,1036 "liked": null,1037 "tags_descriptions": {},1038 "like_count": 0,1039 "views": 74,1040 "category_id": 7,1041 "featured_link": null,1042 "has_accepted_answer": false,1043 "posters": [1044 {1045 "extras": "latest single",1046 "description": "Original Poster, Most Recent Poster",1047 "user": {1048 "id": 83386,1049 "username": "barpitf",1050 "name": "barpitf",1051 "avatar_template": "/letter_avatar_proxy/v4/letter/b/dfb087/{size}.png",1052 "trust_level": 11053 }1054 }1055 ]1056 }1057 ],1058 "tags_descriptions": {},1059 "fancy_title": "Does autograd on var give a quadratic runtime?",1060 "id": 154717,1061 "title": "Does autograd on var give a quadratic runtime?",1062 "posts_count": 2,1063 "created_at": "2022-06-21T16:57:01.206Z",1064 "views": 349,1065 "reply_count": 0,1066 "like_count": 0,1067 "last_posted_at": "2022-08-02T16:25:59.808Z",1068 "visible": true,1069 "closed": false,1070 "archived": false,1071 "has_summary": false,1072 "archetype": "regular",1073 "slug": "does-autograd-on-var-give-a-quadratic-runtime",1074 "category_id": 7,1075 "word_count": 295,1076 "deleted_at": null,1077 "user_id": 52851,1078 "featured_link": null,1079 "pinned_globally": false,1080 "pinned_at": null,1081 "pinned_until": null,1082 "image_url": null,1083 "slow_mode_seconds": 0,1084 "draft": null,1085 "draft_key": "topic_154717",1086 "draft_sequence": null,1087 "unpinned": null,1088 "pinned": false,1089 "current_post_number": 1,1090 "highest_post_number": 2,1091 "deleted_by": null,1092 "actions_summary": [1093 {1094 "id": 4,1095 "count": 0,1096 "hidden": false,1097 "can_act": false1098 },1099 {1100 "id": 8,1101 "count": 0,1102 "hidden": false,1103 "can_act": false1104 },1105 {1106 "id": 10,1107 "count": 0,1108 "hidden": false,1109 "can_act": false1110 },1111 {1112 "id": 7,1113 "count": 0,1114 "hidden": false,1115 "can_act": false1116 }1117 ],1118 "chunk_size": 20,1119 "bookmarked": false,1120 "topic_timer": null,1121 "message_bus_last_id": 0,1122 "participant_count": 1,1123 "show_read_indicator": false,1124 "thumbnails": null,1125 "slow_mode_enabled_until": null,1126 "can_vote": false,1127 "vote_count": 0,1128 "user_voted": false,1129 "discourse_zendesk_plugin_zendesk_id": null,1130 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1131 "details": {1132 "can_edit": false,1133 "notification_level": 1,1134 "participants": [1135 {1136 "id": 52851,1137 "username": "peppermint",1138 "name": "",1139 "avatar_template": "/letter_avatar_proxy/v4/letter/p/dfb087/{size}.png",1140 "post_count": 2,1141 "primary_group_name": null,1142 "flair_name": null,1143 "flair_url": null,1144 "flair_color": null,1145 "flair_bg_color": null,1146 "flair_group_id": null,1147 "trust_level": 11148 }1149 ],1150 "created_by": {1151 "id": 52851,1152 "username": "peppermint",1153 "name": "",1154 "avatar_template": "/letter_avatar_proxy/v4/letter/p/dfb087/{size}.png"1155 },1156 "last_poster": {1157 "id": 52851,1158 "username": "peppermint",1159 "name": "",1160 "avatar_template": "/letter_avatar_proxy/v4/letter/p/dfb087/{size}.png"1161 }1162 },1163 "bookmarks": []1164 },1165 {1166 "post_stream": {1167 "posts": [1168 {1169 "id": 359582,1170 "name": "Sajad",1171 "username": "sajastu",1172 "avatar_template": "/user_avatar/discuss.pytorch.org/sajastu/{size}/14519_2.png",1173 "created_at": "2022-08-02T15:48:10.468Z",1174 "cooked": "<p>I’m trying to run a Huggingface model on multi-GPU. The problem is that when I’m processing multiple inputs which are bound to each other from a single class (shared-weights), I’m getting <code>RuntimeError: Expected to mark a variable ready only once.</code>. While if I use the module only once, for processing one input, I won’t get this error.</p>\n<p>To make it clearer, here is the structure:</p>\n<pre><code class=\"lang-auto\">class Model():\n \n def __init__(self, ...)\n\t self.encoder = ...\n\n\n def forward(input_ids, ...):\n\n\t encoder_outputs = self.encoder(input_ids, ...)\n\n\t # filter encoder_outputs and construct another tensor called 'input_ids_selected'\n\n\t encoder_outputs = self.encoder(input_ids_selected, ...)\n\n\n\t return encoder_outputs\n</code></pre>\n<p>If I remove this line: <code>encoder_outputs = self.encoder(input_ids_selected, ...)</code>, I will not run into this error. Should say that to filter encoder_outputs from the first pass of encoder, I’m using other modules (linear layers) to find important <code>input_ids</code>, retaining those in <code>input_ids_selected</code>. You can see this as a two-step summarizer.</p>",1175 "post_number": 1,1176 "post_type": 1,1177 "posts_count": 1,1178 "updated_at": "2022-08-02T15:50:43.472Z",1179 "reply_count": 0,1180 "reply_to_post_number": null,1181 "quote_count": 0,1182 "incoming_link_count": 101,1183 "reads": 8,1184 "readers_count": 7,1185 "score": 506.6,1186 "yours": false,1187 "topic_id": 158147,1188 "topic_slug": "runtimeerror-expected-to-mark-a-variable-ready-only-once-on-multi-gpu-setting",1189 "display_username": "Sajad",1190 "primary_group_name": null,1191 "flair_name": null,1192 "flair_url": null,1193 "flair_bg_color": null,1194 "flair_color": null,1195 "flair_group_id": null,1196 "badges_granted": [],1197 "version": 1,1198 "can_edit": false,1199 "can_delete": false,1200 "can_recover": false,