Fix a recently introduced race condition in DataLayer #2998

Merged
merged 1 commit into from Aug 30, 2015
Jump to file or symbol
Failed to load files and symbols.
+3 −1
Split
@@ -20,7 +20,9 @@ void BasePrefetchingDataLayer<Dtype>::Forward_gpu(
caffe_copy(batch->label_.count(), batch->label_.gpu_data(),
top[1]->mutable_gpu_data());
}
-
+ // Ensure the copy is synchronous wrt the host, so that the next batch isn't
+ // copied in meanwhile.
+ CUDA_CHECK(cudaStreamSynchronize(cudaStreamDefault));
prefetch_free_.push(batch);
}