Not able to use Nvidia Hardware Accelerated Optical Flow in Opencv Python

I built both OpenCV and OpenCV-contrib from source using CMake-GUI to use the NVIDIA OpticalFlow SDK for Python through OpenCV.
I’m using a Windows 10 machine with an RTX 2070 GPU.
Cuda Toolkit version 10.1.243
CuDNN - 10.2
Python version - 3.8

nvof = cv.cuda_NvidiaOpticalFlow_1_0.create(256, 256, 5, False, False, False, 0)

throws the following error -

AttributeError: module ‘cv2’ has no attribute ‘cuda_NvidiaOpticalFlow_1_0’

This is my first time posting a question here, so kindly forgive me for my mistakes. Thanks in Advance.

You may check which opencv version is used by your python install:

import cv2
print(cv2.getBuildInformation())

Hey @Honey_Patouceul, thank you for the reply. I sorted the problem out. I tried to calculate flow for an RGB image whose pitch value might be out of range for my GPU. Hence the issue. I’ve changed it to grayscale and it worked.