jcjohnson / neural-style

Torch implementation of neural style algorithm
MIT License
18.3k stars 2.71k forks source link

Out of memory & undefined symbol: THFloatVector_add #445

Open kaikun213 opened 6 years ago

kaikun213 commented 6 years ago

The setup went all fine, then I configured CUDA and installed the torch bindings (cutorch, cnn & cudnn) but it runs out of memory when trying to run it in GPU mode. Tried all suggestions to reduce the required memory but even for an image size of 16 it wont work. I got a Geforce 940M which should have 2GB of DDR3. Is there another way to make it run? Or could it be flawed somehow (it should work for resized 16 images..)

cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-1928/cutorch/lib/THC/generic/THCStorage.cu:66 stack traceback: [C]: in function 'resize' ...

Additionally if I try to switch back to non-GPU mode it does not run anymore now. (with gpu -1 flag) It complains about: undefined symbol: THFloatVector_add I believe it must still use some cutorch operations from the bindings?

htoyryla commented 6 years ago

2 GB is too little when using a VGG model. Note also that part of your GPU memory may be in use by other processes. Decreasing image size beyond a certain size does not help, there seems to be a memory peak at the beginning anyway.

Get a decent GPU or try using NIN-Imagenet-Conv.

When using -gpu -1 make sure you don't have -backend cudnn.

kaikun213 commented 6 years ago

Thank you for the answer. Unfortunately the undefined symbol: THFloatVector_add still appears with -gpu -1 and no -backend cudnn. (Running: th neural_style.lua -style_image examples/my_inputs/style.jpg -content_image examples/my_inputs/content.jpg -gpu -1) Even after removing the cutorch with luarocks.

htoyryla commented 6 years ago

Torch may sometimes get garbled... mismatch between different luarocks. Just reinstall torch,

luarocks install torch
luarocks install nn

should be enough if I remember correctly. I think I must have done luarocks install torch, nn, cutorch, cunn, cudnn dozens of times in two and half years.