# cuda\_GpuMat.upload() error doesn't make sense

**URL:** <https://forum.opencv.org/t/cuda-gpumat-upload-error-doesnt-make-sense/9258>\
**Category:** Python\
**Tags:** cuda\
**Created:** [June 21, 2022, 3:55pm UTC](https://forum.opencv.org/t/cuda-gpumat-upload-error-doesnt-make-sense/9258 "2022-06-21T15:55:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Mullen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/brian_mullen/32/5464_2.png) [@Brian\_Mullen](https://forum.opencv.org/u/Brian_Mullen)\
**Post date:** [June 21, 2022, 3:55pm UTC](https://forum.opencv.org/t/cuda-gpumat-upload-error-doesnt-make-sense/9258/1 "2022-06-21T15:55:06Z")

</div>

I’m trying to understand how to use streams with OpenCV and CUDA. I’m really stumped by this error.

My Code:

```auto
import pycuda.gpuarray as gpuarray
import pycuda.driver as cuda

import numpy as np

gpu_frame = cv2.cuda_GpuMat((960, 960), cv2.CV_32FC1)
stream = cuda.Stream()

frame = np.random(960,960)
gpu_frame.upload(frame, stream)

```

Gives the error:

```auto
cv2.error: OpenCV(4.6.0-dev) :-1: error: (-5:Bad argument) in function 'upload'
> Overload resolution failed:
> - cuda_GpuMat.upload() takes at most 1 argument (2 given)
> - cuda_GpuMat.upload() takes at most 1 argument (2 given)
> - cuda_GpuMat.upload() takes at most 1 argument (2 given)
> - Expected Ptr<cv::cuda::Stream> for argument 'stream'
> - Expected Ptr<cv::cuda::GpuMat> for argument 'arr'
> - Expected Ptr<cv::cuda::Stream> for argument 'stream'

```

The documentation says that cuda\_GpuMat.upload() can take two arguments, array and stream. The error message says the same thing. Why am I getting the error?

---

<div class="post-metadata">

**Author:** ![cudawarped](https://avatars.discourse-cdn.com/v4/letter/c/9dc877/32.png) [@cudawarped](https://forum.opencv.org/u/cudawarped)\
**Post date:** [June 21, 2022, 5:41pm UTC](https://forum.opencv.org/t/cuda-gpumat-upload-error-doesnt-make-sense/9258/2 "2022-06-21T17:41:48Z")

</div>

I would guess it is because you are using a CUDA stream object created by pycuda not OpenCV. If I use a cuda stream created as:

```auto
stream = cv2.cuda.Stream()

```

I don’t have any issues.

---

<div class="post-metadata">

**Author:** ![Brian\_Mullen](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/brian_mullen/32/5464_2.png) [@Brian\_Mullen](https://forum.opencv.org/u/Brian_Mullen)\
**Post date:** [June 21, 2022, 6:54pm UTC](https://forum.opencv.org/t/cuda-gpumat-upload-error-doesnt-make-sense/9258/3 "2022-06-21T18:54:48Z")

</div>

Yep, that was it. Thanks!
