Skip to content

cuda 13.0 compatibility #27636

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

Merged
merged 3 commits into from
Aug 11, 2025
Merged

cuda 13.0 compatibility #27636

merged 3 commits into from
Aug 11, 2025

Conversation

jmackay2
Copy link
Contributor

@jmackay2 jmackay2 commented Aug 6, 2025

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Issue

CUDA 13 deprecated some fields, resulting in build failures with CUDA 13. This updates to use the replacement API.
The reference to the deprecated features is here: https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#id6

Testing

This was testing by building on the following configurations:
OS: Ubuntu 24.04
CUDA: 12.9, 13.0

@asmorkalov asmorkalov added category: build/install category: gpu/cuda (contrib) OpenCV 4.0+: moved to opencv_contrib labels Aug 6, 2025
@asmorkalov asmorkalov self-requested a review August 6, 2025 12:29
Copy link
Contributor

@cudawarped cudawarped left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked when cudaDeviceGetTexture1DLinearMaxWidth and all the device attributes returned by cudaDeviceGetAttribute were introduced in case you need to add CUDA_VERSION checks?

All calls should be wrapped with cudaSafeCall( )

cudaError_t clockRateErr = cudaDeviceGetAttribute(&clockRate, cudaDevAttrClockRate, dev);
if (clockRateErr == cudaSuccess)
{
printf(" GPU Clock Speed: %.2f GHz\n", prop.clockRate * 1e-6f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modules\core\src\cuda_info.cpp(951): error C2039: 'clockRate': is not a member of 'cudaDeviceProp'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -531,7 +537,10 @@ int cv::cuda::DeviceInfo::maxTexture1D() const
#ifndef HAVE_CUDA
throw_no_cuda();
#else
return deviceProps().get(device_id_)->maxTexture1D;
Copy link
Contributor

@cudawarped cudawarped Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxTexture1DLinear has been depreciated not maxTexture1D

See

opencv\modules\core\src\cuda_info.cpp(566): error C2039: 'maxTexture1DLinear': is not a member of 'cudaDeviceProp'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I messed that up. Thanks for pointing it out. Fixed.

@jmackay2
Copy link
Contributor Author

jmackay2 commented Aug 7, 2025

Have you checked when cudaDeviceGetTexture1DLinearMaxWidth and all the device attributes returned by cudaDeviceGetAttribute were introduced in case you need to add CUDA_VERSION checks?

All calls should be wrapped with cudaSafeCall( )

I went through cuda documentation. cudaDeviceGetTexture1DLinearMaxWidth only shows up in Cuda 13 documentation, so I wrapped that in a CUDA_VERSION check. All of the device attributes returned by cudaDeviceGetAttribute go back to at least cuda 8, which is the oldest online cuda api documentation available.

@cudawarped
Copy link
Contributor

cudaDeviceGetTexture1DLinearMaxWidth only shows up in Cuda 13 documentation

It looks like this was added in CUDA Toolkit 11.1.0?

@jmackay2
Copy link
Contributor Author

jmackay2 commented Aug 8, 2025

cudaDeviceGetTexture1DLinearMaxWidth only shows up in Cuda 13 documentation

It looks like this was added in CUDA Toolkit 11.1.0?

You are right. Would you prefer the cuda version check to be for when it was deprecated or when the function was introduced?

@cudawarped
Copy link
Contributor

You are right. Would you prefer the cuda version check to be for when it was deprecated or when the function was introduced?

I think when depreciated as you have it will work.

Copy link
Contributor

@cudawarped cudawarped left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@asmorkalov asmorkalov added this to the 4.13.0 milestone Aug 11, 2025
@asmorkalov asmorkalov merged commit f0888a1 into opencv:4.x Aug 11, 2025
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants