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

Extra cudaStreamCreate/cudaStreamDestroy #16592

Closed
mnicely opened this issue Feb 15, 2020 · 2 comments · Fixed by #20019
Closed

Extra cudaStreamCreate/cudaStreamDestroy #16592

mnicely opened this issue Feb 15, 2020 · 2 comments · Fixed by #20019
Labels
bug category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib
Milestone

Comments

@mnicely
Copy link

mnicely commented Feb 15, 2020

System information (version)
  • OpenCV => 4.2.0-dev
  • Operating System / Platform => Ubuntu 18.04
  • Compiler => GNU G++ 7.4.0
  • Python => 3.6.9
Detailed description

When I run self.frame_device.upload(self.frame, stream) I'm getting an extra cudaStreamCreate and cudaStreamDestroy right before the cudaMemcpy2DAsync. (See attached)
extraStream

Steps to reproduce
import os
import sys
import glob
import numpy as np
import time
import cv2
import cudasift

class PreCuda:
    def __init__(self, size):
        print("__init__")
        self.rows = size
        self.cols = size
        self.stream = cv2.cuda_Stream( )
        self.frame = np.zeros((size,size,3),np.uint8)
        cv2.cuda.registerPageLocked(self.frame)
        self.frame_device = cv2.cuda_GpuMat(size,size,cv2.CV_8UC3)

    def __del__(self):
        print("unregisterPageLocked")
        cv2.cuda.unregisterPageLocked(self.frame)

    def ProcessFrame(self):
        print("ProcessFrame")
        self.frame_device.upload(self.frame, self.stream) # <-- issue

    def Frame(self, img):
        print("Frame")
        img = cv2.imread(image_name)
        img.resize(self.rows, self.cols, 3)
        np.copyto(self.frame,img)

image_names = glob.glob('images/*')


size = 512
image_data = PreCuda(size)

for image_name in image_names:
    image_data.Frame(image_name)
    image_data.ProcessFrame()

-->

r2d3 added a commit to r2d3/opencv that referenced this issue May 1, 2021
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
r2d3 added a commit to r2d3/opencv that referenced this issue May 1, 2021
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
r2d3 added a commit to r2d3/opencv that referenced this issue May 1, 2021
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
r2d3 added a commit to r2d3/opencv that referenced this issue May 1, 2021
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
r2d3 added a commit to r2d3/opencv that referenced this issue May 1, 2021
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
add test_cuda_upload_download_stream to test_cuda.py
@r2d3
Copy link
Contributor

r2d3 commented May 1, 2021

Hello Matthew @mnicely,

you could verify the latest version of OpenCV master, it integrates my patch that solves this issue. And confirm that this is solving the issue for you too.

Regards

David

@mnicely
Copy link
Author

mnicely commented May 6, 2021

Hi @r2d3
Unfortunately, that task is not active and it might be awhile before I can circle back. I'm fine with closing this.

a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this issue Mar 30, 2023
this corrects bug opencv#16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
add test_cuda_upload_download_stream to test_cuda.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants