filipradenovic / cnnimageretrieval

CNN Image Retrieval in MatConvNet: Training and evaluating CNNs for Image Retrieval in MatConvNet
http://cmp.felk.cvut.cz/cnnimageretrieval
MIT License
188 stars 54 forks source link

Is it possible to run the training code on a less powerful GPU? #5

Closed mohsij closed 6 years ago

mohsij commented 6 years ago

I went through the second paper and it says the training was done on a TITAN X with 12GB of memory. I tried running the training code on a system with GTX 1070 with 8GB of memory and get the following error even if I reset the GPU memory at the start:

Error using gpuArray/max
Out of memory on device. To view more detail about available memory on the GPU, use 'gpuDevice()'. If
the problem persists, reset the GPU by calling 'gpuDevice(1)'.

Error in vl_nnrelu (line 45)
    y = max(x, 0) ;

Error in dagnn.ReLU/forwardAdvanced (line 29)
      net.vars(out).value = vl_nnrelu(net.vars(in).value, [], ...

Error in dagnn.DagNN/eval (line 91)
  obj.layers(l).block.forwardAdvanced(obj.layers(l)) ;

Error in train_network>processEpoch (line 228)
      net.eval(inputs, params.derOutputs, 'holdOn', subbatch < params.numSubBatches) ;

Error in train_network (line 90)
    [net, state] = processEpoch(net, state, params, 'train') ;

Error in train_cnnimageretrieval (line 66)
[net, state, stats] = train_network(net, @(o,i,n,b,s,m,e) get_batch(o,i,n,b,s,m,e), opts.train);

Is there a way to solve this by using a smaller subset of the training data or some other way? Thanks!

filipradenovic commented 6 years ago

The best you can do is set >> opts.train.numSubBatches=5 (equal to opts.train.batchSize). That will make training a little slower but use much less memory.

I hope this solves your issue, with 8GB and batches split in sub-batches it should fit in the memory. You can also try smaller splits, ie numSubBatches=2 or 3.