cv::resize function costs 143M GPU memory in opencv version 3.2.0
Below is my test script:
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
//#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <iostream>
#include <string>
int main() {
std::string path = "/home/pangwong/TestSpace/test_images/car_test.png";
cv::Mat img = cv::imread(path);
for (int i = 0; i < 100000; i++) {
std::cin.get();
cv::resize(img, img, cv::Size(144, 144));
std::cout << "aaa" << std::endl;
std::cin.get();
}
}
When the routine went to the first "std::cin.get()", no memory was occupied. But when I input something and went to the second "std::cin.get()", something strange happened. Bolow is the nvidia-smi result.
As we can see, 143M GPU memory has been occupied.
System Info:
- Ubuntu 16.04
- Opencv3.2.0, cmake compile flag WITH_CUDA=OFF
- Nvidia GTX1080Ti, CUDA8.0
Anybody could explain what happened and how can I release the memory consumption?
Thanks in advance.
i removed your screenshots, please do not post images of code here, but text
please edit your question, and supply those, we'll help you with the formatting, if nessecary.
Thanks, I have post my code in text and would you please help me with the format.
thanks for the edit ! (now ppl can 'try* your code, it can be properly indexed for search, etc.
Thanks a lot. Update: I tried opencv 2.4.13 and the strange phenomenon missed. So I Guess there is something wrong with opencv3.2