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

Memory leak in cppflow::decode_jpeg()? #228

Open
resetpointer opened this issue Dec 8, 2022 · 1 comment
Open

Memory leak in cppflow::decode_jpeg()? #228

resetpointer opened this issue Dec 8, 2022 · 1 comment

Comments

@resetpointer
Copy link

resetpointer commented Dec 8, 2022

Hi, I am creating a cpp tensor in two different ways. The first method is by using cppflow::decode_jpeg() to create a tensor on GPU memory, the second method is by creating a tensor manually on system memory. The first method causes memory leak, where as the second method does not. The code is as follow:

#define USE_TENSORFLOW_API_GPU_API
#ifdef USE_TENSORFLOW_API_GPU_API
    input = cppflow::decode_jpeg(req->image().content());
    input = cppflow::expand_dims(input, 0);
#else
    std::vector<uint8_t> data;
    for(int i=0; i < h; i++){
        for(int j=0; j < w; j++){
            QColor color = image.pixelColor(j,i);
            int red, green, blue;
            green = color.green();
            blue = color.blue();
            red = color.red();

            data.push_back(red);
            data.push_back(green);
            data.push_back(blue);
        }
    }

    input = cppflow::tensor(data, {1, h, w, 3});
#endif

I am not sure what causes the memory leak, would someone comment on this issue?

I read from this thread that GPU memory (of CUDA toolkit) does not get de-allocated until the process terminated. Please advise if you know anything about this. thanks

@ljn917
Copy link
Contributor

ljn917 commented Dec 20, 2022

@resetpointer Could you please provide the minimal compilable code so that we can reproduce the leak? It would be better if you can provide the jpeg image. In addition, which version of the TF C API did you use?

Please also clarify that the leak happens on CPU, GPU or both. I am a bit confused.

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

2 participants