caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Training Imagenet on Tesla M2050

Open ssierral opened this issue 12 years ago • 8 comments

Hi, I have strictly followed the instructions on the webpage http://caffe.berkeleyvision.org/imagenet_training.html with a Tesla M2050. Everything went fine until I ran the solver and I got the following problem:

Solving CaffeNet
Check failed: error == cudaSuccess (9 vs. 0)  invalid configuration argument

Then I saw a suggestion in https://github.com/BVLC/caffe/issues/12 of @sguada, who recommends reducing the batch size. Then I reduced to 50 the batch size in the train prototxt and indeed it works but I got another problem. The loss rate does not decrease and stays at ~0.69... in a similar way as https://github.com/BVLC/caffe/issues/59 and https://github.com/BVLC/caffe/issues/430...

I wanted to know if somebody could help me with the two problems: The meaning of the first error using the M2050 and how can I adjust the model so the loss decreases?

Thanks in advance..

ssierral avatar Jun 12 '14 08:06 ssierral

@inulinux12 the loss you are getting it is pretty low for ImageNet training, so it could be that since you use a small set it converges and overfit very quickly. Does the loss decrease initially? Also it could be that you didn't get images of all classes, given your reduced set.

Reducing the batch size can require adjusting the base_lr accordingly, so try to make it smaller.

sguada avatar Jun 17 '14 00:06 sguada

Indeed I am actually training with the whole dataset and unfortunately that loss was a type error... it stays at ~6.90... Here i have a snapshot of what's going on with the solver state.

 Iteration 330000, Testing net
I0617 02:16:49.121147 24207 solver.cpp:142] Test score #0: 0.001
I0617 02:16:49.121240 24207 solver.cpp:142] Test score #1: 6.90959
I0617 02:17:04.298697 24207 solver.cpp:237] Iteration 330020, lr = 1e-05
I0617 02:17:04.299059 24207 solver.cpp:87] Iteration 330020, loss = 6.91061
I0617 02:17:19.392648 24207 solver.cpp:237] Iteration 330040, lr = 1e-05
I0617 02:17:19.393013 24207 solver.cpp:87] Iteration 330040, loss = 6.90365
I0617 02:17:34.473000 24207 solver.cpp:237] Iteration 330060, lr = 1e-05
I0617 02:17:34.473361 24207 solver.cpp:87] Iteration 330060, loss = 6.89674
I0617 02:17:49.558796 24207 solver.cpp:237] Iteration 330080, lr = 1e-05
I0617 02:17:49.559154 24207 solver.cpp:87] Iteration 330080, loss = 6.90109
I0617 02:18:04.652261 24207 solver.cpp:237] Iteration 330100, lr = 1e-05
I0617 02:18:04.652623 24207 solver.cpp:87] Iteration 330100, loss = 6.91144
I0617 02:18:19.733106 24207 solver.cpp:237] Iteration 330120, lr = 1e-05
I0617 02:18:19.733471 24207 solver.cpp:87] Iteration 330120, loss = 6.91196
I0617 02:18:34.828780 24207 solver.cpp:237] Iteration 330140, lr = 1e-05
I0617 02:18:34.829144 24207 solver.cpp:87] Iteration 330140, loss = 6.90894

ssierral avatar Jun 17 '14 07:06 ssierral

I run into a similar issue. I was able to solve it by setting the initial bias fillers to the same values (0.1) as suggested in the alexnet train config.

to3i avatar Jun 27 '14 11:06 to3i

Thanks, I will be setting these new bias_filler values, but I wanted to ask you @to3i, which setup did you use in your solver.prototxt? Mine is:

train_net: "imagenet_train.prototxt"
test_net: "imagenet_val.prototxt"
test_iter: 1000
test_interval: 1000
base_lr: 0.005
lr_policy: "step"
gamma: 0.1
stepsize: 400000
display: 20
max_iter: 1800000
momentum: 0.9
weight_decay: 0.0005
snapshot: 40000
snapshot_prefix: "caffe_imagenet_train"

I don't know if the values like the learning rate is correct so I'm following the recommendations of Bottou in Tricks of the trade(http://research.microsoft.com/pubs/192769/tricks-2012.pdf) book, one of those tricks is that one can find the appropiate learning rate experimenting with a smaller dataset. I created two smaller datasets of about 30k images(30 per concept) and 60k(60 per concept) and trying to optimize de learning rate base but I'm not getting good results...

ssierral avatar Jul 03 '14 08:07 ssierral

I am using the original solver.prototxt as provided in the imagenet example. The parameters provided in the imagenet example usually work out of the box and afaik work in different libraries as well.

I have no experience with training on small subsets of imagenet. However, I would recommend running training on the full ILSVRC 2012 trainset with the parameters provided and observe how the loss behaves during the first 5k to 10k iterations. If your loss is not decreasing below the 6.9 threshold (which is equivalent to random guessing), restart training with altered parameters.

to3i avatar Jul 03 '14 20:07 to3i

How long does it take you guys for every 10,000 iter snapshot to be generated? It takes me 5 hours when using 2 GPUs, and I'm not sure if that is normal. I appreciate your comments!

anguyen8 avatar Jul 04 '14 04:07 anguyen8

I have no experience with using two GPUs. Using a single GTX 770 the machine can process about 40 iterations per minute. Including test time it probably takes up to 5 hours as well.

to3i avatar Jul 04 '14 20:07 to3i

Thank you @to3i ! Probably my setting is only for 1 GPU while there are two available on my clusters.

anguyen8 avatar Jul 04 '14 20:07 anguyen8