Skip to content

Commit

Permalink
Merge pull request #2921 from buaaliyi/multi_gpu
Browse files Browse the repository at this point in the history
Destroy CUDA stream when finished
  • Loading branch information
ronghanghu committed Aug 14, 2015
2 parents 33e5b39 + e696f85 commit 65c7fa6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/caffe/layers/base_data_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void BasePrefetchingDataLayer<Dtype>::InternalThreadEntry() {
#ifndef CPU_ONLY
cudaStream_t stream;
if (Caffe::mode() == Caffe::GPU) {
cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking);
CUDA_CHECK(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking));
}
#endif

Expand All @@ -85,14 +85,19 @@ void BasePrefetchingDataLayer<Dtype>::InternalThreadEntry() {
#ifndef CPU_ONLY
if (Caffe::mode() == Caffe::GPU) {
batch->data_.data().get()->async_gpu_push(stream);
cudaStreamSynchronize(stream);
CUDA_CHECK(cudaStreamSynchronize(stream));
}
#endif
prefetch_full_.push(batch);
}
} catch (boost::thread_interrupted&) {
// Interrupted exception is expected on shutdown
}
#ifndef CPU_ONLY
if (Caffe::mode() == Caffe::GPU) {
CUDA_CHECK(cudaStreamDestroy(stream));
}
#endif
}

template <typename Dtype>
Expand Down

0 comments on commit 65c7fa6

Please sign in to comment.