cv::resize function costs 143M GPU memory in opencv version 3.2.0

asked 2017-12-28 06:38:22 -0500

PangWong gravatar image

updated 2017-12-28 07:15:17 -0500

berak gravatar image

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:

  1. Ubuntu 16.04
  2. Opencv3.2.0, cmake compile flag WITH_CUDA=OFF
  3. Nvidia GTX1080Ti, CUDA8.0

Anybody could explain what happened and how can I release the memory consumption?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

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.

berak gravatar imageberak ( 2017-12-28 06:49:54 -0500 )edit
1

Thanks, I have post my code in text and would you please help me with the format.

PangWong gravatar imagePangWong ( 2017-12-28 07:08:29 -0500 )edit

thanks for the edit ! (now ppl can 'try* your code, it can be properly indexed for search, etc.

berak gravatar imageberak ( 2017-12-28 07:15:59 -0500 )edit
1

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

PangWong gravatar imagePangWong ( 2017-12-28 07:21:04 -0500 )edit