happynear / happynear/caffe-windows
after deleting a Net instance, the GPU memory is not released
- Dominant language
- C++
- Stars
- 1.3k
- Forks
- 637
- PR merge metrics
- No merged PRs in 30d
Description
This is my construction of Classifier:
Classifier::Classifier(const std::string& model_file,
const std::string& trained_file)
{
#ifdef CPU_ONLY
Caffe::set_mode(Caffe::CPU);
#else
Caffe::set_mode(Caffe::GPU);
#endif
/* Load the network. */
net_.reset(new Net(model_file, TEST));
net_->CopyTrainedLayersFrom(trained_file);
CHECK_EQ(net_->num_inputs(), 1) << "Network should have exactly one input.";
CHECK_EQ(net_->num_outputs(), 1) << "Network should have exactly one output.";
Blob* input_layer = net_->input_blobs()[0];
num_channels_ = input_layer->channels();
CHECK(num_channels_ == 3 || num_channels_ == 1)
<< "Input layer should have 1 or 3 channels.";
input_geometry_ = cv::Size(input_layer->width(), input_layer->height());
}
and,this is my test code:
Classifier* cnn_1 = new Classifier(lenet_model_file, lenet_trained_file);
delete cnn_1;
the problem is after deleting cnn_1, the memory of GPU is not released.
Please tell me how to release the memory of GPU caused by loading the model.
Contributor guide
Assessment
This issue has not been assessed yet.