{"action":"opened","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/6481","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/6481/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/6481/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/6481/events","html_url":"https://github.com/pytorch/pytorch/issues/6481","id":313074525,"number":6481,"title":"TypeError when using SparseAdam + GPU","user":{"login":"zhu-y11","id":6934830,"avatar_url":"https://avatars0.githubusercontent.com/u/6934830?v=4","gravatar_id":"","url":"https://api.github.com/users/zhu-y11","html_url":"https://github.com/zhu-y11","followers_url":"https://api.github.com/users/zhu-y11/followers","following_url":"https://api.github.com/users/zhu-y11/following{/other_user}","gists_url":"https://api.github.com/users/zhu-y11/gists{/gist_id}","starred_url":"https://api.github.com/users/zhu-y11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhu-y11/subscriptions","organizations_url":"https://api.github.com/users/zhu-y11/orgs","repos_url":"https://api.github.com/users/zhu-y11/repos","events_url":"https://api.github.com/users/zhu-y11/events{/privacy}","received_events_url":"https://api.github.com/users/zhu-y11/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-10T20:19:42Z","updated_at":"2018-04-10T20:19:42Z","closed_at":null,"author_association":"NONE","body":"- PyTorch 0.3.1\r\n- OS: ubuntu 16.04\r\n- How you installed PyTorch (conda, pip, source): pip\r\n- Python version: 3.6.4\r\n- CUDA/cuDNN version: 9.0\r\n\r\nWhen I try to run my [script](https://github.com/zhu-y11/my_wordembs/blob/master/word2vec/pytorch/word2vec.py) (you can clone the repo and directly run the script), using SparseAdam (see in line82) with GPU:\r\n`python3 word2vec.py --train ../../data/de.sent.1e4 --cuda`\r\n\r\nI got the error:\r\n\r\n> File \"word2vec.py\", line 158, in <module>\r\n    train(w2v)\r\n  File \"word2vec.py\", line 96, in train\r\n    total_loss += train_batch(w2v, optimizer, pairs[:w2v.bs], w2v.bs, neg_idxs)\r\n  File \"word2vec.py\", line 151, in train_batch\r\n    optimizer.step()\r\n  File \"/home/yz568/python3/lib/python3.6/site-packages/torch/optim/sparse_adam.py\", line 93, in step\r\n    p.data.add_(make_sparse(-step_size * numer.div_(denom)))\r\n  File \"/home/yz568/python3/lib/python3.6/site-packages/torch/optim/sparse_adam.py\", line 69, in make_sparse\r\n    return constructor(grad_indices, values, size)\r\nTypeError: torch.cuda.sparse.FloatTensor constructor received an invalid combination of arguments - got (torch.cuda.LongTensor, torch.FloatTensor, torch.Size), but expected one of:\r\n no arguments\r\n (int size)\r\n (torch.Size sizes)\r\n (torch.cuda.LongTensor indices, torch.cuda.FloatTensor values)\r\n (torch.cuda.LongTensor indices, torch.cuda.FloatTensor values, torch.Size sizes)\r\n      didn't match because some of the arguments have invalid types: (torch.cuda.LongTensor, torch.FloatTensor, torch.Size)\r\n (int ...)\r\n      didn't match because some of the arguments have invalid types: (torch.cuda.LongTensor, torch.FloatTensor, torch.Size)\r\n\r\nBut it works well when running with\r\n1. SpaseAdam + CPU\r\n2. SGD + CPU\r\n3. SGD + GPU\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"zhu-y11"}}