From af7d48198811d3d495ee5754a26035dc55bb56b8 Mon Sep 17 00:00:00 2001 From: Tomohiro Ubukata Date: Thu, 5 Mar 2020 10:03:51 +0000 Subject: [PATCH] Add CUDA_CHECK to some cudaFree callings --- src/caffe/layers/cudnn_conv_layer.cpp | 4 ++-- src/caffe/layers/cudnn_deconv_layer.cpp | 4 ++-- src/caffe/layers/cudnn_lcn_layer.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/caffe/layers/cudnn_conv_layer.cpp b/src/caffe/layers/cudnn_conv_layer.cpp index efc9e04e8c0..6169cdca428 100644 --- a/src/caffe/layers/cudnn_conv_layer.cpp +++ b/src/caffe/layers/cudnn_conv_layer.cpp @@ -195,7 +195,7 @@ void CuDNNConvolutionLayer::Reshape( workspaceSizeInBytes = total_max_workspace; // free the existing workspace and allocate a new (larger) one - cudaFree(this->workspaceData); + CUDA_CHECK(cudaFree(this->workspaceData)); cudaError_t err = cudaMalloc(&(this->workspaceData), workspaceSizeInBytes); if (err != cudaSuccess) { @@ -251,7 +251,7 @@ CuDNNConvolutionLayer::~CuDNNConvolutionLayer() { cudnnDestroy(handle_[g]); } - cudaFree(workspaceData); + CUDA_CHECK(cudaFree(workspaceData)); delete [] workspace; delete [] stream_; delete [] handle_; diff --git a/src/caffe/layers/cudnn_deconv_layer.cpp b/src/caffe/layers/cudnn_deconv_layer.cpp index 260da5c1ee0..f2e48f2e1be 100644 --- a/src/caffe/layers/cudnn_deconv_layer.cpp +++ b/src/caffe/layers/cudnn_deconv_layer.cpp @@ -253,7 +253,7 @@ void CuDNNDeconvolutionLayer::Reshape( workspaceSizeInBytes = total_max_workspace; // free the existing workspace and allocate a new (larger) one - cudaFree(this->workspaceData); + CUDA_CHECK(cudaFree(this->workspaceData)); cudaError_t err = cudaMalloc(&(this->workspaceData), workspaceSizeInBytes); if (err != cudaSuccess) { @@ -309,7 +309,7 @@ CuDNNDeconvolutionLayer::~CuDNNDeconvolutionLayer() { cudnnDestroy(handle_[g]); } - cudaFree(workspaceData); + CUDA_CHECK(cudaFree(workspaceData)); delete [] workspace; delete [] stream_; delete [] handle_; diff --git a/src/caffe/layers/cudnn_lcn_layer.cpp b/src/caffe/layers/cudnn_lcn_layer.cpp index 9c09bf26b4d..82f2175e239 100644 --- a/src/caffe/layers/cudnn_lcn_layer.cpp +++ b/src/caffe/layers/cudnn_lcn_layer.cpp @@ -42,8 +42,8 @@ void CuDNNLCNLayer::Reshape(const vector*>& bottom, if (totalSizeInBytes > tempDataSize) { tempDataSize = totalSizeInBytes; - cudaFree(tempData1); - cudaFree(tempData2); + CUDA_CHECK(cudaFree(tempData1)); + CUDA_CHECK(cudaFree(tempData2)); // allocate new buffers CUDA_CHECK(cudaMalloc(&tempData1, totalSizeInBytes)); @@ -63,8 +63,8 @@ CuDNNLCNLayer::~CuDNNLCNLayer() { cudnnDestroy(handle_); // free temp buffers - cudaFree(tempData1); - cudaFree(tempData2); + CUDA_CHECK(cudaFree(tempData1)); + CUDA_CHECK(cudaFree(tempData2)); } INSTANTIATE_CLASS(CuDNNLCNLayer);