{"action":"created","issue":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/1346","repository_url":"https://api.github.com/repos/pytorch/pytorch","labels_url":"https://api.github.com/repos/pytorch/pytorch/issues/1346/labels{/name}","comments_url":"https://api.github.com/repos/pytorch/pytorch/issues/1346/comments","events_url":"https://api.github.com/repos/pytorch/pytorch/issues/1346/events","html_url":"https://github.com/pytorch/pytorch/issues/1346","id":223935757,"number":1346,"title":"autograd branch: Memory leak","user":{"login":"ankitkv","id":3175634,"avatar_url":"https://avatars2.githubusercontent.com/u/3175634?v=3","gravatar_id":"","url":"https://api.github.com/users/ankitkv","html_url":"https://github.com/ankitkv","followers_url":"https://api.github.com/users/ankitkv/followers","following_url":"https://api.github.com/users/ankitkv/following{/other_user}","gists_url":"https://api.github.com/users/ankitkv/gists{/gist_id}","starred_url":"https://api.github.com/users/ankitkv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ankitkv/subscriptions","organizations_url":"https://api.github.com/users/ankitkv/orgs","repos_url":"https://api.github.com/users/ankitkv/repos","events_url":"https://api.github.com/users/ankitkv/events{/privacy}","received_events_url":"https://api.github.com/users/ankitkv/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"apaszke","id":4583066,"avatar_url":"https://avatars0.githubusercontent.com/u/4583066?v=3","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false},"assignees":[{"login":"apaszke","id":4583066,"avatar_url":"https://avatars0.githubusercontent.com/u/4583066?v=3","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2017-04-24T20:07:22Z","updated_at":"2017-04-28T09:08:08Z","closed_at":null,"body":"The following code (based on test suit code) leaks memory in the autograd branch:\r\n```\r\nfrom __future__ import print_function\r\n\r\nimport torch\r\nfrom torch.autograd import Variable\r\nimport torch.nn as nn\r\n\r\n\r\ni = 0\r\nwhile True:\r\n    if i % 1000 == 0:\r\n        print(i)\r\n    i += 1\r\n    x = Variable(torch.randn(2, 2).cuda(), requires_grad=True)\r\n    y = Variable(torch.randn(2, 2).cuda(), requires_grad=True)\r\n\r\n    z = x ** 2 + y * x + y ** 2\r\n    z.backward(Variable(torch.ones(2, 2).cuda(), requires_grad=True), retain_variables=True)\r\n\r\n    x_grad = 2 * x.data + y.data\r\n    y_grad = x.data + 2 * y.data\r\n\r\n    grad_sum = 2 * x.grad + y.grad\r\n    grad_sum = grad_sum[:, :-1]\r\n    grad_sum.backward(torch.ones(2, 1).cuda())  # leaks memory\r\n```"},"comment":{"url":"https://api.github.com/repos/pytorch/pytorch/issues/comments/297948324","html_url":"https://github.com/pytorch/pytorch/issues/1346#issuecomment-297948324","issue_url":"https://api.github.com/repos/pytorch/pytorch/issues/1346","id":297948324,"user":{"login":"apaszke","id":4583066,"avatar_url":"https://avatars0.githubusercontent.com/u/4583066?v=3","gravatar_id":"","url":"https://api.github.com/users/apaszke","html_url":"https://github.com/apaszke","followers_url":"https://api.github.com/users/apaszke/followers","following_url":"https://api.github.com/users/apaszke/following{/other_user}","gists_url":"https://api.github.com/users/apaszke/gists{/gist_id}","starred_url":"https://api.github.com/users/apaszke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apaszke/subscriptions","organizations_url":"https://api.github.com/users/apaszke/orgs","repos_url":"https://api.github.com/users/apaszke/repos","events_url":"https://api.github.com/users/apaszke/events{/privacy}","received_events_url":"https://api.github.com/users/apaszke/received_events","type":"User","site_admin":false},"created_at":"2017-04-28T09:08:08Z","updated_at":"2017-04-28T09:08:08Z","body":"It doesn't, but the references are overwritten so they should be freed anyway. I realized it's because of a reference cycle in autograd's C data structures. It's already fixed and I'll push it today"}}
{"actor":{"display_login":"apaszke"}}