Anurag1734/cuda-error-resolution-analysis
07
1[2 {3 "post_stream": {4 "posts": [5 {6 "id": 237704,7 "name": "antran96",8 "username": "antran96",9 "avatar_template": "/user_avatar/discuss.pytorch.org/antran96/{size}/11415_2.png",10 "created_at": "2020-10-20T09:25:36.559Z",11 "cooked": "<p>Which one is a better practice to detach a tensor without expanding CPU memory too much?<code> x.detach() or x.cpu() ?</code><br>\nI found out that if I perform <code>x.cpu()</code>, my memory expand quickly and soon reach memory limit error in slurm.</p>",12 "post_number": 1,13 "post_type": 1,14 "posts_count": 2,15 "updated_at": "2020-10-20T09:25:36.559Z",16 "reply_count": 0,17 "reply_to_post_number": null,18 "quote_count": 0,19 "incoming_link_count": 8155,20 "reads": 149,21 "readers_count": 148,22 "score": 40759.8,23 "yours": false,24 "topic_id": 99991,25 "topic_slug": "detach-vs-cpu",26 "display_username": "antran96",27 "primary_group_name": null,28 "flair_name": null,29 "flair_url": null,30 "flair_bg_color": null,31 "flair_color": null,32 "flair_group_id": null,33 "badges_granted": [],34 "version": 1,35 "can_edit": false,36 "can_delete": false,37 "can_recover": false,38 "can_see_hidden_post": false,39 "can_wiki": false,40 "read": true,41 "user_title": null,42 "bookmarked": false,43 "actions_summary": [44 {45 "id": 2,46 "count": 147 }48 ],49 "moderator": false,50 "admin": false,51 "staff": false,52 "user_id": 17988,53 "hidden": false,54 "trust_level": 1,55 "deleted_at": null,56 "user_deleted": false,57 "edit_reason": null,58 "can_view_edit_history": true,59 "wiki": false,60 "post_url": "/t/detach-vs-cpu/99991/1",61 "can_accept_answer": false,62 "can_unaccept_answer": false,63 "accepted_answer": false,64 "topic_accepted_answer": null,65 "can_vote": false66 },67 {68 "id": 237811,69 "name": "Alban D",70 "username": "albanD",71 "avatar_template": "/user_avatar/discuss.pytorch.org/alband/{size}/215_2.png",72 "created_at": "2020-10-20T15:35:52.992Z",73 "cooked": "<p>Hi,</p>\n<p>The two have very different (and non-overlapping) effect:</p>\n<ul>\n<li>\n<code>x.cpu()</code> will do nothing at all if your Tensor is already on the cpu and otherwise create a new Tensor on the cpu with the same content as <code>x</code>. Note that his op is differentiable and gradient will flow back towards <code>x</code>!</li>\n<li>\n<code>y = x.detach()</code> breaks the graph between <code>x</code> and <code>y</code>. But <code>y</code> will actually be a view into <code>x</code> and share memory with it.</li>\n</ul>",74 "post_number": 2,75 "post_type": 1,76 "posts_count": 2,77 "updated_at": "2020-10-20T15:35:52.992Z",78 "reply_count": 0,79 "reply_to_post_number": null,80 "quote_count": 0,81 "incoming_link_count": 93,82 "reads": 143,83 "readers_count": 142,84 "score": 523.6,85 "yours": false,86 "topic_id": 99991,87 "topic_slug": "detach-vs-cpu",88 "display_username": "Alban D",89 "primary_group_name": null,90 "flair_name": null,91 "flair_url": null,92 "flair_bg_color": null,93 "flair_color": null,94 "flair_group_id": null,95 "badges_granted": [],96 "version": 1,97 "can_edit": false,98 "can_delete": false,99 "can_recover": false,100 "can_see_hidden_post": false,101 "can_wiki": false,102 "read": true,103 "user_title": "",104 "bookmarked": false,105 "actions_summary": [106 {107 "id": 2,108 "count": 2109 }110 ],111 "moderator": true,112 "admin": true,113 "staff": true,114 "user_id": 211,115 "hidden": false,116 "trust_level": 4,117 "deleted_at": null,118 "user_deleted": false,119 "edit_reason": null,120 "can_view_edit_history": true,121 "wiki": false,122 "post_url": "/t/detach-vs-cpu/99991/2",123 "can_accept_answer": false,124 "can_unaccept_answer": false,125 "accepted_answer": false,126 "topic_accepted_answer": null127 }128 ],129 "stream": [130 237704,131 237811132 ]133 },134 "timeline_lookup": [135 [136 1,137 1832138 ],139 [140 2,141 1831142 ]143 ],144 "suggested_topics": [145 {146 "fancy_title": "How to Load Llama-3.3-70B-Instruct Model in Float8 Precision?",147 "id": 214102,148 "title": "How to Load Llama-3.3-70B-Instruct Model in Float8 Precision?",149 "slug": "how-to-load-llama-3-3-70b-instruct-model-in-float8-precision",150 "posts_count": 1,151 "reply_count": 0,152 "highest_post_number": 1,153 "image_url": null,154 "created_at": "2024-12-11T11:59:40.038Z",155 "last_posted_at": "2024-12-11T11:59:40.109Z",156 "bumped": true,157 "bumped_at": "2024-12-11T11:59:40.109Z",158 "archetype": "regular",159 "unseen": false,160 "pinned": false,161 "unpinned": null,162 "visible": true,163 "closed": false,164 "archived": false,165 "bookmarked": null,166 "liked": null,167 "tags_descriptions": {},168 "like_count": 0,169 "views": 160,170 "category_id": 1,171 "featured_link": null,172 "has_accepted_answer": false,173 "posters": [174 {175 "extras": "latest single",176 "description": "Original Poster, Most Recent Poster",177 "user": {178 "id": 78017,179 "username": "Arunima_Ghosh",180 "name": "Arunima Ghosh",181 "avatar_template": "/user_avatar/discuss.pytorch.org/arunima_ghosh/{size}/75750_2.png",182 "trust_level": 1183 }184 }185 ]186 },187 {188 "fancy_title": "GPU Usage graph oscillating",189 "id": 215979,190 "title": "GPU Usage graph oscillating",191 "slug": "gpu-usage-graph-oscillating",192 "posts_count": 3,193 "reply_count": 0,194 "highest_post_number": 3,195 "image_url": "https://discuss.pytorch.org/uploads/default/original/3X/3/4/344dde9d7ba72ce951344fb82a01197791afa133.png",196 "created_at": "2025-01-28T07:49:25.227Z",197 "last_posted_at": "2025-01-28T13:48:25.070Z",198 "bumped": true,199 "bumped_at": "2025-01-28T13:48:25.070Z",200 "archetype": "regular",201 "unseen": false,202 "pinned": false,203 "unpinned": null,204 "visible": true,205 "closed": false,206 "archived": false,207 "bookmarked": null,208 "liked": null,209 "tags_descriptions": {},210 "like_count": 0,211 "views": 146,212 "category_id": 1,213 "featured_link": null,214 "has_accepted_answer": false,215 "posters": [216 {217 "extras": "latest",218 "description": "Original Poster, Most Recent Poster",219 "user": {220 "id": 82364,221 "username": "Sourabh_Yadav",222 "name": "Sourabh Yadav",223 "avatar_template": "/user_avatar/discuss.pytorch.org/sourabh_yadav/{size}/75350_2.png",224 "trust_level": 1225 }226 },227 {228 "extras": null,229 "description": "Frequent Poster",230 "user": {231 "id": 3534,232 "username": "ptrblck",233 "name": "",234 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",235 "admin": true,236 "moderator": true,237 "trust_level": 2238 }239 }240 ]241 },242 {243 "fancy_title": "Finding issue for high memory bandwidth between CPU and GPU",244 "id": 217227,245 "title": "Finding issue for high memory bandwidth between CPU and GPU",246 "slug": "finding-issue-for-high-memory-bandwidth-between-cpu-and-gpu",247 "posts_count": 4,248 "reply_count": 2,249 "highest_post_number": 4,250 "image_url": null,251 "created_at": "2025-02-27T11:23:48.124Z",252 "last_posted_at": "2025-03-01T02:11:01.439Z",253 "bumped": true,254 "bumped_at": "2025-03-01T02:11:01.439Z",255 "archetype": "regular",256 "unseen": false,257 "pinned": false,258 "unpinned": null,259 "visible": true,260 "closed": false,261 "archived": false,262 "bookmarked": null,263 "liked": null,264 "tags_descriptions": {},265 "like_count": 0,266 "views": 101,267 "category_id": 1,268 "featured_link": null,269 "has_accepted_answer": true,270 "posters": [271 {272 "extras": null,273 "description": "Original Poster, Accepted Answer",274 "user": {275 "id": 77701,276 "username": "MLangner",277 "name": "",278 "avatar_template": "/letter_avatar_proxy/v4/letter/m/34f0e0/{size}.png",279 "trust_level": 1280 }281 },282 {283 "extras": "latest",284 "description": "Most Recent Poster",285 "user": {286 "id": 3534,287 "username": "ptrblck",288 "name": "",289 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",290 "admin": true,291 "moderator": true,292 "trust_level": 2293 }294 }295 ]296 },297 {298 "fancy_title": "Nvcc fatal: Could not set up the environment for Microsoft Visual Studio using vcvars64.bat during JIT compilation of bias_act.cu (CUDA 12.6, VS2022 BuildTools)",299 "id": 219086,300 "title": "Nvcc fatal: Could not set up the environment for Microsoft Visual Studio using vcvars64.bat during JIT compilation of bias_act.cu (CUDA 12.6, VS2022 BuildTools)",301 "slug": "nvcc-fatal-could-not-set-up-the-environment-for-microsoft-visual-studio-using-vcvars64-bat-during-jit-compilation-of-bias-act-cu-cuda-12-6-vs2022-buildtools",302 "posts_count": 1,303 "reply_count": 0,304 "highest_post_number": 1,305 "image_url": null,306 "created_at": "2025-04-15T00:17:43.040Z",307 "last_posted_at": "2025-04-15T00:17:43.082Z",308 "bumped": true,309 "bumped_at": "2025-04-15T00:17:43.082Z",310 "archetype": "regular",311 "unseen": false,312 "pinned": false,313 "unpinned": null,314 "visible": true,315 "closed": false,316 "archived": false,317 "bookmarked": null,318 "liked": null,319 "tags_descriptions": {},320 "like_count": 0,321 "views": 43,322 "category_id": 1,323 "featured_link": null,324 "has_accepted_answer": false,325 "posters": [326 {327 "extras": "latest single",328 "description": "Original Poster, Most Recent Poster",329 "user": {330 "id": 29433,331 "username": "cltexe",332 "name": "Omer Faruk Soylemez",333 "avatar_template": "/user_avatar/discuss.pytorch.org/cltexe/{size}/41817_2.png",334 "trust_level": 1335 }336 }337 ]338 },339 {340 "fancy_title": "Need Advice on Training a Model for Blind Navigation App (iOS)",341 "id": 219114,342 "title": "Need Advice on Training a Model for Blind Navigation App (iOS)",343 "slug": "need-advice-on-training-a-model-for-blind-navigation-app-ios",344 "posts_count": 1,345 "reply_count": 0,346 "highest_post_number": 1,347 "image_url": null,348 "created_at": "2025-04-15T15:58:34.977Z",349 "last_posted_at": "2025-04-15T15:58:35.023Z",350 "bumped": true,351 "bumped_at": "2025-04-15T15:58:35.023Z",352 "archetype": "regular",353 "unseen": false,354 "pinned": false,355 "unpinned": null,356 "visible": true,357 "closed": false,358 "archived": false,359 "bookmarked": null,360 "liked": null,361 "tags_descriptions": {},362 "like_count": 0,363 "views": 17,364 "category_id": 1,365 "featured_link": null,366 "has_accepted_answer": false,367 "posters": [368 {369 "extras": "latest single",370 "description": "Original Poster, Most Recent Poster",371 "user": {372 "id": 83831,373 "username": "albert2",374 "name": "homealone",375 "avatar_template": "/user_avatar/discuss.pytorch.org/albert2/{size}/76640_2.png",376 "trust_level": 0377 }378 }379 ]380 }381 ],382 "tags_descriptions": {},383 "fancy_title": ".detach() vs .cpu()?",384 "id": 99991,385 "title": ".detach() vs .cpu()?",386 "posts_count": 2,387 "created_at": "2020-10-20T09:25:36.491Z",388 "views": 9691,389 "reply_count": 0,390 "like_count": 3,391 "last_posted_at": "2020-10-20T15:35:52.992Z",392 "visible": true,393 "closed": false,394 "archived": false,395 "has_summary": false,396 "archetype": "regular",397 "slug": "detach-vs-cpu",398 "category_id": 1,399 "word_count": 119,400 "deleted_at": null,401 "user_id": 17988,402 "featured_link": null,403 "pinned_globally": false,404 "pinned_at": null,405 "pinned_until": null,406 "image_url": null,407 "slow_mode_seconds": 0,408 "draft": null,409 "draft_key": "topic_99991",410 "draft_sequence": null,411 "unpinned": null,412 "pinned": false,413 "current_post_number": 1,414 "highest_post_number": 2,415 "deleted_by": null,416 "actions_summary": [417 {418 "id": 4,419 "count": 0,420 "hidden": false,421 "can_act": false422 },423 {424 "id": 8,425 "count": 0,426 "hidden": false,427 "can_act": false428 },429 {430 "id": 10,431 "count": 0,432 "hidden": false,433 "can_act": false434 },435 {436 "id": 7,437 "count": 0,438 "hidden": false,439 "can_act": false440 }441 ],442 "chunk_size": 20,443 "bookmarked": false,444 "topic_timer": null,445 "message_bus_last_id": 0,446 "participant_count": 2,447 "show_read_indicator": false,448 "thumbnails": null,449 "slow_mode_enabled_until": null,450 "can_vote": false,451 "vote_count": 0,452 "user_voted": false,453 "discourse_zendesk_plugin_zendesk_id": null,454 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",455 "details": {456 "can_edit": false,457 "notification_level": 1,458 "participants": [459 {460 "id": 211,461 "username": "albanD",462 "name": "Alban D",463 "avatar_template": "/user_avatar/discuss.pytorch.org/alband/{size}/215_2.png",464 "post_count": 1,465 "primary_group_name": null,466 "flair_name": null,467 "flair_url": null,468 "flair_color": null,469 "flair_bg_color": null,470 "flair_group_id": null,471 "admin": true,472 "moderator": true,473 "trust_level": 4474 },475 {476 "id": 17988,477 "username": "antran96",478 "name": "antran96",479 "avatar_template": "/user_avatar/discuss.pytorch.org/antran96/{size}/11415_2.png",480 "post_count": 1,481 "primary_group_name": null,482 "flair_name": null,483 "flair_url": null,484 "flair_color": null,485 "flair_bg_color": null,486 "flair_group_id": null,487 "trust_level": 1488 }489 ],490 "created_by": {491 "id": 17988,492 "username": "antran96",493 "name": "antran96",494 "avatar_template": "/user_avatar/discuss.pytorch.org/antran96/{size}/11415_2.png"495 },496 "last_poster": {497 "id": 211,498 "username": "albanD",499 "name": "Alban D",500 "avatar_template": "/user_avatar/discuss.pytorch.org/alband/{size}/215_2.png"501 }502 },503 "bookmarks": []504 },505 {506 "post_stream": {507 "posts": [508 {509 "id": 237729,510 "name": "Joe Harrison",511 "username": "Joe_Harrison",512 "avatar_template": "/user_avatar/discuss.pytorch.org/joe_harrison/{size}/5534_2.png",513 "created_at": "2020-10-20T11:00:29.556Z",514 "cooked": "<pre><code class=\"lang-auto\">import torch\nimport torch.nn as nn\n\nclass CustomFunction(torch.autograd.Function, nn.Module):\n def __call__(self, input):\n return self.apply(input)\n\n @staticmethod\n def forward(ctx, forward_in):\n forward_out = forward_in.clamp(min=0)\n ctx.save_for_backward(forward_in, forward_out)\n return forward_out\n\n @staticmethod\n def backward(ctx, grad_output):\n forward_in, forward_out = ctx.saved_tensors\n\n relu_gradients = torch.ones_like(forward_out)\n relu_gradients[forward_in < 0] = 0\n relu_gradients = relu_gradients.mul(grad_output)\n # Some extra functions here\n return relu_gradients\n\n\nclass CustomModel(nn.Module):\n def __init__(self):\n super(CustomModel, self).__init__()\n self.cr = CustomFunction()\n\n def forward(self, x):\n x.requires_grad_(True)\n self.cr(x)\n criterion = x**2\n criterion.backward()\n return x.grad\n\nmodel = CustomModel()\ntraced_script_module = torch.jit.script(model)\ntraced_script_module.save(\"traced_jit_model.pt\")\njit_model = torch.jit.load('traced_jit_model.pt')\n\n</code></pre>\n<p>This is the minimal version of the code that causes the following error:</p>\n<pre><code class=\"lang-auto\">RuntimeError: You attempted to access the anomaly metadata of a custom autograd function but the underlying PyNode has already been deallocated. The most likely reason this occurred is because you assigned x.grad_fn to a local variable and then let the original variable get deallocated. Don't do that! If you really have no way of restructuring your code so this is the case, please file an issue reporting that you are affected by this.\n</code></pre>\n<p>Is there a way to reconstruct the code so that this error isn’t thrown? I don’t understand what the error means.</p>",515 "post_number": 1,516 "post_type": 1,517 "posts_count": 2,518 "updated_at": "2020-10-20T11:00:29.556Z",519 "reply_count": 0,520 "reply_to_post_number": null,521 "quote_count": 0,522 "incoming_link_count": 75,523 "reads": 14,524 "readers_count": 13,525 "score": 377.8,526 "yours": false,527 "topic_id": 99999,528 "topic_slug": "scripting-custom-autograd-function-runtimeerror-you-attempted-to-access-the-anomaly-metadata-of-a-custom-autograd-function",529 "display_username": "Joe Harrison",530 "primary_group_name": null,531 "flair_name": null,532 "flair_url": null,533 "flair_bg_color": null,534 "flair_color": null,535 "flair_group_id": null,536 "badges_granted": [],537 "version": 1,538 "can_edit": false,539 "can_delete": false,540 "can_recover": false,541 "can_see_hidden_post": false,542 "can_wiki": false,543 "read": true,544 "user_title": null,545 "bookmarked": false,546 "actions_summary": [],547 "moderator": false,548 "admin": false,549 "staff": false,550 "user_id": 9659,551 "hidden": false,552 "trust_level": 1,553 "deleted_at": null,554 "user_deleted": false,555 "edit_reason": null,556 "can_view_edit_history": true,557 "wiki": false,558 "post_url": "/t/scripting-custom-autograd-function-runtimeerror-you-attempted-to-access-the-anomaly-metadata-of-a-custom-autograd-function/99999/1",559 "can_accept_answer": false,560 "can_unaccept_answer": false,561 "accepted_answer": false,562 "topic_accepted_answer": null,563 "can_vote": false564 },565 {566 "id": 237805,567 "name": "Joe Harrison",568 "username": "Joe_Harrison",569 "avatar_template": "/user_avatar/discuss.pytorch.org/joe_harrison/{size}/5534_2.png",570 "created_at": "2020-10-20T15:08:13.465Z",571 "cooked": "<p>I solved this as follows:</p>\n<pre><code class=\"lang-auto\">#include <torch/script.h>\n#include <torch/all.h>\n\n#include <iostream>\n#include <memory>\n\n\nclass CustomReluOp : public torch::autograd::Function<CustomReluOp>{\n public:\n static torch::autograd::variable_list forward(torch::autograd::AutogradContext* ctx, torch::autograd::Variable forward_in){\n auto forward_out = torch::clamp(forward_in, 0.0);\n ctx->save_for_backward({forward_in, forward_out});\n return {forward_out};\n }\n\n static torch::autograd::variable_list backward(torch::autograd::AutogradContext* ctx, torch::autograd::variable_list grad_output){\n auto list_forward = ctx->get_saved_variables();\n auto forward_in = list_forward[0];\n auto forward_out = list_forward[1];\n\n auto relu_gradients = torch::ones_like(forward_out);\n auto indices = forward_in<0;\n relu_gradients.index({indices}) = 0;\n relu_gradients = torch::mul(relu_gradients, grad_output[0]);\n\n relu_gradients = torch::nn::functional::relu(relu_gradients);\n relu_gradients = relu_gradients * forward_out;\n return {relu_gradients};\n }\n};\n\ntorch::Tensor custom_relu_op(const torch::Tensor& input) {\n return CustomReluOp::apply(input)[0];\n}\n\nstatic auto registry = torch::RegisterOperators(\"my_ops::custom_relu_op\", &custom_relu_op);\n</code></pre>\n<p>The code above I saved as customrelu.cpp, I then made the file CMakeLists.txt with the following instructions:</p>\n<pre><code class=\"lang-auto\">cmake_minimum_required(VERSION 3.1 FATAL_ERROR)\nproject(custom_relu)\n\nfind_package(Torch REQUIRED)\n\n# Define our library target\nadd_library(custom_relu SHARED customrelu.cpp)\nset(CMAKE_CXX_STANDARD 14)\n# Link against LibTorch\ntarget_link_libraries(custom_relu \"${TORCH_LIBRARIES}\")\n</code></pre>\n<p>I then made an empty folder build and cd’d into it and ran the following:</p>\n<pre><code class=\"lang-auto\">cmake -DCMAKE_PREFIX_PATH=\"$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')\" ..\n\nmake -j\n</code></pre>\n<p>The following code now uses a custom operation that you can script:</p>\n<pre><code class=\"lang-auto\">import torch\nimport torch.nn as nn\n\ntorch.ops.load_library(\"inference/build/libcustom_relu.so\")\n\nclass CustomModel(nn.Module):\n def __init__(self):\n super(CustomModel, self).__init__()\n self.cr = torch.ops.my_ops.custom_relu_op\n\n def forward(self, x):\n x.requires_grad_(True)\n self.cr(x)\n criterion = x**2\n criterion.backward()\n return x.grad\n\nmodel = CustomModel()\ntraced_script_module = torch.jit.script(model)\ntraced_script_module.save(\"traced_jit_model.pt\")\njit_model = torch.jit.load('traced_jit_model.pt')\n</code></pre>\n<p>I added these instructions because the documentation for the c++ frontend is somewhat daunting for someone with little experience with c++ (like me). Credits to this post: <a href=\"https://discuss.pytorch.org/t/torchscript-register-backward-c-functions/60679/2\" class=\"inline-onebox\">TorchScript register backward C++ functions</a></p>",572 "post_number": 2,573 "post_type": 1,574 "posts_count": 2,575 "updated_at": "2020-10-20T15:09:35.229Z",576 "reply_count": 0,577 "reply_to_post_number": null,578 "quote_count": 0,579 "incoming_link_count": 5,580 "reads": 13,581 "readers_count": 12,582 "score": 27.6,583 "yours": false,584 "topic_id": 99999,585 "topic_slug": "scripting-custom-autograd-function-runtimeerror-you-attempted-to-access-the-anomaly-metadata-of-a-custom-autograd-function",586 "display_username": "Joe Harrison",587 "primary_group_name": null,588 "flair_name": null,589 "flair_url": null,590 "flair_bg_color": null,591 "flair_color": null,592 "flair_group_id": null,593 "badges_granted": [],594 "version": 2,595 "can_edit": false,596 "can_delete": false,597 "can_recover": false,598 "can_see_hidden_post": false,599 "can_wiki": false,600 "link_counts": [601 {602 "url": "https://discuss.pytorch.org/t/torchscript-register-backward-c-functions/60679/2",603 "internal": true,604 "reflection": false,605 "title": "TorchScript register backward C++ functions",606 "clicks": 4607 }608 ],609 "read": true,610 "user_title": null,611 "bookmarked": false,612 "actions_summary": [],613 "moderator": false,614 "admin": false,615 "staff": false,616 "user_id": 9659,617 "hidden": false,618 "trust_level": 1,619 "deleted_at": null,620 "user_deleted": false,621 "edit_reason": null,622 "can_view_edit_history": true,623 "wiki": false,624 "post_url": "/t/scripting-custom-autograd-function-runtimeerror-you-attempted-to-access-the-anomaly-metadata-of-a-custom-autograd-function/99999/2",625 "can_accept_answer": false,626 "can_unaccept_answer": false,627 "accepted_answer": false,628 "topic_accepted_answer": null629 }630 ],631 "stream": [632 237729,633 237805634 ]635 },636 "timeline_lookup": [637 [638 1,639 1831640 ]641 ],642 "suggested_topics": [643 {644 "fancy_title": "Why is torch.compile so fast?",645 "id": 215891,646 "title": "Why is torch.compile so fast?",647 "slug": "why-is-torch-compile-so-fast",648 "posts_count": 2,649 "reply_count": 0,650 "highest_post_number": 2,651 "image_url": null,652 "created_at": "2025-01-26T12:00:41.233Z",653 "last_posted_at": "2025-01-26T16:12:30.907Z",654 "bumped": true,655 "bumped_at": "2025-01-27T06:14:38.539Z",656 "archetype": "regular",657 "unseen": false,658 "pinned": false,659 "unpinned": null,660 "visible": true,661 "closed": false,662 "archived": false,663 "bookmarked": null,664 "liked": null,665 "tags_descriptions": {},666 "like_count": 0,667 "views": 268,668 "category_id": 13,669 "featured_link": null,670 "has_accepted_answer": false,671 "posters": [672 {673 "extras": null,674 "description": "Original Poster",675 "user": {676 "id": 79055,677 "username": "hello_e",678 "name": "hhhh",679 "avatar_template": "/letter_avatar_proxy/v4/letter/h/f9ae1b/{size}.png",680 "trust_level": 1681 }682 },683 {684 "extras": "latest",685 "description": "Most Recent Poster",686 "user": {687 "id": 3534,688 "username": "ptrblck",689 "name": "",690 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",691 "admin": true,692 "moderator": true,693 "trust_level": 2694 }695 }696 ]697 },698 {699 "fancy_title": "How to check grads in each step of model?",700 "id": 216615,701 "title": "How to check grads in each step of model?",702 "slug": "how-to-check-grads-in-each-step-of-model",703 "posts_count": 2,704 "reply_count": 0,705 "highest_post_number": 2,706 "image_url": null,707 "created_at": "2025-02-13T09:04:16.004Z",708 "last_posted_at": "2025-03-24T20:39:19.668Z",709 "bumped": true,710 "bumped_at": "2025-03-24T20:39:19.668Z",711 "archetype": "regular",712 "unseen": false,713 "pinned": false,714 "unpinned": null,715 "visible": true,716 "closed": false,717 "archived": false,718 "bookmarked": null,719 "liked": null,720 "tags_descriptions": {},721 "like_count": 0,722 "views": 53,723 "category_id": 13,724 "featured_link": null,725 "has_accepted_answer": false,726 "posters": [727 {728 "extras": null,729 "description": "Original Poster",730 "user": {731 "id": 73868,732 "username": "elinliu0823",733 "name": "轶霖 柳",734 "avatar_template": "/user_avatar/discuss.pytorch.org/elinliu0823/{size}/68215_2.png",735 "trust_level": 1736 }737 },738 {739 "extras": "latest",740 "description": "Most Recent Poster",741 "user": {742 "id": 60146,743 "username": "MyCenturaHealth",744 "name": "MyCenturaHealth",745 "avatar_template": "/user_avatar/discuss.pytorch.org/mycenturahealth/{size}/46345_2.png",746 "trust_level": 1747 }748 }749 ]750 },751 {752 "fancy_title": "TorchScript compiling the model to run on OpenWrt",753 "id": 214470,754 "title": "TorchScript compiling the model to run on OpenWrt",755 "slug": "torchscript-compiling-the-model-to-run-on-openwrt",756 "posts_count": 1,757 "reply_count": 0,758 "highest_post_number": 1,759 "image_url": null,760 "created_at": "2024-12-20T20:14:07.104Z",761 "last_posted_at": "2024-12-20T20:14:07.154Z",762 "bumped": true,763 "bumped_at": "2024-12-20T20:14:07.154Z",764 "archetype": "regular",765 "unseen": false,766 "pinned": false,767 "unpinned": null,768 "visible": true,769 "closed": false,770 "archived": false,771 "bookmarked": null,772 "liked": null,773 "tags_descriptions": {},774 "like_count": 0,775 "views": 132,776 "category_id": 13,777 "featured_link": null,778 "has_accepted_answer": false,779 "posters": [780 {781 "extras": "latest single",782 "description": "Original Poster, Most Recent Poster",783 "user": {784 "id": 81459,785 "username": "Rajesh_Singh",786 "name": "Rajesh Singh",787 "avatar_template": "/user_avatar/discuss.pytorch.org/rajesh_singh/{size}/73225_2.png",788 "trust_level": 1789 }790 }791 ]792 },793 {794 "fancy_title": "@jit.export methods disappear after jit.load(pth)",795 "id": 213329,796 "title": "@jit.export methods disappear after jit.load(pth)",797 "slug": "jit-export-methods-disappear-after-jit-load-pth",798 "posts_count": 1,799 "reply_count": 0,800 "highest_post_number": 1,801 "image_url": null,802 "created_at": "2024-11-22T22:16:44.495Z",803 "last_posted_at": "2024-11-22T22:16:44.584Z",804 "bumped": true,805 "bumped_at": "2024-11-22T22:16:44.584Z",806 "archetype": "regular",807 "unseen": false,808 "pinned": false,809 "unpinned": null,810 "visible": true,811 "closed": false,812 "archived": false,813 "bookmarked": null,814 "liked": null,815 "tags_descriptions": {},816 "like_count": 0,817 "views": 129,818 "category_id": 13,819 "featured_link": null,820 "has_accepted_answer": false,821 "posters": [822 {823 "extras": "latest single",824 "description": "Original Poster, Most Recent Poster",825 "user": {826 "id": 81077,827 "username": "T0BIAS",828 "name": "",829 "avatar_template": "/user_avatar/discuss.pytorch.org/t0bias/{size}/74141_2.png",830 "trust_level": 1831 }832 }833 ]834 },835 {836 "fancy_title": "‘Tensor.data_ptr()’ not visible from TorchScript",837 "id": 216655,838 "title": "'Tensor.data_ptr()' not visible from TorchScript",839 "slug": "tensor-data-ptr-not-visible-from-torchscript",840 "posts_count": 2,841 "reply_count": 0,842 "highest_post_number": 2,843 "image_url": null,844 "created_at": "2025-02-14T03:23:48.725Z",845 "last_posted_at": "2025-02-15T21:35:01.051Z",846 "bumped": true,847 "bumped_at": "2025-02-15T21:35:01.051Z",848 "archetype": "regular",849 "unseen": false,850 "pinned": false,851 "unpinned": null,852 "visible": true,853 "closed": false,854 "archived": false,855 "bookmarked": null,856 "liked": null,857 "tags_descriptions": {},858 "like_count": 0,859 "views": 103,860 "category_id": 13,861 "featured_link": null,862 "has_accepted_answer": true,863 "posters": [864 {865 "extras": "latest single",866 "description": "Original Poster, Most Recent Poster, Accepted Answer",867 "user": {868 "id": 17314,869 "username": "Avi_Chapman",870 "name": "Avi Chapman",871 "avatar_template": "/user_avatar/discuss.pytorch.org/avi_chapman/{size}/10688_2.png",872 "trust_level": 1873 }874 }875 ]876 }877 ],878 "tags_descriptions": {},879 "fancy_title": "Scripting custom autograd function. RuntimeError: You attempted to access the anomaly metadata of a custom autograd function",880 "id": 99999,881 "title": "Scripting custom autograd function. RuntimeError: You attempted to access the anomaly metadata of a custom autograd function",882 "posts_count": 2,883 "created_at": "2020-10-20T11:00:29.504Z",884 "views": 771,885 "reply_count": 0,886 "like_count": 0,887 "last_posted_at": "2020-10-20T15:08:13.465Z",888 "visible": true,889 "closed": false,890 "archived": false,891 "has_summary": false,892 "archetype": "regular",893 "slug": "scripting-custom-autograd-function-runtimeerror-you-attempted-to-access-the-anomaly-metadata-of-a-custom-autograd-function",894 "category_id": 13,895 "word_count": 544,896 "deleted_at": null,897 "user_id": 9659,898 "featured_link": null,899 "pinned_globally": false,900 "pinned_at": null,901 "pinned_until": null,902 "image_url": null,903 "slow_mode_seconds": 0,904 "draft": null,905 "draft_key": "topic_99999",906 "draft_sequence": null,907 "unpinned": null,908 "pinned": false,909 "current_post_number": 1,910 "highest_post_number": 2,911 "deleted_by": null,912 "actions_summary": [913 {914 "id": 4,915 "count": 0,916 "hidden": false,917 "can_act": false918 },919 {920 "id": 8,921 "count": 0,922 "hidden": false,923 "can_act": false924 },925 {926 "id": 10,927 "count": 0,928 "hidden": false,929 "can_act": false930 },931 {932 "id": 7,933 "count": 0,934 "hidden": false,935 "can_act": false936 }937 ],938 "chunk_size": 20,939 "bookmarked": false,940 "topic_timer": null,941 "message_bus_last_id": 0,942 "participant_count": 1,943 "show_read_indicator": false,944 "thumbnails": null,945 "slow_mode_enabled_until": null,946 "can_vote": false,947 "vote_count": 0,948 "user_voted": false,949 "discourse_zendesk_plugin_zendesk_id": null,950 "discourse_zendesk_plugin_zendesk_url": "https://your-url.zendesk.com/agent/tickets/",951 "details": {952 "can_edit": false,953 "notification_level": 1,954 "participants": [955 {956 "id": 9659,957 "username": "Joe_Harrison",958 "name": "Joe Harrison",959 "avatar_template": "/user_avatar/discuss.pytorch.org/joe_harrison/{size}/5534_2.png",960 "post_count": 2,961 "primary_group_name": null,962 "flair_name": null,963 "flair_url": null,964 "flair_color": null,965 "flair_bg_color": null,966 "flair_group_id": null,967 "trust_level": 1968 }969 ],970 "created_by": {971 "id": 9659,972 "username": "Joe_Harrison",973 "name": "Joe Harrison",974 "avatar_template": "/user_avatar/discuss.pytorch.org/joe_harrison/{size}/5534_2.png"975 },976 "last_poster": {977 "id": 9659,978 "username": "Joe_Harrison",979 "name": "Joe Harrison",980 "avatar_template": "/user_avatar/discuss.pytorch.org/joe_harrison/{size}/5534_2.png"981 },982 "links": [983 {984 "url": "https://discuss.pytorch.org/t/torchscript-register-backward-c-functions/60679/2",985 "title": "TorchScript register backward C++ functions",986 "internal": true,987 "attachment": false,988 "reflection": false,989 "clicks": 4,990 "user_id": 9659,991 "domain": "discuss.pytorch.org",992 "root_domain": "pytorch.org"993 }994 ]995 },996 "bookmarks": []997 },998 {999 "post_stream": {1000 "posts": [1001 {1002 "id": 234209,1003 "name": "Steven",1004 "username": "Chen0729",1005 "avatar_template": "/user_avatar/discuss.pytorch.org/chen0729/{size}/15587_2.png",1006 "created_at": "2020-10-06T18:12:27.548Z",1007 "cooked": "<p>Hi, All,</p>\n<p>I would like to convert the following from pytorch to libtorch. The pytorch code is<br>\nacc = torch.mean((output_label.max(1)[1] == y).float())</p>\n<p>I convert it as:<br>\nfloat acc = torch::mean((output_label.max(1)[1] == y));</p>\n<p>The building error is:<br>\nerror: no match for ‘operator[]’ (operand types are ‘std::tuple<at::Tensor, at::Tensor>’ and ‘int’)</p>\n<p>Any suggestions to correct it please ?</p>\n<p>Much appreciated</p>",1008 "post_number": 1,1009 "post_type": 1,1010 "posts_count": 10,1011 "updated_at": "2020-10-06T18:12:27.548Z",1012 "reply_count": 0,1013 "reply_to_post_number": null,1014 "quote_count": 0,1015 "incoming_link_count": 533,1016 "reads": 31,1017 "readers_count": 30,1018 "score": 2666.2,1019 "yours": false,1020 "topic_id": 98471,1021 "topic_slug": "help-on-indexing-a-tuple-in-libtorch-please",1022 "display_username": "Steven",1023 "primary_group_name": null,1024 "flair_name": null,1025 "flair_url": null,1026 "flair_bg_color": null,1027 "flair_color": null,1028 "flair_group_id": null,1029 "badges_granted": [],1030 "version": 1,1031 "can_edit": false,1032 "can_delete": false,1033 "can_recover": false,1034 "can_see_hidden_post": false,1035 "can_wiki": false,1036 "read": true,1037 "user_title": "",1038 "bookmarked": false,1039 "actions_summary": [],1040 "moderator": false,1041 "admin": false,1042 "staff": false,1043 "user_id": 36581,1044 "hidden": false,1045 "trust_level": 1,1046 "deleted_at": null,1047 "user_deleted": false,1048 "edit_reason": null,1049 "can_view_edit_history": true,1050 "wiki": false,1051 "post_url": "/t/help-on-indexing-a-tuple-in-libtorch-please/98471/1",1052 "can_accept_answer": false,1053 "can_unaccept_answer": false,1054 "accepted_answer": false,1055 "topic_accepted_answer": null,1056 "can_vote": false1057 },1058 {1059 "id": 234774,1060 "name": "",1061 "username": "ptrblck",1062 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1063 "created_at": "2020-10-08T23:53:39.668Z",1064 "cooked": "<p>Try to use <code>std::get<1>(output_label.max(1))</code>.</p>",1065 "post_number": 2,1066 "post_type": 1,1067 "posts_count": 10,1068 "updated_at": "2020-10-08T23:53:39.668Z",1069 "reply_count": 0,1070 "reply_to_post_number": null,1071 "quote_count": 0,1072 "incoming_link_count": 2,1073 "reads": 32,1074 "readers_count": 31,1075 "score": 16.4,1076 "yours": false,1077 "topic_id": 98471,1078 "topic_slug": "help-on-indexing-a-tuple-in-libtorch-please",1079 "display_username": "",1080 "primary_group_name": null,1081 "flair_name": null,1082 "flair_url": null,1083 "flair_bg_color": null,1084 "flair_color": null,1085 "flair_group_id": null,1086 "badges_granted": [],1087 "version": 1,1088 "can_edit": false,1089 "can_delete": false,1090 "can_recover": false,1091 "can_see_hidden_post": false,1092 "can_wiki": false,1093 "read": true,1094 "user_title": "",1095 "bookmarked": false,1096 "actions_summary": [],1097 "moderator": true,1098 "admin": true,1099 "staff": true,1100 "user_id": 3534,1101 "hidden": false,1102 "trust_level": 2,1103 "deleted_at": null,1104 "user_deleted": false,1105 "edit_reason": null,1106 "can_view_edit_history": true,1107 "wiki": false,1108 "post_url": "/t/help-on-indexing-a-tuple-in-libtorch-please/98471/2",1109 "can_accept_answer": false,1110 "can_unaccept_answer": false,1111 "accepted_answer": false,1112 "topic_accepted_answer": null1113 },1114 {1115 "id": 234961,1116 "name": "Steven",1117 "username": "Chen0729",1118 "avatar_template": "/user_avatar/discuss.pytorch.org/chen0729/{size}/15587_2.png",1119 "created_at": "2020-10-09T13:41:07.911Z",1120 "cooked": "<p>Thanks a lot.<br>\nauto acc = torch::mean(get<1>(output_label.max(1))== y); works</p>\n<p>But<br>\nfloat acc = torch::mean(get<1>(output_label.max(1))== y); doesnot work</p>\n<p>How shall I convert acc from tensor to float in this case please ?</p>\n<p>Thanks.</p>",1121 "post_number": 3,1122 "post_type": 1,1123 "posts_count": 10,1124 "updated_at": "2020-10-09T13:41:07.911Z",1125 "reply_count": 1,1126 "reply_to_post_number": null,1127 "quote_count": 0,1128 "incoming_link_count": 0,1129 "reads": 30,1130 "readers_count": 29,1131 "score": 11.0,1132 "yours": false,1133 "topic_id": 98471,1134 "topic_slug": "help-on-indexing-a-tuple-in-libtorch-please",1135 "display_username": "Steven",1136 "primary_group_name": null,1137 "flair_name": null,1138 "flair_url": null,1139 "flair_bg_color": null,1140 "flair_color": null,1141 "flair_group_id": null,1142 "badges_granted": [],1143 "version": 1,1144 "can_edit": false,1145 "can_delete": false,1146 "can_recover": false,1147 "can_see_hidden_post": false,1148 "can_wiki": false,1149 "read": true,1150 "user_title": "",1151 "bookmarked": false,1152 "actions_summary": [],1153 "moderator": false,1154 "admin": false,1155 "staff": false,1156 "user_id": 36581,1157 "hidden": false,1158 "trust_level": 1,1159 "deleted_at": null,1160 "user_deleted": false,1161 "edit_reason": null,1162 "can_view_edit_history": true,1163 "wiki": false,1164 "post_url": "/t/help-on-indexing-a-tuple-in-libtorch-please/98471/3",1165 "can_accept_answer": false,1166 "can_unaccept_answer": false,1167 "accepted_answer": false,1168 "topic_accepted_answer": null1169 },1170 {1171 "id": 235253,1172 "name": "",1173 "username": "ptrblck",1174 "avatar_template": "/user_avatar/discuss.pytorch.org/ptrblck/{size}/1823_2.png",1175 "created_at": "2020-10-11T04:51:02.209Z",1176 "cooked": "<p>I guess <code>.item<float>()</code> should work.</p>",1177 "post_number": 4,1178 "post_type": 1,1179 "posts_count": 10,1180 "updated_at": "2020-10-11T04:51:02.209Z",1181 "reply_count": 0,1182 "reply_to_post_number": 3,1183 "quote_count": 0,1184 "incoming_link_count": 0,1185 "reads": 29,1186 "readers_count": 28,1187 "score": 5.8,1188 "yours": false,1189 "topic_id": 98471,1190 "topic_slug": "help-on-indexing-a-tuple-in-libtorch-please",1191 "display_username": "",1192 "primary_group_name": null,1193 "flair_name": null,1194 "flair_url": null,1195 "flair_bg_color": null,1196 "flair_color": null,1197 "flair_group_id": null,1198 "badges_granted": [],1199 "version": 1,1200 "can_edit": false,