the cv::cuda::transpose crash when CV_32F rows exceed 1048560
Open
Nobody has claimed this yet.
bug
category: gpu/cuda (contrib)
- Dominant language
- C++
- Stars
- 90.9k
- Forks
- 57k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 112
Description
System Information
OpenCV: 4.10.0
compiler: clang 17.0.6
Platform: almalinux9
cuda sdk: 12.3
Detailed description
exception message: OpenCV(4.10.0) opencv-4.10.0/contrib/modules/cudev/include/opencv2/cudev/grid/detail/transpose.hpp:118: error: (-217:Gpu API call) invalid configuration argument in function 'transpose
Steps to reproduce
for (int i = 1048555; i <= 1048561; i += 1)
{
cv::Mat src(i, 4, CV_32F, cv::Scalar{2});
cv::Mat dst;
cv::RNG rng{};
rng.fill(
src,
cv::RNG::UNIFORM,
0,
200
);
// CPU works
cv::transpose(src, dst);
// GPU works
cv::cuda::GpuMat d_src(src);
cv::cuda::GpuMat d_dst;
cv::cuda::GpuMat d_dst2{src.cols, src.rows, src.type(), cv::Scalar{10}};
std::cout << cv::cuda::sum(d_src) << "| " << cv::cuda::sum(d_dst2) << std::endl;
cv::cuda::transpose(d_src, d_dst);
cv::cuda::transpose(d_src, d_dst2);
std::cout << cv::cuda::sum(d_src) << "| " << cv::cuda::sum(d_dst) << "| " << cv::cuda::sum(d_dst2) << std::endl;
// Check results
bool passed = cv::norm(dst - cv::Mat(d_dst), cv::NORM_INF) < 1e-3;
bool passed2 = cv::norm(dst - cv::Mat(d_dst2), cv::NORM_INF) < 1e-3;
std::cout<< "i=" << i << " dst without memory initalized:" << (passed ? "passed" : "FAILED") << std::endl;
std::cout<< "i=" << i << "dst with memory initalized:" << (passed2 ? "passed" : "FAILED") << std::endl;
// Deallocate data here, otherwise deallocation will be performed
// after context is extracted from the stack
d_src.release();
d_dst.release();
d_dst2.release();
std::cout << "released\n";
}
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at contrib/modules/cudev/include/opencv2/cudev/grid/detail/transpose.hpp:118 and reproduce the failure with the supplied C++ loop using cv::cuda::transpose on CV_32F matrices around 1,048,560 rows. Done means the boundary sizes no longer raise an invalid configuration argument and both destination paths match the CPU transpose result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100