Search code examples
luatorchmnist

Torch: luajit out of memory on simple task


I am trying to load the MNIST dataset in the th repl and do mean subtraction by the following:

file = torch.load('data/mnist.t7/train_32x32.t7', 'ascii') 
data = file.data:type(torch.getdefaulttensortype()) 
mean = data:mean() 
data:add(-mean)

The last line causes the following error:

.../torch/install/bin/luajit: not enough memory

I am running this on a laptop with 16GB of RAM. Also MNIST has already been loaded into data so not sure why doing data:add(-mean) would cause this issue. Any ideas?

Thanks


Solution

  • The problem was that it was trying to print the whole matrix (which is large) to the console.

    This can be overcome by doing either data = data:add(-mean) or data:add(-mean); - notice the semicolon

    Answer provided by Soumith Chintala on the torch gitter.