jcjohnson / neural-style

Torch implementation of neural style algorithm
MIT License
18.31k stars 2.7k forks source link

Out of memory using GPU #81

Open 3DTOPO opened 8 years ago

3DTOPO commented 8 years ago

I am able to load the neural style without the GPU with this command: th neural_style.lua -gpu -1 -print_iter 1

But if I attempt to use cuda (followed instructions and installed fine) with: th neural_style.lua -gpu 0 -print_iter 1

I get the following out of memory error. I am assume I am running out of GPU memory and not system memory, but it would be helpful if someone could confirm that is the case.

/Users/jeshua/torch/install/bin/luajit: /Users/jeshua/torch/install/share/lua/5.1/nn/utils.lua:11: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-6682/cutorch/lib/THC/THCStorage.cu:44 stack traceback: [C]: in function 'resize' /Users/jeshua/torch/install/share/lua/5.1/nn/utils.lua:11: in function 'torch_Storage_type' /Users/jeshua/torch/install/share/lua/5.1/nn/utils.lua:57: in function 'recursiveType' /Users/jeshua/torch/install/share/lua/5.1/nn/Module.lua:123: in function 'type' /Users/jeshua/torch/install/share/lua/5.1/nn/utils.lua:45: in function 'recursiveType' /Users/jeshua/torch/install/share/lua/5.1/nn/utils.lua:41: in function 'recursiveType' /Users/jeshua/torch/install/share/lua/5.1/nn/Module.lua:123: in function 'cuda' neural_style.lua:67: in function 'main' neural_style.lua:454: in main chunk [C]: in function 'dofile' ...shua/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk [C]: at 0x01043c8bd0

jcjohnson commented 8 years ago

How much memory does your GPU have? That does look like you are running out of GPU memory.

3DTOPO commented 8 years ago

Thanks for confirming that. Yeah - just 2GB. Time to order a Titan! ;)

That said, is there anyway to calculate how much VRAM it is going to require on a GPU for a given image size? Even some kind of an ballpark estimate would be helpful.

3DTOPO commented 8 years ago

It would be awesome if you could briefly explain the texture stack loaded on the GPU (I assume that would be the bulk of VRAM allocated) or provide any insight. Thanks!

maraoz commented 8 years ago

@3DTOPO were you able to solve it without upgrading hardware? I've got the same problem :)