Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete PyTorch objects correctly from memory within Python? #19

Open
cjmcmurtrie opened this issue Oct 5, 2016 · 1 comment
Open

Comments

@cjmcmurtrie
Copy link

I'm having an issue with properly deleting PyTorch objects from memory. With this dummy class:

require 'nn'
require 'cunn'
require 'cutorch'

local Test = torch.class('Test')

function Test:__init()
    self.tensor = torch.CudaTensor(10000, 10000)
end

If I instantiate from Python:

>>> from PyTorchHelpers import load_lua_class
>>> Test = load_lua_class('modules/test.lua', 'Test')
>>> test = Test()

Then delete the object:

>>> del test

CUDA memory is not freed up.

Is there a clean way to delete a PyTorch object from memory?

@cjmcmurtrie cjmcmurtrie changed the title How to remove PyTorch objects correctly from within Python? How to remove PyTorch objects correctly from memory within Python? Oct 5, 2016
@cjmcmurtrie cjmcmurtrie changed the title How to remove PyTorch objects correctly from memory within Python? How to delete PyTorch objects correctly from memory within Python? Oct 5, 2016
@hughperkins
Copy link
Owner

Ah, yes, this is probably connected to #10 (comment) It's kind of non-trivial to fix, but probably should be fixed... Probably need some kind of gc command perhaps. If memory was freed iff one called a new hypothetical PyTorch.gc() command, to what extent could that be acceptable-ish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants