caffe icon indicating copy to clipboard operation
caffe copied to clipboard

MNIST Autoencoder Example hangs on data layer lock

Open andykitchen opened this issue 11 years ago • 11 comments

Hi, All

I'm running 5367a1af5dc8a56a284b7f1c67efce097871955a and running the mnist Autoencoder example just hangs. I have a very vanilla setup compiled on ubuntu 14.04 using cuda 7.0.

andykitchen avatar Sep 06 '15 02:09 andykitchen

the problem is not present in 8181870b9ac330a094ab0f8d53f54a0202f697a0 I'm using that version currently

andykitchen avatar Sep 06 '15 02:09 andykitchen

Same here. Curious: what Cuda Toolkit version are you using? I'm using 5.5, for which this older commit works out of the box (as opposed to having to throw away some multi-GPU code blocks in a C++ file with the following commits).

rdipietro avatar Sep 08 '15 12:09 rdipietro

I also can confirm this issue.

Additionally, the MNIST autoencoder does not work with leveldb because the TRAIN datalayer locks train_leveldb.

nik-ko avatar Sep 16 '15 14:09 nik-ko

A temporary workaround in this case would be to rename the source in the "test-on-train" data layer to:

source: "./examples/mnist/mnist_train_lmdb"

vs.

source: "examples/mnist/mnist_train_lmdb"

The problem was introduced by the MultiGPU extension, particularly in bcc8f50a95ecad954d1887f3fb273eaa298e2274 partly as a result of lines 23-29 in data_reader.cpp:

string key = source_key(param);
weak_ptr<Body>& weak = bodies_[key];
body_ = weak.lock();
if (!body_) {
  body_.reset(new Body(param));
  bodies_[key] = weak_ptr<Body>(body_);
}

Only one Body object is created per data source (the "key" being the path to the source/lmdb, hence the workaround), and for some reason this prevents the "test-on-train" data layer during setup from completing Datum& datum = *(reader_.full().peek()) in DataLayer<Dtype>::DataLayerSetUp().

I have a rough patch that I could PR in, unless the people who were involved with that branch (@cypof, @ronghanghu) would prefer to take a crack at addressing it. Basically, it uses an additional layer parameter to override the "one Body per data source" restriction, but there's probably a more principled way to address this.

mohomran avatar Sep 16 '15 18:09 mohomran

@rdipietro I was using CUDA 7.0, which was the newest at the time. 8181870b9ac330a094ab0f8d53f54a0202f697a0 compiles out of the box for me with CUDA 7.0

andykitchen avatar Sep 17 '15 05:09 andykitchen

I can confirm this bug as well. adding "./" to the source resolves the issue.

mbz avatar Oct 30 '15 17:10 mbz

If using the path as a key, then perhaps the path should be made canonical.

seanbell avatar Oct 30 '15 20:10 seanbell

Same bug. And the "./" trick works.

suruoxi avatar Nov 01 '15 09:11 suruoxi

Closing in favor of #3108, which more directly explains the issue here.

longjon avatar Nov 05 '15 09:11 longjon

Adding the "./" in "test-on-train" data layer works well. @mohomran Thank you very much.

yinchuandong avatar Mar 23 '16 00:03 yinchuandong

Adding the "./" in "test-on-train" data layer works well. @mohomran Thank you very much.

BobLiu20 avatar Mar 18 '17 01:03 BobLiu20