{"action":"created","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/10303","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/10303/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/10303/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/10303/events","html_url":"https://github.com/pytorch/pytorch/issues/10303","id":348359199,"node_id":"MDU6SXNzdWUzNDgzNTkxOTk=","number":10303,"title":"cuda runtime error(59): device-side assert when running torch.topk","user":{"login":"Ai-is-light","id":11785119,"node_id":"MDQ6VXNlcjExNzg1MTE5","avatar_url":"https://avatars2.githubusercontent.com/u/11785119?v=4","gravatar_id":"","url":"https://api.github.com/users/Ai-is-light","html_url":"https://github.com/Ai-is-light","followers_url":"https://api.github.com/users/Ai-is-light/followers","following_url":"https://api.github.com/users/Ai-is-light/following{/other_user}","gists_url":"https://api.github.com/users/Ai-is-light/gists{/gist_id}","starred_url":"https://api.github.com/users/Ai-is-light/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ai-is-light/subscriptions","organizations_url":"https://api.github.com/users/Ai-is-light/orgs","repos_url":"https://api.github.com/users/Ai-is-light/repos","events_url":"https://api.github.com/users/Ai-is-light/events{/privacy}","received_events_url":"https://api.github.com/users/Ai-is-light/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-08-07T14:56:34Z","updated_at":"2018-11-12T12:41:19Z","closed_at":"2018-08-14T04:51:27Z","author_association":"NONE","body":"The code and dataset were the same as before, but I got the following error. However they could work well about a half mouth ago.\r\nthe pytorch's version is 0.3.1, BUT I find the version 0.4.0 also meeting with the same error\r\nraceback (most recent call last):\r\nFile \"main.py\", line 341, in\r\nmain()\r\nFile \"main.py\", line 141, in main\r\ntrain(train_loader, model, criterion, optimizer, epoch)\r\nFile \"main.py\", line 192, in train\r\nprec1, prec5 = accuracy(output.data, target, topk=(1,5))\r\nFile \"main.py\", line 329, in accuracy\r\n_, pred = output.topk(maxk, 1, True, True)\r\nRuntimeError: invalid argument 5: k not in range for dimension at /pytorch/torch/lib/THC/generic/THCTensorTopK.cu:21\r\n/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [0,0,0] Assertion t >= 0 && t < n_classes failed.\r\n/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [1,0,0] Assertion t >= 0 && t < n_classes failed.\r\n/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [2,0,0] Assertion t >= 0 && t < n_classes failed.\r\n/pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:101: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype *, Dtype *, Dtype *, long *, Dtype *, int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [3,0,0] Assertion t >= 0 && t < n_classes failed.\r\nTHCudaCheck FAIL file=/pytorch/torch/lib/THC/generic/THCStorage.c line=184 error=59 : device-side assert triggered\r\nterminate called after throwing an instance of 'std::runtime_error'\r\nwhat(): cuda runtime error (59) : device-side assert triggered at /pytorch/torch/lib/THC/generic/THCStorage.c:184\r\nAborted (core dumped)"},"comment":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/comments/437865235","html_url":"https://github.com/pytorch/pytorch/issues/10303#issuecomment-437865235","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/10303","id":437865235,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzg2NTIzNQ==","user":{"login":"KasperJuunge","id":39537120,"node_id":"MDQ6VXNlcjM5NTM3MTIw","avatar_url":"https://avatars2.githubusercontent.com/u/39537120?v=4","gravatar_id":"","url":"https://api.github.com/users/KasperJuunge","html_url":"https://github.com/KasperJuunge","followers_url":"https://api.github.com/users/KasperJuunge/followers","following_url":"https://api.github.com/users/KasperJuunge/following{/other_user}","gists_url":"https://api.github.com/users/KasperJuunge/gists{/gist_id}","starred_url":"https://api.github.com/users/KasperJuunge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KasperJuunge/subscriptions","organizations_url":"https://api.github.com/users/KasperJuunge/orgs","repos_url":"https://api.github.com/users/KasperJuunge/repos","events_url":"https://api.github.com/users/KasperJuunge/events{/privacy}","received_events_url":"https://api.github.com/users/KasperJuunge/received_events","type":"User","site_admin":false},"created_at":"2018-11-12T12:41:19Z","updated_at":"2018-11-12T12:41:19Z","author_association":"NONE","body":"I kind of had the same problem. I was trying to modify the transfer learning tutorial (https://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html) with the hymenoptera dataset (bees and ants dataset) to make it fit to my project. The problem was that i had 3 classes and the tutorial has 2.  So i found that you have to define the number of outputs from the fully connected network (the output layer). So the only thing i had to do was changing \"model_ft.fc = nn.Linear(num_ftrs, 2)\" to \"model_ft.fc = nn.Linear(num_ftrs, 3)\". Hope it helps somebody :)"}}
{"actor":{"display_login":"KasperJuunge"}}