From 8a2903c190fd41b2ac4255c436fddf1dd58dacde Mon Sep 17 00:00:00 2001 From: ruisv <27017322+ruisv@users.noreply.github.com> Date: Tue, 6 May 2025 23:47:12 +0800 Subject: [PATCH] =?UTF-8?q?CUDA=E2=80=AF12.9=20support:=20build=E2=80=AFNp?= =?UTF-8?q?pStreamContext=E2=80=AFmanually?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/include/opencv2/core/private.cuda.hpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/private.cuda.hpp b/modules/core/include/opencv2/core/private.cuda.hpp index 39f2ddcdeb3d..a9029131fbfa 100644 --- a/modules/core/include/opencv2/core/private.cuda.hpp +++ b/modules/core/include/opencv2/core/private.cuda.hpp @@ -147,7 +147,23 @@ namespace cv { namespace cuda inline explicit NppStreamHandler(cudaStream_t newStream) { nppStreamContext = {}; - nppSafeCall(nppGetStreamContext(&nppStreamContext)); + #if CUDA_VERSION < 12090 + nppSafeCall(nppGetStreamContext(&nppStreamContext)); + #else + int device = 0; + cudaSafeCall(cudaGetDevice(&device)); + + cudaDeviceProp prop{}; + cudaSafeCall(cudaGetDeviceProperties(&prop, device)); + + nppStreamContext.nCudaDeviceId = device; + nppStreamContext.nMultiProcessorCount = prop.multiProcessorCount; + nppStreamContext.nMaxThreadsPerMultiProcessor = prop.maxThreadsPerMultiProcessor; + nppStreamContext.nMaxThreadsPerBlock = prop.maxThreadsPerBlock; + nppStreamContext.nSharedMemPerBlock = prop.sharedMemPerBlock; + nppStreamContext.nCudaDevAttrComputeCapabilityMajor = prop.major; + nppStreamContext.nCudaDevAttrComputeCapabilityMinor = prop.minor; + #endif nppStreamContext.hStream = newStream; cudaSafeCall(cudaStreamGetFlags(nppStreamContext.hStream, &nppStreamContext.nStreamFlags)); }