summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRonghang Hu <huronghang@hotmail.com>2015-08-14 10:54:11 -0700
committerRonghang Hu <huronghang@hotmail.com>2015-08-14 10:54:11 -0700
commit65c7fa6e92d81c68d44caa206bd003013786ac69 (patch)
treefc7b0cea4b15d16c4675aaad30e0ba5d83c3d7de /src
parent33e5b3929cc2fa3fee8562408b7d4e8c0febb008 (diff)
parente696f85abe2c50107fbb67b211bf7dad0f87ade0 (diff)
downloadcaffeonacl-65c7fa6e92d81c68d44caa206bd003013786ac69.tar.gz
caffeonacl-65c7fa6e92d81c68d44caa206bd003013786ac69.tar.bz2
caffeonacl-65c7fa6e92d81c68d44caa206bd003013786ac69.zip
Merge pull request #2921 from buaaliyi/multi_gpu
Destroy CUDA stream when finished
Diffstat (limited to 'src')
-rw-r--r--src/caffe/layers/base_data_layer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/caffe/layers/base_data_layer.cpp b/src/caffe/layers/base_data_layer.cpp
index 20f76f62..5303fe9c 100644
--- a/src/caffe/layers/base_data_layer.cpp
+++ b/src/caffe/layers/base_data_layer.cpp
@@ -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
@@ -85,7 +85,7 @@ 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);
@@ -93,6 +93,11 @@ void BasePrefetchingDataLayer<Dtype>::InternalThreadEntry() {
} 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>