kaishengtai / neuralart

An implementation of the paper 'A Neural Algorithm of Artistic Style'.
MIT License
2.41k stars 353 forks source link

Out of Memory #1

Closed pents90 closed 9 years ago

pents90 commented 9 years ago

Hi, I'm trying to run your software against images the same size as your example images, but I'm getting:

qlua: ...de/torch/install/share/lua/5.1/nn/SpatialConvolution.lua:110: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-664/cutorch/lib/THC/THCStorage.cu:44

Any ideas how to resolve? Thanks!

pents90 commented 9 years ago

(Note: running on OS X Mavericks using a modern Macbook Pro)

kaishengtai commented 9 years ago

Are you running off an old Torch installation? If so, reinstalling torch/cutorch/cunn should help:

luarocks install torch
luarocks install cutorch
luarocks install cunn
pents90 commented 9 years ago

Just reinstalled using those commands, and got the same error! I'm down to images of size less than 300x300 each, still running out of memory.

pents90 commented 9 years ago

I see that my computer has an GT 650M (1 GB), while yours is the 750M (2 GB), so that could be why I'm running out. Thanks for your prompt reply!

dribnet commented 9 years ago

Memo to others - for me this is also triggered by using a content image with nearly square aspect ratio. The error generated (on b699593d) is:

iter    10      loss 1.40e+08   lr 1.00e-01     time  1.8
qlua: cuda runtime error (2) : out of memory at /tmp/luarocks_cutorch-scm-1-8358/cutorch/lib/THC/THCStorage.cu:30
stack traceback:
        [C]: at 0x010af261d0
        [C]: at 0x16084be0
        [C]: in function 'mm'
        main.lua:48: in function 'gram'
        main.lua:76: in function 'style_grad'
        main.lua:174: in function 'opfunc'
        /Users/tom/torch/install/share/lua/5.1/optim/sgd.lua:43: in function 'sgd'
        main.lua:219: in main chunk

I'm sure it's the aspect ratio - for example for me a 300x294 content image will fail while a 1200x1000 will succeed. Looking at the code flow this kind of makes sense - even small images are scaled up to the standard size - which if square on my hardware is slightly too large.

This puzzled me for awhile, but there is now is a simple fix on the latest codebase: simply add a size argument at some number slightly smaller that 500 - eg: --size 460. @pents90 - this would also help you since you can similarly dial this number down to reduce the memory footprint.

pents90 commented 9 years ago

@dribnet Thanks, I was able to use the --size parameter to get it working!

xiahaoyun commented 7 years ago

I use the -image_size ,it works