ryankiros / neural-storyteller

A recurrent neural network for generating little stories about images
2.96k stars 539 forks source link

Can neural-storyteller work without a GPU? #1

Open ezcn opened 9 years ago

ezcn commented 9 years ago

After installation:

In [1]: import generate
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-e2356e8a9459> in <module>()
----> 1 import generate

/home/enza/erikhasblueeyes/neural-storyteller/generate.py in <module>()
     14 import lasagne
     15 from lasagne.layers import InputLayer, DenseLayer, NonlinearityLayer, DropoutLayer
---> 16 from lasagne.layers.corrmm import Conv2DMMLayer as ConvLayer
     17 from lasagne.layers import MaxPool2DLayer as PoolLayer
     18 from lasagne.nonlinearities import softmax

/home/enza/.local/lib/python2.7/site-packages/lasagne/layers/corrmm.py in <module>()
     20 
     21 if not theano.config.device.startswith("gpu"):
---> 22     raise ImportError("requires a GPU to work")  # pragma: no cover
     23 
     24 

ImportError: requires a GPU to work

Is it possible to use this without a GPU?

ryankiros commented 9 years ago

As is, probably not :(

One thing you can do is replace line 16 of generate.py with: from lasagne.layers import Conv2DLayer as ConvLayer

This should allow you to import and run the code. The problem with this though is it does not handle padding of the VGG-19 convolutional layers correctly, so it will output different (perhaps slightly worse) results. At least this will run, albeit very slowly.

If anyone has an alternative CPU solution which produces the correct output, I would love to know!

Ryan

ezcn commented 9 years ago

Thanks Ryan, I will try. Perhaps it would be helpful to specify this in the read.me :)

Enza

jlumpe commented 9 years ago

Ryan,

Lasagne's documentation for layers.Conv2DLayer says:

Theano’s underlying convolution (theano.tensor.nnet.conv.conv2d()) only supports pad=0 and pad='full'. This layer emulates other modes by cropping a full convolution or explicitly padding the input with zeros.

while the note for layers.corrmm.Conv2DMMLayer reads:

Unlike lasagne.layers.Conv2DLayer, this layer properly supports pad='same'. It is not emulated. This should result in better performance.

To me it seems like using the former should yield the same results with pad=1 (equivalent to pad='same'), albeit with some performance hit beyond simply the use of the CPU. I would like to test this but unfortunately I am not very familiar with Theano currently.

twitteried commented 9 years ago

I'm completely new to these libraries, but I have a less-than-stellar NVIDIA GeForce GT 610 running on my machine and am experiencing the same error.

ryankiros commented 9 years ago

We are working on adding Caffe as an additional option, which works fine on both GPU and CPU. This will be included shortly.