Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 425967,7 "name": "khalid",8 "username": "khalid-sharma",9 "avatar_template": "/user_avatar/discuss.pytorch.org/khalid-sharma/{size}/65951_2.png",10 "created_at": "2023-12-02T03:59:33.448Z",11 "cooked": "<p>Hi,</p>\n<p>I’m basically struggling to understand how to be able to use todays blogpost on accelerating LLM throughput.</p>\n<p>I want to make sure I’m understanding or doing it properly but what I think I need to do is:</p>\n<ol>\n<li>clone the repo</li>\n<li>choose a model checkpoint to convert into a faster version using</li>\n</ol>\n<pre><code class=\"lang-auto\">export MODEL_REPO=meta-llama/Llama-2-7b-chat-hf\n./scripts/prepare.sh $MODEL_REPO\n</code></pre>\n<ol start=\"3\">\n<li>Then run that model using:</li>\n</ol>\n<pre><code class=\"lang-auto\">python generate.py --compile --checkpoint_path checkpoints/$MODEL_REPO/model.pth --prompt \"Hello, my name is\"\n</code></pre>\n<p>If this is wrong, I’d the proper way to do this because I get a long download for the weights and then an error on line 3 above regarding model.pth and the checkpoints</p>\n<p>Furthermore, I don’t really understand if I can convert any open source llm in this way or just the ones tested etc; I saw some mention of mistral but I guess I dont really know the full process to be confident enough. Also might be a dumb question but I won’t see the results of this efficiency without an A100 too right? Appreciate any guidance.</p>\n<p>If anyone could walk me through how I’m supposed to utilize this methodology the right way, I’d appreciate that immensely.</p>\n<p>Documentation: <a href=\"https://pytorch.org/blog/accelerating-generative-ai-2/\" rel=\"noopener nofollow ugc\">Blog Post</a><br>\nGithub: <a href=\"https://github.com/pytorch-labs/gpt-fast\" class=\"inline-onebox\" rel=\"noopener nofollow ugc\">GitHub - pytorch-labs/gpt-fast: Simple and efficient pytorch-native transformer text generation in <1000 LOC of python.</a></p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 4,15 "updated_at": "2023-12-02T03:59:33.448Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 254,20 "reads": 12,21 "readers_count": 11,22 "score": 1257.4,23 "yours": false,24 "topic_id": 192984,25 "topic_slug": "pytorch-acceleration-gpt-fast",26 "display_username": "khalid",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 "link_counts": [41 {42 "url": "https://github.com/pytorch-labs/gpt-fast",43 "internal": false,44 "reflection": false,45 "title": "GitHub - pytorch-labs/gpt-fast: Simple and efficient pytorch-native transformer text generation in <1000 LOC of python.",46 "clicks": 947 },48 {49 "url": "https://pytorch.org/blog/accelerating-generative-ai-2/",50 "internal": false,51 "reflection": false,52 "title": "Accelerating Generative AI with PyTorch II: GPT, Fast | PyTorch",53 "clicks": 654 }55 ],56 "read": true,57 "user_title": null,58 "bookmarked": false,59 "actions_summary": [],60 "moderator": false,61 "admin": false,62 "staff": false,63 "user_id": 71415,64 "hidden": false,65 "trust_level": 0,66 "deleted_at": null,67 "user_deleted": false,68 "edit_reason": null,69 "can_view_edit_history": true,70 "wiki": false,71 "post_url": "/t/pytorch-acceleration-gpt-fast/192984/1",72 "can_accept_answer": false,73 "can_unaccept_answer": false,74 "accepted_answer": false,75 "topic_accepted_answer": null,76 "can_vote": false77 },78 {79 "id": 425974,80 "name": "Mark Saroufim",81 "username": "marksaroufim",82 "avatar_template": "/user_avatar/discuss.pytorch.org/marksaroufim/{size}/36747_2.png",83 "created_at": "2023-12-02T06:33:30.413Z",84 "cooked": "<p>The implementation is meant to be a hacky copy and paste one so right now it mostly supports Llama but it should be easy to support other implementations</p>\n<p>What’s the error you run into when you call generate? You didn’t paste any logs</p>",85 "post_number": 2,86 "post_type": 1,87 "posts_count": 4,88 "updated_at": "2023-12-02T06:33:30.413Z",89 "reply_count": 1,90 "reply_to_post_number": null,91 "quote_count": 0,92 "incoming_link_count": 1,93 "reads": 10,94 "readers_count": 9,95 "score": 12.0,96 "yours": false,97 "topic_id": 192984,98 "topic_slug": "pytorch-acceleration-gpt-fast",99 "display_username": "Mark Saroufim",100 "primary_group_name": null,101 "flair_name": null,102 "flair_url": null,103 "flair_bg_color": null,104 "flair_color": null,105 "flair_group_id": null,106 "badges_granted": [],107 "version": 1,108 "can_edit": false,109 "can_delete": false,110 "can_recover": false,111 "can_see_hidden_post": false,112 "can_wiki": false,113 "read": true,114 "user_title": "Regular",115 "title_is_group": false,116 "bookmarked": false,117 "actions_summary": [],118 "moderator": false,119 "admin": false,120 "staff": false,121 "user_id": 43941,122 "hidden": false,123 "trust_level": 3,124 "deleted_at": null,125 "user_deleted": false,126 "edit_reason": null,127 "can_view_edit_history": true,128 "wiki": false,129 "post_url": "/t/pytorch-acceleration-gpt-fast/192984/2",130 "can_accept_answer": false,131 "can_unaccept_answer": false,132 "accepted_answer": false,133 "topic_accepted_answer": null134 },135 {136 "id": 425976,137 "name": "khalid",138 "username": "khalid-sharma",139 "avatar_template": "/user_avatar/discuss.pytorch.org/khalid-sharma/{size}/65951_2.png",140 "created_at": "2023-12-02T06:54:17.798Z",141 "cooked": "<p>The error I have currently is related to not yet being approved by Meta via hugging face to use the templates, so was asking specifically about the process for when I am approved.</p>\n<p>I understand that these are quantization methods and speed up methods so is the idea that once I have access I can use these files to make small faster models that I can reupload publicly to Huggingface for example or LM Studio?</p>",142 "post_number": 4,143 "post_type": 1,144 "posts_count": 4,145 "updated_at": "2023-12-02T06:54:17.798Z",146 "reply_count": 1,147 "reply_to_post_number": 2,148 "quote_count": 0,149 "incoming_link_count": 1,150 "reads": 9,151 "readers_count": 8,152 "score": 11.8,153 "yours": false,154 "topic_id": 192984,155 "topic_slug": "pytorch-acceleration-gpt-fast",156 "display_username": "khalid",157 "primary_group_name": null,158 "flair_name": null,159 "flair_url": null,160 "flair_bg_color": null,161 "flair_color": null,162 "flair_group_id": null,163 "badges_granted": [],164 "version": 1,165 "can_edit": false,166 "can_delete": false,167 "can_recover": false,168 "can_see_hidden_post": false,169 "can_wiki": false,170 "read": true,171 "user_title": null,172 "reply_to_user": {173 "id": 43941,174 "username": "marksaroufim",175 "name": "Mark Saroufim",176 "avatar_template": "/user_avatar/discuss.pytorch.org/marksaroufim/{size}/36747_2.png"177 },178 "bookmarked": false,179 "actions_summary": [],180 "moderator": false,181 "admin": false,182 "staff": false,183 "user_id": 71415,184 "hidden": false,185 "trust_level": 0,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/pytorch-acceleration-gpt-fast/192984/4",192 "can_accept_answer": false,193 "can_unaccept_answer": false,194 "accepted_answer": false,195 "topic_accepted_answer": null196 },197 {198 "id": 425977,199 "name": "Mark Saroufim",200 "username": "marksaroufim",201 "avatar_template": "/user_avatar/discuss.pytorch.org/marksaroufim/{size}/36747_2.png",202 "created_at": "2023-12-02T07:03:44.684Z",203 "cooked": "<p>As long as you use the same kind of state dict as the one for llama2 you should be good</p>",204 "post_number": 5,205 "post_type": 1,206 "posts_count": 4,207 "updated_at": "2023-12-02T07:03:44.684Z",208 "reply_count": 0,209 "reply_to_post_number": 4,210 "quote_count": 0,211 "incoming_link_count": 0,212 "reads": 8,213 "readers_count": 7,214 "score": 1.6,215 "yours": false,216 "topic_id": 192984,217 "topic_slug": "pytorch-acceleration-gpt-fast",218 "display_username": "Mark Saroufim",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 "read": true,233 "user_title": "Regular",234 "title_is_group": false,235 "reply_to_user": {236 "id": 71415,237 "username": "khalid-sharma",238 "name": "khalid",239 "avatar_template": "/user_avatar/discuss.pytorch.org/khalid-sharma/{size}/65951_2.png"240 },241 "bookmarked": false,242 "actions_summary": [],243 "moderator": false,244 "admin": false,245 "staff": false,246 "user_id": 43941,247 "hidden": false,248 "trust_level": 3,249 "deleted_at": null,250 "user_deleted": false,251 "edit_reason": null,252 "can_view_edit_history": true,253 "wiki": false,254 "post_url": "/t/pytorch-acceleration-gpt-fast/192984/5",255 "can_accept_answer": false,256 "can_unaccept_answer": false,257 "accepted_answer": false,258 "topic_accepted_answer": null259 }260 ],261 "stream": [262 425967,263 425974,264 425976,265 425977266 ]267 },268 "timeline_lookup": [269 [270 1,271 694272 ],273 [274 3,275 693276 ]277 ],278 "suggested_topics": [279 {280 "fancy_title": "Inference_mode() doesn’t remove grad",281 "id": 216739,282 "title": "Inference_mode() doesn't remove grad",283 "slug": "inference-mode-doesnt-remove-grad",284 "posts_count": 2,285 "reply_count": 0,286 "highest_post_number": 2,287 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/1/d/1d5da9ab3a51d653e4e1cc79efce5660959de40d.png",288 "created_at": "2025-02-16T12:10:09.684Z",289 "last_posted_at": "2025-02-16T15:15:50.947Z",290 "bumped": true,291 "bumped_at": "2025-02-16T15:15:50.947Z",292 "archetype": "regular",293 "unseen": false,294 "pinned": false,295 "unpinned": null,296 "visible": true,297 "closed": false,298 "archived": false,299 "bookmarked": null,300 "liked": null,301 "tags_descriptions": {},302 "like_count": 0,303 "views": 76,304 "category_id": 1,305 "featured_link": null,306 "has_accepted_answer": false,307 "posters": [308 {309 "extras": null,310 "description": "Original Poster",311 "user": {312 "id": 82719,313 "username": "blmppes",314 "name": "Trung Hiếu Đỗ",315 "avatar_template": "/user_avatar/discuss.pytorch.org/blmppes/{size}/75683_2.png",316 "trust_level": 0317 }318 },319 {320 "extras": "latest",321 "description": "Most Recent Poster",322 "user": {323 "id": 3534,324 "username": "ptrblck",325 "name": "",326 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",327 "admin": true,328 "moderator": true,329 "trust_level": 2330 }331 }332 ]333 },334 {335 "fancy_title": "ROCm: hipBLASLt error with gfx1103",336 "id": 212721,337 "title": "ROCm: hipBLASLt error with gfx1103",338 "slug": "rocm-hipblaslt-error-with-gfx1103",339 "posts_count": 2,340 "reply_count": 0,341 "highest_post_number": 2,342 "image_url": null,343 "created_at": "2024-11-09T01:43:15.446Z",344 "last_posted_at": "2025-03-03T19:42:45.282Z",345 "bumped": true,346 "bumped_at": "2025-03-03T19:42:45.282Z",347 "archetype": "regular",348 "unseen": false,349 "pinned": false,350 "unpinned": null,351 "visible": true,352 "closed": false,353 "archived": false,354 "bookmarked": null,355 "liked": null,356 "tags_descriptions": {},357 "like_count": 0,358 "views": 1070,359 "category_id": 1,360 "featured_link": null,361 "has_accepted_answer": false,362 "posters": [363 {364 "extras": null,365 "description": "Original Poster",366 "user": {367 "id": 78358,368 "username": "lumie",369 "name": "",370 "avatar_template": "/letter_avatar_proxy/v4/letter/l/ea5d25/{size}.png",371 "trust_level": 1372 }373 },374 {375 "extras": "latest",376 "description": "Most Recent Poster",377 "user": {378 "id": 82743,379 "username": "fngarrett",380 "name": "Garrett",381 "avatar_template": "/letter_avatar_proxy/v4/letter/f/e79b87/{size}.png",382 "trust_level": 1383 }384 }385 ]386 },387 {388 "fancy_title": "Why kernels different streams can’t in parallel",389 "id": 215618,390 "title": "Why kernels different streams can't in parallel",391 "slug": "why-kernels-different-streams-cant-in-parallel",392 "posts_count": 2,393 "reply_count": 0,394 "highest_post_number": 2,395 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/f/f/ff20ec5488f7548c57f81427e2ca0e83062f5ee9_2_1024x801.png",396 "created_at": "2025-01-20T07:24:07.095Z",397 "last_posted_at": "2025-01-20T13:51:41.366Z",398 "bumped": true,399 "bumped_at": "2025-01-20T13:51:41.366Z",400 "archetype": "regular",401 "unseen": false,402 "pinned": false,403 "unpinned": null,404 "visible": true,405 "closed": false,406 "archived": false,407 "bookmarked": null,408 "liked": null,409 "tags_descriptions": {},410 "like_count": 0,411 "views": 206,412 "category_id": 1,413 "featured_link": null,414 "has_accepted_answer": false,415 "posters": [416 {417 "extras": null,418 "description": "Original Poster",419 "user": {420 "id": 72471,421 "username": "shadowshadow",422 "name": "",423 "avatar_template": "/user_avatar/discuss.pytorch.org/shadowshadow/{size}/62985_2.png",424 "trust_level": 2425 }426 },427 {428 "extras": "latest",429 "description": "Most Recent Poster",430 "user": {431 "id": 3534,432 "username": "ptrblck",433 "name": "",434 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",435 "admin": true,436 "moderator": true,437 "trust_level": 2438 }439 }440 ]441 },442 {443 "fancy_title": "Transformer application for spectra regression",444 "id": 212961,445 "title": "Transformer application for spectra regression",446 "slug": "transformer-application-for-spectra-regression",447 "posts_count": 1,448 "reply_count": 0,449 "highest_post_number": 1,450 "image_url": null,451 "created_at": "2024-11-14T02:47:03.765Z",452 "last_posted_at": "2024-11-14T02:47:03.809Z",453 "bumped": true,454 "bumped_at": "2024-11-14T02:47:03.809Z",455 "archetype": "regular",456 "unseen": false,457 "pinned": false,458 "unpinned": null,459 "visible": true,460 "closed": false,461 "archived": false,462 "bookmarked": null,463 "liked": null,464 "tags_descriptions": {},465 "like_count": 0,466 "views": 108,467 "category_id": 1,468 "featured_link": null,469 "has_accepted_answer": false,470 "posters": [471 {472 "extras": "latest single",473 "description": "Original Poster, Most Recent Poster",474 "user": {475 "id": 80903,476 "username": "Camouflage_aa",477 "name": "Camouflage aa",478 "avatar_template": "/user_avatar/discuss.pytorch.org/camouflage_aa/{size}/73986_2.png",479 "trust_level": 0480 }481 }482 ]483 },484 {485 "fancy_title": "How to discard the eigenvectors with a 0 eigenvalues while calculating loss?",486 "id": 217324,487 "title": "How to discard the eigenvectors with a 0 eigenvalues while calculating loss?",488 "slug": "how-to-discard-the-eigenvectors-with-a-0-eigenvalues-while-calculating-loss",489 "posts_count": 4,490 "reply_count": 2,491 "highest_post_number": 4,492 "image_url": null,493 "created_at": "2025-03-01T19:00:22.401Z",494 "last_posted_at": "2025-03-06T04:03:54.219Z",495 "bumped": true,496 "bumped_at": "2025-03-06T04:03:54.219Z",497 "archetype": "regular",498 "unseen": false,499 "pinned": false,500 "unpinned": null,501 "visible": true,502 "closed": false,503 "archived": false,504 "bookmarked": null,505 "liked": null,506 "tags_descriptions": {},507 "like_count": 0,508 "views": 54,509 "category_id": 1,510 "featured_link": null,511 "has_accepted_answer": false,512 "posters": [513 {514 "extras": null,515 "description": "Original Poster",516 "user": {517 "id": 80508,518 "username": "wasabi_linguist",519 "name": "",520 "avatar_template": "/user_avatar/discuss.pytorch.org/wasabi_linguist/{size}/73592_2.png",521 "trust_level": 1522 }523 },524 {525 "extras": "latest",526 "description": "Most Recent Poster",527 "user": {528 "id": 18088,529 "username": "KFrank",530 "name": "K. Frank",531 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",532 "trust_level": 2533 }534 }535 ]536 }537 ],538 "tags_descriptions": {},539 "fancy_title": "PyTorch Acceleration GPT-Fast",540 "id": 192984,541 "title": "PyTorch Acceleration GPT-Fast",542 "posts_count": 4,543 "created_at": "2023-12-02T03:59:33.369Z",544 "views": 548,545 "reply_count": 3,546 "like_count": 0,547 "last_posted_at": "2023-12-02T07:03:44.684Z",548 "visible": true,549 "closed": false,550 "archived": false,551 "has_summary": false,552 "archetype": "regular",553 "slug": "pytorch-acceleration-gpt-fast",554 "category_id": 1,555 "word_count": 376,556 "deleted_at": null,557 "user_id": 71415,558 "featured_link": null,559 "pinned_globally": false,560 "pinned_at": null,561 "pinned_until": null,562 "image_url": null,563 "slow_mode_seconds": 0,564 "draft": null,565 "draft_key": "topic_192984",566 "draft_sequence": null,567 "unpinned": null,568 "pinned": false,569 "current_post_number": 1,570 "highest_post_number": 5,571 "deleted_by": null,572 "actions_summary": [573 {574 "id": 4,575 "count": 0,576 "hidden": false,577 "can_act": false578 },579 {580 "id": 8,581 "count": 0,582 "hidden": false,583 "can_act": false584 },585 {586 "id": 10,587 "count": 0,588 "hidden": false,589 "can_act": false590 },591 {592 "id": 7,593 "count": 0,594 "hidden": false,595 "can_act": false596 }597 ],598 "chunk_size": 20,599 "bookmarked": false,600 "topic_timer": null,601 "message_bus_last_id": 0,602 "participant_count": 2,603 "show_read_indicator": false,604 "thumbnails": null,605 "slow_mode_enabled_until": null,606 "can_vote": false,607 "vote_count": 0,608 "user_voted": false,609 "discourse_zendesk_plugin_zendesk_id": null,610 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",611 "details": {612 "can_edit": false,613 "notification_level": 1,614 "participants": [615 {616 "id": 43941,617 "username": "marksaroufim",618 "name": "Mark Saroufim",619 "avatar_template": "/user_avatar/discuss.pytorch.org/marksaroufim/{size}/36747_2.png",620 "post_count": 2,621 "primary_group_name": null,622 "flair_name": null,623 "flair_url": null,624 "flair_color": null,625 "flair_bg_color": null,626 "flair_group_id": null,627 "trust_level": 3628 },629 {630 "id": 71415,631 "username": "khalid-sharma",632 "name": "khalid",633 "avatar_template": "/user_avatar/discuss.pytorch.org/khalid-sharma/{size}/65951_2.png",634 "post_count": 2,635 "primary_group_name": null,636 "flair_name": null,637 "flair_url": null,638 "flair_color": null,639 "flair_bg_color": null,640 "flair_group_id": null,641 "trust_level": 0642 }643 ],644 "created_by": {645 "id": 71415,646 "username": "khalid-sharma",647 "name": "khalid",648 "avatar_template": "/user_avatar/discuss.pytorch.org/khalid-sharma/{size}/65951_2.png"649 },650 "last_poster": {651 "id": 43941,652 "username": "marksaroufim",653 "name": "Mark Saroufim",654 "avatar_template": "/user_avatar/discuss.pytorch.org/marksaroufim/{size}/36747_2.png"655 },656 "links": [657 {658 "url": "https://github.com/pytorch-labs/gpt-fast",659 "title": "GitHub - pytorch-labs/gpt-fast: Simple and efficient pytorch-native transformer text generation in <1000 LOC of python.",660 "internal": false,661 "attachment": false,662 "reflection": false,663 "clicks": 9,664 "user_id": 71415,665 "domain": "github.com",666 "root_domain": "github.com"667 },668 {669 "url": "https://pytorch.org/blog/accelerating-generative-ai-2/",670 "title": "Accelerating Generative AI with PyTorch II: GPT, Fast | PyTorch",671 "internal": false,672 "attachment": false,673 "reflection": false,674 "clicks": 6,675 "user_id": 71415,676 "domain": "pytorch.org",677 "root_domain": "pytorch.org"678 }679 ]680 },681 "bookmarks": []682 },683 {684 "post_stream": {685 "posts": [686 {687 "id": 425969,688 "name": "",689 "username": "mahoo",690 "avatar_template": "/letter_avatar_proxy/v4/letter/m/f9ae1b/{size}.png",691 "created_at": "2023-12-02T04:35:28.063Z",692 "cooked": "<p>Can someone help me with a link to a tutorial on how to re-training deeplab v3 on my data? I have only one class target and I keep getting errors. I’m fairly new to pytorch. I have been searching and reading but still unsucessful. TIA! Currently my code is at this stage:</p>\n<pre><code class=\"lang-auto\">import torch\nimport torch.nn as nn\nimport torch.optim as optim\nfrom torchvision.transforms import ToTensor\nfrom torch.utils.data import Dataset, DataLoader\nfrom torchvision.models.segmentation import deeplabv3_resnet50\nimport os\nfrom PIL import Image\nfrom torchvision import transforms\n\n# Define your own dataset\nclass MyDataset(Dataset):\n def __init__(self, image_paths, mask_paths, transform=None):\n self.image_paths = image_paths\n self.mask_paths = mask_paths\n self.transform = transform\n\n def __getitem__(self, index):\n image = Image.open(self.image_paths[index]).convert(\"RGB\")\n mask = Image.open(self.mask_paths[index])\n if self.transform:\n image = self.transform(image)\n mask = self.transform(mask)\n return image, mask\n\n def __len__(self):\n return len(self.image_paths)\n\n\n# Define your training hyperparameters\nbatch_size = 16\nlearning_rate = 0.001\nnum_epochs = 10\n\n# Create an instance of the DeepLabV3 model\nmodel = deeplabv3_resnet50(pretrained=False, num_classes=2) # Adjust num_classes to 2 for object and background\n\n# Define your loss function (e.g., CrossEntropyLoss) and optimizer (e.g., Adam)\ncriterion = nn.CrossEntropyLoss()\noptimizer = optim.Adam(model.parameters(), lr=learning_rate)\n\n\nmyTransform = transforms.Compose([\n transforms.ToTensor(),\n transforms.Resize((224, 224))\n #transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),\n])\n\n\n# Load your dataset\nimage_dir = \"./test_img_mask/images\"\nmask_dir = \"./test_img_mask/masks\"\nimage_paths = [os.path.join(image_dir, filename) for filename in os.listdir(image_dir)]\nmask_paths = [os.path.join(mask_dir, filename) for filename in os.listdir(mask_dir)]\ndataset = MyDataset(image_paths, mask_paths, transform=myTransform)\n\ntrain_size = int(0.8 * len(dataset))\nval_size = len(dataset) - train_size\ntrain_dataset, val_dataset = torch.utils.data.random_split(dataset, [train_size, val_size])\n\ntrain_loader = DataLoader(train_dataset, batch_size=4, shuffle=True)\nval_loader = DataLoader(val_dataset, batch_size=4, shuffle=False)\n\n# Move the model to the GPU if available\ndevice = torch.device('cuda' if torch.cuda.is_available() else 'cpu')\nmodel.to(device)\n\n# Training loop\nfor epoch in range(num_epochs):\n model.train()\n for images, masks in train_loader:\n images = images.to(device)\n masks = masks.to(device)\n\n # Forward pass\n outputs = model(images)['out']\n\n # Compute loss\n loss = criterion(outputs, masks.squeeze(1).long())\n\n # Backward and optimize\n optimizer.zero_grad()\n loss.backward()\n optimizer.step()\n\n # Validation loop\n model.eval()\n with torch.no_grad():\n for images, masks in val_loader:\n images = images.to(device)\n masks = masks.to(device)\n\n # Forward pass\n outputs = model(images)['out']\n\n # Compute validation loss\n val_loss = criterion(outputs, masks.squeeze(1).long())\n\n print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}, Val Loss: {val_loss.item():.4f}')\n\n</code></pre>",693 "post_number": 1,694 "post_type": 1,695 "posts_count": 1,696 "updated_at": "2023-12-02T04:39:10.905Z",697 "reply_count": 0,698 "reply_to_post_number": null,699 "quote_count": 0,700 "incoming_link_count": 325,701 "reads": 6,702 "readers_count": 5,703 "score": 1611.2,704 "yours": false,705 "topic_id": 192986,706 "topic_slug": "re-training-deeplab-v3",707 "display_username": "",708 "primary_group_name": null,709 "flair_name": null,710 "flair_url": null,711 "flair_bg_color": null,712 "flair_color": null,713 "flair_group_id": null,714 "badges_granted": [],715 "version": 2,716 "can_edit": false,717 "can_delete": false,718 "can_recover": false,719 "can_see_hidden_post": false,720 "can_wiki": false,721 "read": true,722 "user_title": null,723 "bookmarked": false,724 "actions_summary": [],725 "moderator": false,726 "admin": false,727 "staff": false,728 "user_id": 71416,729 "hidden": false,730 "trust_level": 0,731 "deleted_at": null,732 "user_deleted": false,733 "edit_reason": null,734 "can_view_edit_history": true,735 "wiki": false,736 "post_url": "/t/re-training-deeplab-v3/192986/1",737 "can_accept_answer": false,738 "can_unaccept_answer": false,739 "accepted_answer": false,740 "topic_accepted_answer": null,741 "can_vote": false742 }743 ],744 "stream": [745 425969746 ]747 },748 "timeline_lookup": [749 [750 1,751 694752 ]753 ],754 "suggested_topics": [755 {756 "fancy_title": "Pooling with a custom kernel?",757 "id": 217660,758 "title": "Pooling with a custom kernel?",759 "slug": "pooling-with-a-custom-kernel",760 "posts_count": 2,761 "reply_count": 0,762 "highest_post_number": 2,763 "image_url": null,764 "created_at": "2025-03-10T11:11:41.968Z",765 "last_posted_at": "2025-03-10T15:10:50.281Z",766 "bumped": true,767 "bumped_at": "2025-03-10T15:10:50.281Z",768 "archetype": "regular",769 "unseen": false,770 "pinned": false,771 "unpinned": null,772 "visible": true,773 "closed": false,774 "archived": false,775 "bookmarked": null,776 "liked": null,777 "tags_descriptions": {},778 "like_count": 0,779 "views": 65,780 "category_id": 5,781 "featured_link": null,782 "has_accepted_answer": false,783 "posters": [784 {785 "extras": null,786 "description": "Original Poster",787 "user": {788 "id": 83175,789 "username": "shroomite",790 "name": "Karol",791 "avatar_template": "/user_avatar/discuss.pytorch.org/shroomite/{size}/76075_2.png",792 "trust_level": 1793 }794 },795 {796 "extras": "latest",797 "description": "Most Recent Poster",798 "user": {799 "id": 18088,800 "username": "KFrank",801 "name": "K. Frank",802 "avatar_template": "/letter_avatar_proxy/v4/letter/k/ecb155/{size}.png",803 "trust_level": 2804 }805 }806 ]807 },808 {809 "fancy_title": "No gradient found for a parameter in custom Linear class",810 "id": 212455,811 "title": "No gradient found for a parameter in custom Linear class",812 "slug": "no-gradient-found-for-a-parameter-in-custom-linear-class",813 "posts_count": 2,814 "reply_count": 0,815 "highest_post_number": 2,816 "image_url": null,817 "created_at": "2024-11-02T19:37:13.384Z",818 "last_posted_at": "2024-11-04T14:49:26.100Z",819 "bumped": true,820 "bumped_at": "2024-11-04T14:49:26.100Z",821 "archetype": "regular",822 "unseen": false,823 "pinned": false,824 "unpinned": null,825 "visible": true,826 "closed": false,827 "archived": false,828 "bookmarked": null,829 "liked": null,830 "tags_descriptions": {},831 "like_count": 0,832 "views": 42,833 "category_id": 5,834 "featured_link": null,835 "has_accepted_answer": false,836 "posters": [837 {838 "extras": null,839 "description": "Original Poster",840 "user": {841 "id": 80655,842 "username": "Arkapravo_Ghosh",843 "name": "Arkapravo Ghosh",844 "avatar_template": "/user_avatar/discuss.pytorch.org/arkapravo_ghosh/{size}/73737_2.png",845 "trust_level": 1846 }847 },848 {849 "extras": "latest",850 "description": "Most Recent Poster",851 "user": {852 "id": 3534,853 "username": "ptrblck",854 "name": "",855 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",856 "admin": true,857 "moderator": true,858 "trust_level": 2859 }860 }861 ]862 },863 {864 "fancy_title": "Swin Based Backbone for FasterRCNN",865 "id": 212736,866 "title": "Swin Based Backbone for FasterRCNN",867 "slug": "swin-based-backbone-for-fasterrcnn",868 "posts_count": 1,869 "reply_count": 0,870 "highest_post_number": 1,871 "image_url": null,872 "created_at": "2024-11-09T12:29:52.715Z",873 "last_posted_at": "2024-11-09T12:29:52.773Z",874 "bumped": true,875 "bumped_at": "2024-11-09T12:29:52.773Z",876 "archetype": "regular",877 "unseen": false,878 "pinned": false,879 "unpinned": null,880 "visible": true,881 "closed": false,882 "archived": false,883 "bookmarked": null,884 "liked": null,885 "tags_descriptions": {},886 "like_count": 0,887 "views": 136,888 "category_id": 5,889 "featured_link": null,890 "has_accepted_answer": false,891 "posters": [892 {893 "extras": "latest single",894 "description": "Original Poster, Most Recent Poster",895 "user": {896 "id": 80786,897 "username": "berk",898 "name": "",899 "avatar_template": "/user_avatar/discuss.pytorch.org/berk/{size}/73881_2.png",900 "trust_level": 1901 }902 }903 ]904 },905 {906 "fancy_title": "Training Time is Increasing per epoch, Can somebody help me?",907 "id": 214900,908 "title": "Training Time is Increasing per epoch, Can somebody help me?",909 "slug": "training-time-is-increasing-per-epoch-can-somebody-help-me",910 "posts_count": 6,911 "reply_count": 4,912 "highest_post_number": 6,913 "image_url": null,914 "created_at": "2025-01-02T17:21:10.454Z",915 "last_posted_at": "2025-01-17T18:10:59.673Z",916 "bumped": true,917 "bumped_at": "2025-01-17T18:10:59.673Z",918 "archetype": "regular",919 "unseen": false,920 "pinned": false,921 "unpinned": null,922 "visible": true,923 "closed": false,924 "archived": false,925 "bookmarked": null,926 "liked": null,927 "tags_descriptions": {},928 "like_count": 3,929 "views": 183,930 "category_id": 5,931 "featured_link": null,932 "has_accepted_answer": true,933 "posters": [934 {935 "extras": "latest",936 "description": "Original Poster, Most Recent Poster",937 "user": {938 "id": 81840,939 "username": "iran_boy",940 "name": "iran boy",941 "avatar_template": "/user_avatar/discuss.pytorch.org/iran_boy/{size}/74864_2.png",942 "trust_level": 0943 }944 },945 {946 "extras": null,947 "description": "Frequent Poster, Accepted Answer",948 "user": {949 "id": 3534,950 "username": "ptrblck",951 "name": "",952 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",953 "admin": true,954 "moderator": true,955 "trust_level": 2956 }957 }958 ]959 },960 {961 "fancy_title": "Parity mismatch between torch and tensorRT for ultralytics yolo-v11 model",962 "id": 218602,963 "title": "Parity mismatch between torch and tensorRT for ultralytics yolo-v11 model",964 "slug": "parity-mismatch-between-torch-and-tensorrt-for-ultralytics-yolo-v11-model",965 "posts_count": 1,966 "reply_count": 0,967 "highest_post_number": 1,968 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/e/3/e31d9ba78eab2ae23d4b926bc034a4cf1a86eaa8.png",969 "created_at": "2025-04-04T00:22:22.544Z",970 "last_posted_at": "2025-04-04T00:22:22.590Z",971 "bumped": true,972 "bumped_at": "2025-04-04T00:22:22.590Z",973 "archetype": "regular",974 "unseen": false,975 "pinned": false,976 "unpinned": null,977 "visible": true,978 "closed": false,979 "archived": false,980 "bookmarked": null,981 "liked": null,982 "tags_descriptions": {},983 "like_count": 0,984 "views": 79,985 "category_id": 5,986 "featured_link": null,987 "has_accepted_answer": false,988 "posters": [989 {990 "extras": "latest single",991 "description": "Original Poster, Most Recent Poster",992 "user": {993 "id": 83626,994 "username": "d_utkarsh",995 "name": "Utkarsh Deshmukh",996 "avatar_template": "/letter_avatar_proxy/v4/letter/d/b9bd4f/{size}.png",997 "trust_level": 0998 }999 }1000 ]1001 }1002 ],1003 "tags_descriptions": {},1004 "fancy_title": "Re-training deeplab v3",1005 "id": 192986,1006 "title": "Re-training deeplab v3",1007 "posts_count": 1,1008 "created_at": "2023-12-02T04:35:27.988Z",1009 "views": 581,1010 "reply_count": 0,1011 "like_count": 0,1012 "last_posted_at": "2023-12-02T04:35:28.063Z",1013 "visible": true,1014 "closed": false,1015 "archived": false,1016 "has_summary": false,1017 "archetype": "regular",1018 "slug": "re-training-deeplab-v3",1019 "category_id": 5,1020 "word_count": 429,1021 "deleted_at": null,1022 "user_id": 71416,1023 "featured_link": null,1024 "pinned_globally": false,1025 "pinned_at": null,1026 "pinned_until": null,1027 "image_url": null,1028 "slow_mode_seconds": 0,1029 "draft": null,1030 "draft_key": "topic_192986",1031 "draft_sequence": null,1032 "unpinned": null,1033 "pinned": false,1034 "current_post_number": 1,1035 "highest_post_number": 1,1036 "deleted_by": null,1037 "actions_summary": [1038 {1039 "id": 4,1040 "count": 0,1041 "hidden": false,1042 "can_act": false1043 },1044 {1045 "id": 8,1046 "count": 0,1047 "hidden": false,1048 "can_act": false1049 },1050 {1051 "id": 10,1052 "count": 0,1053 "hidden": false,1054 "can_act": false1055 },1056 {1057 "id": 7,1058 "count": 0,1059 "hidden": false,1060 "can_act": false1061 }1062 ],1063 "chunk_size": 20,1064 "bookmarked": false,1065 "topic_timer": null,1066 "message_bus_last_id": 0,1067 "participant_count": 1,1068 "show_read_indicator": false,1069 "thumbnails": null,1070 "slow_mode_enabled_until": null,1071 "can_vote": false,1072 "vote_count": 0,1073 "user_voted": false,1074 "discourse_zendesk_plugin_zendesk_id": null,1075 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",1076 "details": {1077 "can_edit": false,1078 "notification_level": 1,1079 "participants": [1080 {1081 "id": 71416,1082 "username": "mahoo",1083 "name": "",1084 "avatar_template": "/letter_avatar_proxy/v4/letter/m/f9ae1b/{size}.png",1085 "post_count": 1,1086 "primary_group_name": null,1087 "flair_name": null,1088 "flair_url": null,1089 "flair_color": null,1090 "flair_bg_color": null,1091 "flair_group_id": null,1092 "trust_level": 01093 }1094 ],1095 "created_by": {1096 "id": 71416,1097 "username": "mahoo",1098 "name": "",1099 "avatar_template": "/letter_avatar_proxy/v4/letter/m/f9ae1b/{size}.png"1100 },1101 "last_poster": {1102 "id": 71416,1103 "username": "mahoo",1104 "name": "",1105 "avatar_template": "/letter_avatar_proxy/v4/letter/m/f9ae1b/{size}.png"1106 }1107 },1108 "bookmarks": []1109 },1110 {1111 "post_stream": {1112 "posts": [1113 {1114 "id": 425963,1115 "name": "Sayan Das",1116 "username": "Sayan01",1117 "avatar_template": "/user_avatar/discuss.pytorch.org/sayan01/{size}/62133_2.png",1118 "created_at": "2023-12-02T01:36:59.410Z",1119 "cooked": "<p>What kind of junk servers are Pytorch websites hosted on? It is repeatedly timing out the download. And please don’t try to say that the issue is something else.<br>\n<div class=\"lightbox-wrapper\"><a class=\"lightbox\" href=\"https://discuss.pytorch.org/uploads/default/original/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24.png\" data-download-href=\"https://discuss.pytorch.org/uploads/default/638eb2ce8733bad810a421f1194ff505af263a24\" title=\"Screen Shot 2023-12-02 at 12.34.00 PM\"><img src=\"https://discuss.pytorch.org/uploads/default/optimized/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24_2_690x88.png\" alt=\"Screen Shot 2023-12-02 at 12.34.00 PM\" data-base62-sha1=\"ecIZYydwgFA6YxSBgYpm6yjnIjy\" width=\"690\" height=\"88\" srcset=\"https://discuss.pytorch.org/uploads/default/optimized/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24_2_690x88.png, https://discuss.pytorch.org/uploads/default/optimized/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24_2_1035x132.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24.png 2x\" data-dominant-color=\"F7EAE8\"><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\">Screen Shot 2023-12-02 at 12.34.00 PM</span><span class=\"informations\">1098×141 27.7 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>",1120 "post_number": 1,1121 "post_type": 1,1122 "posts_count": 2,1123 "updated_at": "2023-12-02T01:38:08.777Z",1124 "reply_count": 0,1125 "reply_to_post_number": null,1126 "quote_count": 0,1127 "incoming_link_count": 16,1128 "reads": 2,1129 "readers_count": 1,1130 "score": 80.4,1131 "yours": false,1132 "topic_id": 192981,1133 "topic_slug": "pytorch-website-timing-out",1134 "display_username": "Sayan Das",1135 "primary_group_name": null,1136 "flair_name": null,1137 "flair_url": null,1138 "flair_bg_color": null,1139 "flair_color": null,1140 "flair_group_id": null,1141 "badges_granted": [],1142 "version": 1,1143 "can_edit": false,1144 "can_delete": false,1145 "can_recover": false,1146 "can_see_hidden_post": false,1147 "can_wiki": false,1148 "link_counts": [1149 {1150 "url": "https://discuss.pytorch.org/uploads/default/original/3X/6/3/638eb2ce8733bad810a421f1194ff505af263a24.png",1151 "internal": true,1152 "reflection": false,1153 "clicks": 01154 }1155 ],1156 "read": true,1157 "user_title": null,1158 "bookmarked": false,1159 "actions_summary": [],1160 "moderator": false,1161 "admin": false,1162 "staff": false,1163 "user_id": 71413,1164 "hidden": false,1165 "trust_level": 1,1166 "deleted_at": null,1167 "user_deleted": false,1168 "edit_reason": null,1169 "can_view_edit_history": true,1170 "wiki": false,1171 "post_url": "/t/pytorch-website-timing-out/192981/1",1172 "can_accept_answer": false,1173 "can_unaccept_answer": false,1174 "accepted_answer": false,1175 "topic_accepted_answer": null,1176 "can_vote": false1177 },1178 {1179 "id": 425964,1180 "name": "",1181 "username": "ptrblck",1182 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1183 "created_at": "2023-12-02T02:38:27.861Z",1184 "cooked": "<p>Could you please watch your language?<br>\nAlso, which install command are you using?</p>",1185 "post_number": 2,1186 "post_type": 1,1187 "posts_count": 2,1188 "updated_at": "2023-12-02T02:38:27.861Z",1189 "reply_count": 0,1190 "reply_to_post_number": null,1191 "quote_count": 0,1192 "incoming_link_count": 1,1193 "reads": 1,1194 "readers_count": 0,1195 "score": 5.2,1196 "yours": false,1197 "topic_id": 192981,1198 "topic_slug": "pytorch-website-timing-out",1199 "display_username": "",1200 "primary_group_name": null,