Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

after deleting a Net instance, the GPU memory is not released #327

Open
mmchen88 opened this issue Apr 18, 2020 · 0 comments
Open

after deleting a Net instance, the GPU memory is not released #327

mmchen88 opened this issue Apr 18, 2020 · 0 comments

Comments

@mmchen88
Copy link

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<float>(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<float>* 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.

@mmchen88 mmchen88 changed the title after delete a Net instance, GPU memory is not released after deleting a Net instance, GPU memory is not released Apr 18, 2020
@mmchen88 mmchen88 changed the title after deleting a Net instance, GPU memory is not released after deleting a Net instance, the GPU memory is not released Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant