Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 183971,7 "name": "Dishank Bansal",8 "username": "Dishank_Bansal",9 "avatar_template": "/user_avatar/discuss.pytorch.org/dishank_bansal/{size}/16855_2.png",10 "created_at": "2020-04-19T06:16:02.859Z",11 "cooked": "<p>I am getting CUDA out of memory error running following.</p>\n<pre><code class=\"lang-auto\">def train(self, epochs, saving_freq):\n assert self.model.train\n while self.epoch <= epochs:\n running_loss = {}\n\n for idx, batch_sample in enumerate(self.train_loader):\n print(\"Iteration:\", idx)\n loss_dict = self.train_step(batch_sample)\n \n if idx%10==0:\n with torch.no_grad():\n #----------- Logging and Printing ----------#\n print(\"{:<8d} {:<9d} {:<7.4f}\".format(self.epoch, idx, loss_dict['tot_loss'].item()))\n for loss_name, value in loss_dict.items():\n self.tb_writer.add_scalar('Loss/'+loss_name, value.item())\n</code></pre>\n<p>where <code>train_step</code> is defined as:</p>\n<pre><code class=\"lang-auto\"> def train_step(self, batch_sample):\n in_images = batch_sample['image'].to(self.device)\n target = [x.to(self.device) for x in batch_sample['target']]\n\n rpn_proposals, instances, rpn_losses, detection_losses = self.model(in_images, target, self.is_training)\n print([len(x) for x in instances])\n \n loss_dict = {}\n loss_dict.update(rpn_losses)\n loss_dict.update(detection_losses)\n \n loss = 0.0\n for k, v in loss_dict.items():\n loss += v\n loss_dict.update({'tot_loss':loss})\n\n self.optimizer.zero_grad()\n # loss.backward()\n self.optimizer.step()\n\n return loss_dict\n</code></pre>\n<p>Weird thing is that if I do any of the following 3, the memory error goes away:</p>\n<ol>\n<li>uncomment loss.backward() - I understand that this frees memory graph, but even in my case, at each iteration, previous memory allocation should be freed itself.</li>\n<li>I change if <code>idx%10==0</code>: <code>to idx%1==0</code> in function <code>train()</code> . ie instead of doing it every iteration intead of every 10 iteration</li>\n<li>If I comment this line:</li>\n</ol>\n<pre><code class=\"lang-auto\">\nfor loss_name, value in loss_dict.items():\n self.tb_writer.add_scalar('Loss/'+loss_name, value.item())\n</code></pre>\n<p>So I guess above line is not allowing to free the memory. BTW, this line is just logging to tensorboard.</p>\n<p>Let me know if you need an error log.</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 1,15 "updated_at": "2020-04-19T06:21:18.323Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 18,20 "reads": 7,21 "readers_count": 6,22 "score": 91.4,23 "yours": false,24 "topic_id": 77394,25 "topic_slug": "cuda-memory-error-if-i-dont-call-backward",26 "display_username": "Dishank Bansal",27 "primary_group_name": null,28 "flair_name": null,29 "flair_url": null,30 "flair_bg_color": null,31 "flair_color": null,32 "flair_group_id": null,33 "badges_granted": [],34 "version": 2,35 "can_edit": false,36 "can_delete": false,37 "can_recover": false,38 "can_see_hidden_post": false,39 "can_wiki": false,40 "read": true,41 "user_title": null,42 "bookmarked": false,43 "actions_summary": [],44 "moderator": false,45 "admin": false,46 "staff": false,47 "user_id": 23530,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/cuda-memory-error-if-i-dont-call-backward/77394/1",56 "can_accept_answer": false,57 "can_unaccept_answer": false,58 "accepted_answer": false,59 "topic_accepted_answer": null,60 "can_vote": false61 }62 ],63 "stream": [64 18397165 ]66 },67 "timeline_lookup": [68 [69 1,70 201671 ]72 ],73 "suggested_topics": [74 {75 "fancy_title": "Build from source failing",76 "id": 217994,77 "title": "Build from source failing",78 "slug": "build-from-source-failing",79 "posts_count": 5,80 "reply_count": 2,81 "highest_post_number": 5,82 "image_url": null,83 "created_at": "2025-03-18T16:16:04.698Z",84 "last_posted_at": "2025-09-10T06:11:17.025Z",85 "bumped": true,86 "bumped_at": "2025-09-10T06:11:17.025Z",87 "archetype": "regular",88 "unseen": false,89 "pinned": false,90 "unpinned": null,91 "visible": true,92 "closed": false,93 "archived": false,94 "bookmarked": null,95 "liked": null,96 "tags_descriptions": {},97 "like_count": 0,98 "views": 211,99 "category_id": 1,100 "featured_link": null,101 "has_accepted_answer": false,102 "posters": [103 {104 "extras": null,105 "description": "Original Poster",106 "user": {107 "id": 83348,108 "username": "Krytern",109 "name": "",110 "avatar_template": "/user_avatar/discuss.pytorch.org/krytern/{size}/76527_2.png",111 "trust_level": 1112 }113 },114 {115 "extras": null,116 "description": "Frequent Poster",117 "user": {118 "id": 3534,119 "username": "ptrblck",120 "name": "",121 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",122 "admin": true,123 "moderator": true,124 "trust_level": 2125 }126 },127 {128 "extras": "latest",129 "description": "Most Recent Poster",130 "user": {131 "id": 85814,132 "username": "genofog",133 "name": "",134 "avatar_template": "/user_avatar/discuss.pytorch.org/genofog/{size}/78190_2.png",135 "trust_level": 0136 }137 }138 ]139 },140 {141 "fancy_title": "Install PyTorch 1.7",142 "id": 213881,143 "title": "Install PyTorch 1.7",144 "slug": "install-pytorch-1-7",145 "posts_count": 5,146 "reply_count": 3,147 "highest_post_number": 5,148 "image_url": "https://discuss.pytorch.org/uploads/default/optimized/3X/9/d/9d6121f6c5d76c51efced35dfb3949c6f5d304a3_2_1023x144.png",149 "created_at": "2024-12-05T22:40:54.483Z",150 "last_posted_at": "2024-12-06T16:09:25.133Z",151 "bumped": true,152 "bumped_at": "2024-12-06T16:58:31.417Z",153 "archetype": "regular",154 "unseen": false,155 "pinned": false,156 "unpinned": null,157 "visible": true,158 "closed": false,159 "archived": false,160 "bookmarked": null,161 "liked": null,162 "tags_descriptions": {},163 "like_count": 2,164 "views": 1244,165 "category_id": 1,166 "featured_link": null,167 "has_accepted_answer": true,168 "posters": [169 {170 "extras": "latest",171 "description": "Original Poster, Most Recent Poster",172 "user": {173 "id": 81343,174 "username": "adb57",175 "name": "",176 "avatar_template": "/letter_avatar_proxy/v4/letter/a/e9bcb4/{size}.png",177 "trust_level": 0178 }179 },180 {181 "extras": null,182 "description": "Frequent Poster, Accepted Answer",183 "user": {184 "id": 3534,185 "username": "ptrblck",186 "name": "",187 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",188 "admin": true,189 "moderator": true,190 "trust_level": 2191 }192 }193 ]194 },195 {196 "fancy_title": "Pytorch and Cuda version compatibility",197 "id": 216242,198 "title": "Pytorch and Cuda version compatibility",199 "slug": "pytorch-and-cuda-version-compatibility",200 "posts_count": 4,201 "reply_count": 2,202 "highest_post_number": 4,203 "image_url": null,204 "created_at": "2025-02-04T21:43:58.736Z",205 "last_posted_at": "2025-02-06T01:58:24.857Z",206 "bumped": true,207 "bumped_at": "2025-02-06T01:58:24.857Z",208 "archetype": "regular",209 "unseen": false,210 "pinned": false,211 "unpinned": null,212 "visible": true,213 "closed": false,214 "archived": false,215 "bookmarked": null,216 "liked": null,217 "tags_descriptions": {},218 "like_count": 0,219 "views": 814,220 "category_id": 1,221 "featured_link": null,222 "has_accepted_answer": false,223 "posters": [224 {225 "extras": null,226 "description": "Original Poster",227 "user": {228 "id": 82490,229 "username": "pooja-kabra",230 "name": "Pooja Kabra",231 "avatar_template": "/user_avatar/discuss.pytorch.org/pooja-kabra/{size}/75471_2.png",232 "trust_level": 1233 }234 },235 {236 "extras": "latest",237 "description": "Most Recent Poster",238 "user": {239 "id": 3534,240 "username": "ptrblck",241 "name": "",242 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",243 "admin": true,244 "moderator": true,245 "trust_level": 2246 }247 }248 ]249 },250 {251 "fancy_title": "Unexpected Behavior with Weight Sharing between nn.Linear and nn.Embedding",252 "id": 212223,253 "title": "Unexpected Behavior with Weight Sharing between nn.Linear and nn.Embedding",254 "slug": "unexpected-behavior-with-weight-sharing-between-nn-linear-and-nn-embedding",255 "posts_count": 3,256 "reply_count": 1,257 "highest_post_number": 3,258 "image_url": null,259 "created_at": "2024-10-28T22:58:14.282Z",260 "last_posted_at": "2024-10-29T00:47:09.870Z",261 "bumped": true,262 "bumped_at": "2024-10-29T00:47:09.870Z",263 "archetype": "regular",264 "unseen": false,265 "pinned": false,266 "unpinned": null,267 "visible": true,268 "closed": false,269 "archived": false,270 "bookmarked": null,271 "liked": null,272 "tags_descriptions": {},273 "like_count": 1,274 "views": 58,275 "category_id": 1,276 "featured_link": null,277 "has_accepted_answer": false,278 "posters": [279 {280 "extras": "latest",281 "description": "Original Poster, Most Recent Poster",282 "user": {283 "id": 59149,284 "username": "samlk",285 "name": "Kryštof Šaml",286 "avatar_template": "/letter_avatar_proxy/v4/letter/s/c57346/{size}.png",287 "trust_level": 1288 }289 },290 {291 "extras": null,292 "description": "Frequent Poster",293 "user": {294 "id": 3534,295 "username": "ptrblck",296 "name": "",297 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",298 "admin": true,299 "moderator": true,300 "trust_level": 2301 }302 }303 ]304 },305 {306 "fancy_title": "Homomorphic encryption of tensors?",307 "id": 218384,308 "title": "Homomorphic encryption of tensors?",309 "slug": "homomorphic-encryption-of-tensors",310 "posts_count": 1,311 "reply_count": 0,312 "highest_post_number": 1,313 "image_url": null,314 "created_at": "2025-03-28T23:27:27.467Z",315 "last_posted_at": "2025-03-28T23:27:27.506Z",316 "bumped": true,317 "bumped_at": "2025-03-28T23:27:27.506Z",318 "archetype": "regular",319 "unseen": false,320 "pinned": false,321 "unpinned": null,322 "visible": true,323 "closed": false,324 "archived": false,325 "bookmarked": null,326 "liked": null,327 "tags_descriptions": {},328 "like_count": 0,329 "views": 68,330 "category_id": 1,331 "featured_link": null,332 "has_accepted_answer": false,333 "posters": [334 {335 "extras": "latest single",336 "description": "Original Poster, Most Recent Poster",337 "user": {338 "id": 75981,339 "username": "Geremia",340 "name": "Geremia",341 "avatar_template": "/user_avatar/discuss.pytorch.org/geremia/{size}/70165_2.png",342 "trust_level": 2343 }344 }345 ]346 }347 ],348 "tags_descriptions": {},349 "fancy_title": "CUDA memory error if I don’t call .backward()",350 "id": 77394,351 "title": "CUDA memory error if I don't call .backward()",352 "posts_count": 1,353 "created_at": "2020-04-19T06:16:02.803Z",354 "views": 311,355 "reply_count": 0,356 "like_count": 0,357 "last_posted_at": "2020-04-19T06:16:02.859Z",358 "visible": true,359 "closed": false,360 "archived": false,361 "has_summary": false,362 "archetype": "regular",363 "slug": "cuda-memory-error-if-i-dont-call-backward",364 "category_id": 1,365 "word_count": 264,366 "deleted_at": null,367 "user_id": 23530,368 "featured_link": null,369 "pinned_globally": false,370 "pinned_at": null,371 "pinned_until": null,372 "image_url": null,373 "slow_mode_seconds": 0,374 "draft": null,375 "draft_key": "topic_77394",376 "draft_sequence": null,377 "unpinned": null,378 "pinned": false,379 "current_post_number": 1,380 "highest_post_number": 1,381 "deleted_by": null,382 "actions_summary": [383 {384 "id": 4,385 "count": 0,386 "hidden": false,387 "can_act": false388 },389 {390 "id": 8,391 "count": 0,392 "hidden": false,393 "can_act": false394 },395 {396 "id": 10,397 "count": 0,398 "hidden": false,399 "can_act": false400 },401 {402 "id": 7,403 "count": 0,404 "hidden": false,405 "can_act": false406 }407 ],408 "chunk_size": 20,409 "bookmarked": false,410 "topic_timer": null,411 "message_bus_last_id": 0,412 "participant_count": 1,413 "show_read_indicator": false,414 "thumbnails": null,415 "slow_mode_enabled_until": null,416 "can_vote": false,417 "vote_count": 0,418 "user_voted": false,419 "discourse_zendesk_plugin_zendesk_id": null,420 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",421 "details": {422 "can_edit": false,423 "notification_level": 1,424 "participants": [425 {426 "id": 23530,427 "username": "Dishank_Bansal",428 "name": "Dishank Bansal",429 "avatar_template": "/user_avatar/discuss.pytorch.org/dishank_bansal/{size}/16855_2.png",430 "post_count": 1,431 "primary_group_name": null,432 "flair_name": null,433 "flair_url": null,434 "flair_color": null,435 "flair_bg_color": null,436 "flair_group_id": null,437 "trust_level": 1438 }439 ],440 "created_by": {441 "id": 23530,442 "username": "Dishank_Bansal",443 "name": "Dishank Bansal",444 "avatar_template": "/user_avatar/discuss.pytorch.org/dishank_bansal/{size}/16855_2.png"445 },446 "last_poster": {447 "id": 23530,448 "username": "Dishank_Bansal",449 "name": "Dishank Bansal",450 "avatar_template": "/user_avatar/discuss.pytorch.org/dishank_bansal/{size}/16855_2.png"451 }452 },453 "bookmarks": []454 },455 {456 "post_stream": {457 "posts": [458 {459 "id": 183927,460 "name": "Aly Mostafa",461 "username": "Alymostafa",462 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",463 "created_at": "2020-04-19T03:53:06.214Z",464 "cooked": "<p>i use this CNN architecture to classify images (input : 224,224) , (output: 2 )</p>\n<pre><code class=\"lang-auto\">class ConvNet(nn.Module):\n def init(self, num_classes=2):\n super(ConvNet, self).init()\n self.layer1 = nn.Sequential(\n nn.Conv2d(1, 16, kernel_size=5, stride=1, padding=2),\n nn.ReLU(),\n nn.MaxPool2d(kernel_size=2, stride=2))\n self.layer2 = nn.Sequential(\n nn.Conv2d(16, 32, kernel_size=5, stride=1, padding=2),\n #nn.BatchNorm2d(64),\n nn.ReLU(),\n nn.MaxPool2d(kernel_size=5, stride=0))\n\n self.drop_out = nn.Dropout()\n\n self.fc1 = nn.Linear(15488, 1000)\n self.fc2 = nn.Linear(1000 ,2)\n\n def forward(self, x):\n x.float()\n #x = x.permute(0,3,1,2)\n out = self.layer1(x)\n out = self.layer2(out)\n out = out.reshape(out.size(0), -1)\n out = self.drop_out(out)\n out = self.fc1(out)\n out = self.fc2(out)\n\n return out\n</code></pre>\n<p>and it gives me :</p>\n<pre><code class=\"lang-auto\">RuntimeError: [enforce fail at ..\\c10\\core\\CPUAllocator.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 38816153600 bytes. Buy new RAM!\n</code></pre>\n<p>cpu : intel xeon® e5-2696 v3 , 2.30ghz<br>\nram : 110gb</p>",465 "post_number": 1,466 "post_type": 1,467 "posts_count": 11,468 "updated_at": "2020-04-19T03:53:06.214Z",469 "reply_count": 0,470 "reply_to_post_number": null,471 "quote_count": 0,472 "incoming_link_count": 364,473 "reads": 8,474 "readers_count": 7,475 "score": 1821.6,476 "yours": false,477 "topic_id": 77379,478 "topic_slug": "runtimeerror-no-enough-ram",479 "display_username": "Aly Mostafa",480 "primary_group_name": null,481 "flair_name": null,482 "flair_url": null,483 "flair_bg_color": null,484 "flair_color": null,485 "flair_group_id": null,486 "badges_granted": [],487 "version": 1,488 "can_edit": false,489 "can_delete": false,490 "can_recover": false,491 "can_see_hidden_post": false,492 "can_wiki": false,493 "read": true,494 "user_title": null,495 "bookmarked": false,496 "actions_summary": [],497 "moderator": false,498 "admin": false,499 "staff": false,500 "user_id": 29616,501 "hidden": false,502 "trust_level": 1,503 "deleted_at": null,504 "user_deleted": false,505 "edit_reason": null,506 "can_view_edit_history": true,507 "wiki": false,508 "post_url": "/t/runtimeerror-no-enough-ram/77379/1",509 "can_accept_answer": false,510 "can_unaccept_answer": false,511 "accepted_answer": false,512 "topic_accepted_answer": null,513 "can_vote": false514 },515 {516 "id": 183937,517 "name": "",518 "username": "ptrblck",519 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",520 "created_at": "2020-04-19T04:21:22.466Z",521 "cooked": "<p>How large is your batch size to create this error and how much of your RAM is already in use when running this script?</p>",522 "post_number": 2,523 "post_type": 1,524 "posts_count": 11,525 "updated_at": "2020-04-19T04:21:22.466Z",526 "reply_count": 1,527 "reply_to_post_number": null,528 "quote_count": 0,529 "incoming_link_count": 2,530 "reads": 8,531 "readers_count": 7,532 "score": 16.6,533 "yours": false,534 "topic_id": 77379,535 "topic_slug": "runtimeerror-no-enough-ram",536 "display_username": "",537 "primary_group_name": null,538 "flair_name": null,539 "flair_url": null,540 "flair_bg_color": null,541 "flair_color": null,542 "flair_group_id": null,543 "badges_granted": [],544 "version": 1,545 "can_edit": false,546 "can_delete": false,547 "can_recover": false,548 "can_see_hidden_post": false,549 "can_wiki": false,550 "read": true,551 "user_title": "",552 "bookmarked": false,553 "actions_summary": [],554 "moderator": true,555 "admin": true,556 "staff": true,557 "user_id": 3534,558 "hidden": false,559 "trust_level": 2,560 "deleted_at": null,561 "user_deleted": false,562 "edit_reason": null,563 "can_view_edit_history": true,564 "wiki": false,565 "post_url": "/t/runtimeerror-no-enough-ram/77379/2",566 "can_accept_answer": false,567 "can_unaccept_answer": false,568 "accepted_answer": false,569 "topic_accepted_answer": null570 },571 {572 "id": 183940,573 "name": "Aly Mostafa",574 "username": "Alymostafa",575 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",576 "created_at": "2020-04-19T04:33:03.643Z",577 "cooked": "<p>batch size : 5</p>\n<aside class=\"quote no-group\" data-username=\"ptrblck\" data-post=\"2\" data-topic=\"77379\">\n<div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img loading=\"lazy\" alt=\"\" width=\"24\" height=\"24\" src=\"https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png\" class=\"avatar\"> ptrblck:</div>\n<blockquote>\n<p>how much of your RAM is already in use when running this script?</p>\n</blockquote>\n</aside>\n<p>110 of 110</p>",578 "post_number": 3,579 "post_type": 1,580 "posts_count": 11,581 "updated_at": "2020-04-19T04:33:03.643Z",582 "reply_count": 1,583 "reply_to_post_number": 2,584 "quote_count": 1,585 "incoming_link_count": 3,586 "reads": 8,587 "readers_count": 7,588 "score": 21.6,589 "yours": false,590 "topic_id": 77379,591 "topic_slug": "runtimeerror-no-enough-ram",592 "display_username": "Aly Mostafa",593 "primary_group_name": null,594 "flair_name": null,595 "flair_url": null,596 "flair_bg_color": null,597 "flair_color": null,598 "flair_group_id": null,599 "badges_granted": [],600 "version": 1,601 "can_edit": false,602 "can_delete": false,603 "can_recover": false,604 "can_see_hidden_post": false,605 "can_wiki": false,606 "read": true,607 "user_title": null,608 "bookmarked": false,609 "actions_summary": [],610 "moderator": false,611 "admin": false,612 "staff": false,613 "user_id": 29616,614 "hidden": false,615 "trust_level": 1,616 "deleted_at": null,617 "user_deleted": false,618 "edit_reason": null,619 "can_view_edit_history": true,620 "wiki": false,621 "post_url": "/t/runtimeerror-no-enough-ram/77379/3",622 "can_accept_answer": false,623 "can_unaccept_answer": false,624 "accepted_answer": false,625 "topic_accepted_answer": null626 },627 {628 "id": 183941,629 "name": "",630 "username": "ptrblck",631 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",632 "created_at": "2020-04-19T04:34:18.333Z",633 "cooked": "<p>If your main RAM is already filled before executing this script, how much swap do you have?<br>\nNote that using the swap will hit your performance pretty hard.</p>",634 "post_number": 4,635 "post_type": 1,636 "posts_count": 11,637 "updated_at": "2020-04-19T04:34:18.333Z",638 "reply_count": 1,639 "reply_to_post_number": 3,640 "quote_count": 0,641 "incoming_link_count": 2,642 "reads": 8,643 "readers_count": 7,644 "score": 16.6,645 "yours": false,646 "topic_id": 77379,647 "topic_slug": "runtimeerror-no-enough-ram",648 "display_username": "",649 "primary_group_name": null,650 "flair_name": null,651 "flair_url": null,652 "flair_bg_color": null,653 "flair_color": null,654 "flair_group_id": null,655 "badges_granted": [],656 "version": 1,657 "can_edit": false,658 "can_delete": false,659 "can_recover": false,660 "can_see_hidden_post": false,661 "can_wiki": false,662 "read": true,663 "user_title": "",664 "reply_to_user": {665 "id": 29616,666 "username": "Alymostafa",667 "name": "Aly Mostafa",668 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png"669 },670 "bookmarked": false,671 "actions_summary": [],672 "moderator": true,673 "admin": true,674 "staff": true,675 "user_id": 3534,676 "hidden": false,677 "trust_level": 2,678 "deleted_at": null,679 "user_deleted": false,680 "edit_reason": null,681 "can_view_edit_history": true,682 "wiki": false,683 "post_url": "/t/runtimeerror-no-enough-ram/77379/4",684 "can_accept_answer": false,685 "can_unaccept_answer": false,686 "accepted_answer": false,687 "topic_accepted_answer": null688 },689 {690 "id": 183944,691 "name": "Aly Mostafa",692 "username": "Alymostafa",693 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",694 "created_at": "2020-04-19T04:38:03.287Z",695 "cooked": "<p>before running this script ram is : 5 of 110<br>\nafter running this script ram is : 110 of 110<br>\nmemory : 96<br>\nwith swap : 120</p>",696 "post_number": 5,697 "post_type": 1,698 "posts_count": 11,699 "updated_at": "2020-04-19T04:38:10.781Z",700 "reply_count": 1,701 "reply_to_post_number": 4,702 "quote_count": 0,703 "incoming_link_count": 1,704 "reads": 7,705 "readers_count": 6,706 "score": 11.4,707 "yours": false,708 "topic_id": 77379,709 "topic_slug": "runtimeerror-no-enough-ram",710 "display_username": "Aly Mostafa",711 "primary_group_name": null,712 "flair_name": null,713 "flair_url": null,714 "flair_bg_color": null,715 "flair_color": null,716 "flair_group_id": null,717 "badges_granted": [],718 "version": 1,719 "can_edit": false,720 "can_delete": false,721 "can_recover": false,722 "can_see_hidden_post": false,723 "can_wiki": false,724 "read": true,725 "user_title": null,726 "reply_to_user": {727 "id": 3534,728 "username": "ptrblck",729 "name": "",730 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"731 },732 "bookmarked": false,733 "actions_summary": [],734 "moderator": false,735 "admin": false,736 "staff": false,737 "user_id": 29616,738 "hidden": false,739 "trust_level": 1,740 "deleted_at": null,741 "user_deleted": false,742 "edit_reason": null,743 "can_view_edit_history": true,744 "wiki": false,745 "post_url": "/t/runtimeerror-no-enough-ram/77379/5",746 "can_accept_answer": false,747 "can_unaccept_answer": false,748 "accepted_answer": false,749 "topic_accepted_answer": null750 },751 {752 "id": 183947,753 "name": "",754 "username": "ptrblck",755 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",756 "created_at": "2020-04-19T04:46:25.399Z",757 "cooked": "<p>For an input of <code>[5, 1, 224, 224]</code>, your forward pass will use ~120MB.</p>\n<p>Could you post an executable code snippet to reproduce the >105GB memory allocation?</p>",758 "post_number": 6,759 "post_type": 1,760 "posts_count": 11,761 "updated_at": "2020-04-19T04:46:25.399Z",762 "reply_count": 1,763 "reply_to_post_number": 5,764 "quote_count": 0,765 "incoming_link_count": 1,766 "reads": 7,767 "readers_count": 6,768 "score": 11.4,769 "yours": false,770 "topic_id": 77379,771 "topic_slug": "runtimeerror-no-enough-ram",772 "display_username": "",773 "primary_group_name": null,774 "flair_name": null,775 "flair_url": null,776 "flair_bg_color": null,777 "flair_color": null,778 "flair_group_id": null,779 "badges_granted": [],780 "version": 1,781 "can_edit": false,782 "can_delete": false,783 "can_recover": false,784 "can_see_hidden_post": false,785 "can_wiki": false,786 "read": true,787 "user_title": "",788 "reply_to_user": {789 "id": 29616,790 "username": "Alymostafa",791 "name": "Aly Mostafa",792 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png"793 },794 "bookmarked": false,795 "actions_summary": [],796 "moderator": true,797 "admin": true,798 "staff": true,799 "user_id": 3534,800 "hidden": false,801 "trust_level": 2,802 "deleted_at": null,803 "user_deleted": false,804 "edit_reason": null,805 "can_view_edit_history": true,806 "wiki": false,807 "post_url": "/t/runtimeerror-no-enough-ram/77379/6",808 "can_accept_answer": false,809 "can_unaccept_answer": false,810 "accepted_answer": false,811 "topic_accepted_answer": null812 },813 {814 "id": 183953,815 "name": "Aly Mostafa",816 "username": "Alymostafa",817 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",818 "created_at": "2020-04-19T05:12:50.143Z",819 "cooked": "<aside class=\"quote no-group\" data-username=\"ptrblck\" data-post=\"6\" data-topic=\"77379\">\n<div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img loading=\"lazy\" alt=\"\" width=\"24\" height=\"24\" src=\"https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png\" class=\"avatar\"> ptrblck:</div>\n<blockquote>\n<p>Could you post an executable code snippet to reproduce the >105GB memory allocation?</p>\n</blockquote>\n</aside>\n<p>can you specify what do you mean by an executable code snippet to reproduce the >105GB memory allocation ?</p>",820 "post_number": 7,821 "post_type": 1,822 "posts_count": 11,823 "updated_at": "2020-04-19T05:12:50.143Z",824 "reply_count": 1,825 "reply_to_post_number": 6,826 "quote_count": 1,827 "incoming_link_count": 3,828 "reads": 7,829 "readers_count": 6,830 "score": 21.4,831 "yours": false,832 "topic_id": 77379,833 "topic_slug": "runtimeerror-no-enough-ram",834 "display_username": "Aly Mostafa",835 "primary_group_name": null,836 "flair_name": null,837 "flair_url": null,838 "flair_bg_color": null,839 "flair_color": null,840 "flair_group_id": null,841 "badges_granted": [],842 "version": 1,843 "can_edit": false,844 "can_delete": false,845 "can_recover": false,846 "can_see_hidden_post": false,847 "can_wiki": false,848 "read": true,849 "user_title": null,850 "bookmarked": false,851 "actions_summary": [],852 "moderator": false,853 "admin": false,854 "staff": false,855 "user_id": 29616,856 "hidden": false,857 "trust_level": 1,858 "deleted_at": null,859 "user_deleted": false,860 "edit_reason": null,861 "can_view_edit_history": true,862 "wiki": false,863 "post_url": "/t/runtimeerror-no-enough-ram/77379/7",864 "can_accept_answer": false,865 "can_unaccept_answer": false,866 "accepted_answer": false,867 "topic_accepted_answer": null868 },869 {870 "id": 183956,871 "name": "",872 "username": "ptrblck",873 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",874 "created_at": "2020-04-19T05:14:54.358Z",875 "cooked": "<p>A code snippet I could run on my machine to reproduce the large memory allocation.<br>\nAt the moment I’m using your model definition and a random input in the shape <code>[5, 1, 224, 224]</code> in the forward pass, which only uses 120MB, which is far off of the reported 105GB.</p>",876 "post_number": 8,877 "post_type": 1,878 "posts_count": 11,879 "updated_at": "2020-04-19T05:14:54.358Z",880 "reply_count": 1,881 "reply_to_post_number": 7,882 "quote_count": 0,883 "incoming_link_count": 1,884 "reads": 7,885 "readers_count": 6,886 "score": 11.4,887 "yours": false,888 "topic_id": 77379,889 "topic_slug": "runtimeerror-no-enough-ram",890 "display_username": "",891 "primary_group_name": null,892 "flair_name": null,893 "flair_url": null,894 "flair_bg_color": null,895 "flair_color": null,896 "flair_group_id": null,897 "badges_granted": [],898 "version": 1,899 "can_edit": false,900 "can_delete": false,901 "can_recover": false,902 "can_see_hidden_post": false,903 "can_wiki": false,904 "read": true,905 "user_title": "",906 "reply_to_user": {907 "id": 29616,908 "username": "Alymostafa",909 "name": "Aly Mostafa",910 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png"911 },912 "bookmarked": false,913 "actions_summary": [],914 "moderator": true,915 "admin": true,916 "staff": true,917 "user_id": 3534,918 "hidden": false,919 "trust_level": 2,920 "deleted_at": null,921 "user_deleted": false,922 "edit_reason": null,923 "can_view_edit_history": true,924 "wiki": false,925 "post_url": "/t/runtimeerror-no-enough-ram/77379/8",926 "can_accept_answer": false,927 "can_unaccept_answer": false,928 "accepted_answer": false,929 "topic_accepted_answer": null930 },931 {932 "id": 183962,933 "name": "Aly Mostafa",934 "username": "Alymostafa",935 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",936 "created_at": "2020-04-19T06:02:28.333Z",937 "cooked": "<p>I couldn’t fully know which piece of code should be sent so this is the full repo on github.<br>\nplease before you run it make sure to put the “covid” folder alongside the “other” folder in a folder called “data”<br>\n<aside class=\"onebox whitelistedgeneric\">\n <header class=\"source\">\n <img src=\"https://github.githubassets.com/favicons/favicon.svg\" class=\"site-icon\" width=\"16\" height=\"16\">\n <a href=\"https://github.com/lnBrTgAaaL/Pattern-Rocognition-COVID-19\" target=\"_blank\" rel=\"nofollow noopener\">GitHub</a>\n </header>\n <article class=\"onebox-body\">\n <img src=\"https://avatars0.githubusercontent.com/u/58595056?s=400&v=4\" class=\"thumbnail onebox-avatar\" width=\"60\" height=\"60\">\n\n<h3><a href=\"https://github.com/lnBrTgAaaL/Pattern-Rocognition-COVID-19\" target=\"_blank\" rel=\"nofollow noopener\">lnBrTgAaaL/Pattern-Rocognition-COVID-19</a></h3>\n\n<p>Contribute to lnBrTgAaaL/Pattern-Rocognition-COVID-19 development by creating an account on GitHub.</p>\n\n\n </article>\n <div class=\"onebox-metadata\">\n \n \n </div>\n <div style=\"clear: both\"></div>\n</aside>\n<br>\nyour help is very much appreciated</p>",938 "post_number": 9,939 "post_type": 1,940 "posts_count": 11,941 "updated_at": "2020-04-19T06:02:28.333Z",942 "reply_count": 1,943 "reply_to_post_number": 8,944 "quote_count": 0,945 "incoming_link_count": 4,946 "reads": 4,947 "readers_count": 3,948 "score": 25.8,949 "yours": false,950 "topic_id": 77379,951 "topic_slug": "runtimeerror-no-enough-ram",952 "display_username": "Aly Mostafa",953 "primary_group_name": null,954 "flair_name": null,955 "flair_url": null,956 "flair_bg_color": null,957 "flair_color": null,958 "flair_group_id": null,959 "badges_granted": [],960 "version": 1,961 "can_edit": false,962 "can_delete": false,963 "can_recover": false,964 "can_see_hidden_post": false,965 "can_wiki": false,966 "link_counts": [967 {968 "url": "https://github.com/lnBrTgAaaL/Pattern-Rocognition-COVID-19",969 "internal": false,970 "reflection": false,971 "title": "GitHub - lnBrTgAaaL/Pattern-Rocognition-COVID-19",972 "clicks": 1973 }974 ],975 "read": true,976 "user_title": null,977 "reply_to_user": {978 "id": 3534,979 "username": "ptrblck",980 "name": "",981 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"982 },983 "bookmarked": false,984 "actions_summary": [],985 "moderator": false,986 "admin": false,987 "staff": false,988 "user_id": 29616,989 "hidden": false,990 "trust_level": 1,991 "deleted_at": null,992 "user_deleted": false,993 "edit_reason": null,994 "can_view_edit_history": true,995 "wiki": false,996 "post_url": "/t/runtimeerror-no-enough-ram/77379/9",997 "can_accept_answer": false,998 "can_unaccept_answer": false,999 "accepted_answer": false,1000 "topic_accepted_answer": null1001 },1002 {1003 "id": 183964,1004 "name": "",1005 "username": "ptrblck",1006 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1007 "created_at": "2020-04-19T06:06:05.427Z",1008 "cooked": "<p>It seems you are directly loading all images to your RAM in this cell:</p>\n<pre><code class=\"lang-python\">print(\"[INFO] loading images...\")\nimagePaths = list(paths.list_images(args[\"dataset_1\"]))\ndata = []\nlabels = []\nfor imagePath in imagePaths:\n label = imagePath.split(os.path.sep)[-2]\n image = cv2.imread(imagePath)\n image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)\n image = cv2.resize(image, (224, 224))\n data.append(image)\n labels.append(label)\ndata = np.array(data) / 255.0\nlabels = np.array(labels)\n</code></pre>\n<p>Depending on the number of images and their size, this might take a lot of memory.<br>\nIf you are dealing with a large dataset, it’s recommended to lazily load the batches using a <code>Dataset</code> and <code>DataLoader</code> as described in <a href=\"https://pytorch.org/tutorials/beginner/data_loading_tutorial.html\">this tutorial</a>.<br>\nHow many images does your dataset have and how large is each image after preprocessing?</p>",1009 "post_number": 10,1010 "post_type": 1,1011 "posts_count": 11,1012 "updated_at": "2020-04-19T06:06:05.427Z",1013 "reply_count": 1,1014 "reply_to_post_number": 9,1015 "quote_count": 0,1016 "incoming_link_count": 4,1017 "reads": 4,1018 "readers_count": 3,1019 "score": 25.8,1020 "yours": false,1021 "topic_id": 77379,1022 "topic_slug": "runtimeerror-no-enough-ram",1023 "display_username": "",1024 "primary_group_name": null,1025 "flair_name": null,1026 "flair_url": null,1027 "flair_bg_color": null,1028 "flair_color": null,1029 "flair_group_id": null,1030 "badges_granted": [],1031 "version": 1,1032 "can_edit": false,1033 "can_delete": false,1034 "can_recover": false,1035 "can_see_hidden_post": false,1036 "can_wiki": false,1037 "link_counts": [1038 {1039 "url": "https://pytorch.org/tutorials/beginner/data_loading_tutorial.html",1040 "internal": false,1041 "reflection": false,1042 "title": "Writing Custom Datasets, DataLoaders and Transforms — PyTorch Tutorials 1.4.0 documentation",1043 "clicks": 131044 }1045 ],1046 "read": true,1047 "user_title": "",1048 "reply_to_user": {1049 "id": 29616,1050 "username": "Alymostafa",1051 "name": "Aly Mostafa",1052 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png"1053 },1054 "bookmarked": false,1055 "actions_summary": [],1056 "moderator": true,1057 "admin": true,1058 "staff": true,1059 "user_id": 3534,1060 "hidden": false,1061 "trust_level": 2,1062 "deleted_at": null,1063 "user_deleted": false,1064 "edit_reason": null,1065 "can_view_edit_history": true,1066 "wiki": false,1067 "post_url": "/t/runtimeerror-no-enough-ram/77379/10",1068 "can_accept_answer": false,1069 "can_unaccept_answer": false,1070 "accepted_answer": false,1071 "topic_accepted_answer": null1072 },1073 {1074 "id": 183967,1075 "name": "Aly Mostafa",1076 "username": "Alymostafa",1077 "avatar_template": "/user_avatar/discuss.pytorch.org/alymostafa/{size}/22446_2.png",1078 "created_at": "2020-04-19T06:07:59.051Z",1079 "cooked": "<p>1075 images with an average of 400kb \\ image , i am using this so i can make sure that the picture is in grayscaler not RBG.so what can we use instead for this matter ?</p>",1080 "post_number": 11,1081 "post_type": 1,1082 "posts_count": 11,1083 "updated_at": "2020-04-19T06:11:04.306Z",1084 "reply_count": 0,1085 "reply_to_post_number": 10,1086 "quote_count": 0,1087 "incoming_link_count": 2,1088 "reads": 4,1089 "readers_count": 3,1090 "score": 10.8,1091 "yours": false,1092 "topic_id": 77379,1093 "topic_slug": "runtimeerror-no-enough-ram",1094 "display_username": "Aly Mostafa",1095 "primary_group_name": null,1096 "flair_name": null,1097 "flair_url": null,1098 "flair_bg_color": null,1099 "flair_color": null,1100 "flair_group_id": null,1101 "badges_granted": [],1102 "version": 2,1103 "can_edit": false,1104 "can_delete": false,1105 "can_recover": false,1106 "can_see_hidden_post": false,1107 "can_wiki": false,1108 "read": true,1109 "user_title": null,1110 "reply_to_user": {1111 "id": 3534,1112 "username": "ptrblck",1113 "name": "",1114 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png"1115 },1116 "bookmarked": false,1117 "actions_summary": [],1118 "moderator": false,1119 "admin": false,1120 "staff": false,1121 "user_id": 29616,1122 "hidden": false,1123 "trust_level": 1,1124 "deleted_at": null,1125 "user_deleted": false,1126 "edit_reason": null,1127 "can_view_edit_history": true,1128 "wiki": false,1129 "post_url": "/t/runtimeerror-no-enough-ram/77379/11",1130 "can_accept_answer": false,1131 "can_unaccept_answer": false,1132 "accepted_answer": false,1133 "topic_accepted_answer": null1134 }1135 ],1136 "stream": [1137 183927,1138 183937,1139 183940,1140 183941,1141 183944,1142 183947,1143 183953,1144 183956,1145 183962,1146 183964,1147 1839671148 ]1149 },1150 "timeline_lookup": [1151 [1152 1,1153 20161154 ]1155 ],1156 "suggested_topics": [1157 {1158 "fancy_title": "Trying to setup a service, need some quick help with pytorch/cuda compatibility",1159 "id": 212941,1160 "title": "Trying to setup a service, need some quick help with pytorch/cuda compatibility",1161 "slug": "trying-to-setup-a-service-need-some-quick-help-with-pytorch-cuda-compatibility",1162 "posts_count": 5,1163 "reply_count": 1,1164 "highest_post_number": 5,1165 "image_url": null,1166 "created_at": "2024-11-13T17:12:20.490Z",1167 "last_posted_at": "2024-11-14T22:34:42.979Z",1168 "bumped": true,1169 "bumped_at": "2024-11-14T22:34:42.979Z",1170 "archetype": "regular",1171 "unseen": false,1172 "pinned": false,1173 "unpinned": null,1174 "visible": true,1175 "closed": false,1176 "archived": false,1177 "bookmarked": null,1178 "liked": null,1179 "tags_descriptions": {},1180 "like_count": 1,1181 "views": 556,1182 "category_id": 1,1183 "featured_link": null,1184 "has_accepted_answer": false,1185 "posters": [1186 {1187 "extras": "latest",1188 "description": "Original Poster, Most Recent Poster",1189 "user": {1190 "id": 80892,1191 "username": "dillonius",1192 "name": "",1193 "avatar_template": "/user_avatar/discuss.pytorch.org/dillonius/{size}/73979_2.png",1194 "trust_level": 01195 }1196 },1197 {1198 "extras": null,1199 "description": "Frequent Poster",1200 "user": {