caffe icon indicating copy to clipboard operation
caffe copied to clipboard

Check failed: data_

Open alex-pt opened this issue 11 years ago • 11 comments

Hello everyone!

I'm trying to train the standard bvlc_reference_caffenet model for a certain keyword with a custom dataset (109 images).

Here's my solver (models/bvlc_reference_caffenet/solver.prototxt), deploy and train_val prototxt files: https://gist.github.com/alex-poterya/82ad37869599936f1e23

I'm getting the following error:

F0403 00:41:11.246575  6415 blob.cpp:101] Check failed: data_
*** Check failure stack trace: ***
    @     0x7f9fd4843daa  (unknown)
    @     0x7f9fd4843ce4  (unknown)
    @     0x7f9fd48436e6  (unknown)
    @     0x7f9fd4846687  (unknown)
    @     0x7f9fd4c1979e  caffe::Blob<>::mutable_cpu_data()
    @     0x7f9fd4bccfc5  caffe::BasePrefetchingDataLayer<>::LayerSetUp()
    @     0x7f9fd4c14132  caffe::Net<>::Init()
    @     0x7f9fd4c15bf2  caffe::Net<>::Net()
    @     0x7f9fd4c55934  caffe::Solver<>::InitTestNets()
    @     0x7f9fd4c5602b  caffe::Solver<>::Init()
    @     0x7f9fd4c561f6  caffe::Solver<>::Solver()
    @           0x40c3d0  caffe::GetSolver<>()
    @           0x406371  train()
    @           0x404901  main
    @     0x7f9fd3d55ec5  (unknown)
    @           0x404ead  (unknown)
    @              (nil)  (unknown)

Here's the full output: https://gist.github.com/alex-poterya/1c11649086c72c075ce5

Any advice on what I'm missing here or how to debug this would be extremely helpful.

Thanks, Alex.

alex-pt avatar Apr 03 '15 04:04 alex-pt

Look at these two lines in your full output:

I0403 00:32:18.600239 6403 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_val_lmdb I0403 00:32:18.600582 6403 data_layer.cpp:67] output data size: 0,3,227,227

This means that you have no database file examples/imagenet/ilsvrc12_val_lmdb, or it's not being read properly. Fix that and you should be good to go.

mprat avatar Apr 03 '15 13:04 mprat

@mprat Thanks for your reply!

This is the way *_lmdb files are generated. There is no errors here.

root@deeplearning:/var/www/caffe-master# sh examples/imagenet/create_imagenet.sh
Creating train lmdb...
I0403 12:02:45.686950 16263 convert_imageset.cpp:79] Shuffling data
I0403 12:02:45.688592 16263 convert_imageset.cpp:82] A total of 109 images.
I0403 12:02:45.689610 16263 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_train_lmdb
E0403 12:02:46.526530 16263 convert_imageset.cpp:149] Processed 109 files.
Creating val lmdb...
I0403 12:02:46.557591 16265 convert_imageset.cpp:79] Shuffling data
I0403 12:02:46.558353 16265 convert_imageset.cpp:82] A total of 1 images.
I0403 12:02:46.558717 16265 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_val_lmdb
E0403 12:02:46.568151 16265 convert_imageset.cpp:149] Processed 1 files.
Done.
root@deeplearning:/var/www/caffe-master# sh -x examples/imagenet/make_imagenet_mean.sh
+ EXAMPLE=examples/imagenet
+ DATA=data/ilsvrc12
+ TOOLS=build/tools
+ build/tools/compute_image_mean examples/imagenet/ilsvrc12_train_lmdb data/ilsvrc12/imagenet_mean.binaryproto
+ echo Done.
Done.
ls examples/imagenet/ilsvrc12_val_lmdb
data.mdb  lock.mdb

Any advice on what should I look into next? What would be the right way to troubleshoot if data.mdb contains the correct data?

alex-pt avatar Apr 03 '15 16:04 alex-pt

Well, your validation database seems to only have one file in it. Given that your prototxt seems to have a batch size of 5, trying to generate a batch size of 5 with only 1 image in your lmdb will definitely cause an error. Why do you only have 1 image in your validation set? You should try to have something like 10% of your training set becoming your validation set. So if you only have 109 images (which is pretty small for fine-tuning a neural net the size of imagenet anyway), you should break up your data into a training + validation + testing set. Ideally each of these for fine-tuning would have on the order of hundreds if not thousands per category you are trying to tune to. At the very least, you should include a minimum of 5 images in your validation set so that you don't get any errors during caffe's TEST phase.

mprat avatar Apr 03 '15 16:04 mprat

(by the way, no affiliation with BVLC, just a regular old caffe user)

mprat avatar Apr 03 '15 16:04 mprat

@mprat Thanks for clarifying this!

Why do you only have 1 image in your validation set? Ideally each of these for fine-tuning would have on the order of hundreds if not thousands per category you are trying to tune to.

This is intended to be more of a proof of concept, just to make it run and then I'd train it on a much larger data set.

At the very least, you should include a minimum of 5 images in your validation set so that you don't get any errors during caffe's TEST phase.

After including 5 pictures in the validation set I'm getting the same error.

Creating train lmdb...
I0403 13:07:26.134297 18067 convert_imageset.cpp:79] Shuffling data
I0403 13:07:26.135725 18067 convert_imageset.cpp:82] A total of 109 images.
I0403 13:07:26.138103 18067 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_train_lmdb
E0403 13:07:26.976610 18067 convert_imageset.cpp:149] Processed 109 files.
Creating val lmdb...
I0403 13:07:27.010831 18071 convert_imageset.cpp:79] Shuffling data
I0403 13:07:27.011456 18071 convert_imageset.cpp:82] A total of 5 images.
I0403 13:07:27.011761 18071 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_val_lmdb
E0403 13:07:27.207181 18071 convert_imageset.cpp:149] Processed 5 files.
Done.
I0403 13:05:28.675997 18029 layer_factory.hpp:74] Creating layer data
I0403 13:05:28.676039 18029 net.cpp:84] Creating Layer data
I0403 13:05:28.676058 18029 net.cpp:338] data -> data
I0403 13:05:28.676085 18029 net.cpp:338] data -> label
I0403 13:05:28.676115 18029 net.cpp:113] Setting up data
I0403 13:05:28.676239 18029 db.cpp:34] Opened lmdb examples/imagenet/ilsvrc12_val_lmdb
I0403 13:05:28.676633 18029 data_layer.cpp:67] output data size: 0,3,227,227
I0403 13:05:28.676669 18029 data_transformer.cpp:22] Loading mean file from: data/ilsvrc12/imagenet_mean.binaryproto
F0403 13:05:28.679837 18029 blob.cpp:101] Check failed: data_
*** Check failure stack trace: ***
    @     0x7ff8ac684daa  (unknown)
    @     0x7ff8ac684ce4  (unknown)
    @     0x7ff8ac6846e6  (unknown)
    @     0x7ff8ac687687  (unknown)
    @     0x7ff8aca5a79e  caffe::Blob<>::mutable_cpu_data()
    @     0x7ff8aca0dfc5  caffe::BasePrefetchingDataLayer<>::LayerSetUp()
    @     0x7ff8aca55132  caffe::Net<>::Init()
    @     0x7ff8aca56bf2  caffe::Net<>::Net()
    @     0x7ff8aca96934  caffe::Solver<>::InitTestNets()
    @     0x7ff8aca9702b  caffe::Solver<>::Init()
    @     0x7ff8aca971f6  caffe::Solver<>::Solver()
    @           0x40c3d0  caffe::GetSolver<>()
    @           0x406371  train()
    @           0x404901  main
    @     0x7ff8abb96ec5  (unknown)
    @           0x404ead  (unknown)
    @              (nil)  (unknown)
Aborted (core dumped)

alex-pt avatar Apr 03 '15 17:04 alex-pt

Can you try with more than 5? You see the line that is the problem:

I0403 13:05:28.676633 18029 data_layer.cpp:67] output data size: 0,3,227,227

Your lmdb is still not returning anything. Looking at your solver, you are also trying to do

test_iter: 50

which means caffe will generate 50 random samples of size batch_size (in your case, 5) from your testing set. Try putting more than 5 images in your val LMDB and changing test_iter to something like 1. That /should/ get rid of your problem, if I understand caffe right.

mprat avatar Apr 03 '15 17:04 mprat

If I set test_iter to 1 and increase validation set to 20 pictures (~20% of the training set) I'm still getting the same error.

I wonder what would be the steps to troubleshoot my lmdb? eg fetch certain keys with an external script, etc

alex-pt avatar Apr 03 '15 23:04 alex-pt

I think you're getting output data size: 0, ... because you have batch_size: 0 in your TEST data layer...change that 0 to a positive int?

jeffdonahue avatar Apr 03 '15 23:04 jeffdonahue

@jeffdonahue That helped. Thanks!

alex-pt avatar Apr 04 '15 00:04 alex-pt

Hi,

Does someone know why this message appears?

vpn26055:~ CarlosTrevino$ sh caffe_win_01062015/data/camvid/create_camvid_ex.sh Creating train lmdb... I0603 16:35:00.728893 1968370432 convert_imageset.cpp:79] Shuffling data I0603 16:35:00.735761 1968370432 convert_imageset.cpp:82] A total of 0 images. I0603 16:35:00.750924 1968370432 db.cpp:34] Opened lmdb examples/camvid/example_train_lmdb Creating val lmdb... I0603 16:35:00.947710 1968370432 convert_imageset.cpp:79] Shuffling data I0603 16:35:00.955155 1968370432 convert_imageset.cpp:82] A total of 0 images. I0603 16:35:00.955641 1968370432 db.cpp:34] Opened lmdb examples/camvid/example_val_lmdb Done.

It seems that i can't even load an image.

ctrevino avatar Jun 03 '15 14:06 ctrevino

@ctrevino I have the same problem when I convert images...Have you already solve it?

effielikesmilk avatar Aug 26 '16 02:08 effielikesmilk