BufferPool.getBuffer report "Unknown C++ exception from OpenCV code" in python

I cant use getBuffer in python

In python report cv2.error: Unknown C++ exception from OpenCV code

import cv2


cv2.cuda.setBufferPoolUsage(True)
cv2.cuda.setBufferPoolConfig(cv2.cuda.getDevice(), 1024 * 1024 * 64, 2)

stream_a = cv2.cuda.Stream()
stream_b = cv2.cuda.Stream()
pool_a = cv2.cuda.BufferPool(stream_a)
pool_b = cv2.cuda.BufferPool(stream_a)
pool_a.getBuffer(1024, 1024, cv2.CV_8UC3)

In c++, it works

#include "opencv2/core/mat.hpp"
#include "opencv2/core/cuda.hpp"


using namespace std;


int main()
{

    cv::cuda::setBufferPoolUsage(true);
    cv::cuda::setBufferPoolConfig(cv::cuda::getDevice(), 1024 * 1024 * 64, 2);

    cv::cuda::Stream streamA, streamB;
    cv::cuda::BufferPool poolA(streamA), poolB(streamB);
    
    cv::cuda::GpuMat im_source_bgr = poolA.getBuffer(1024, 1024, CV_8UC3);
    cv::cuda::GpuMat im_search_bgr = poolB.getBuffer(1024, 1024, CV_8UC3);

    cv::cuda::GpuMat im_source = poolA.getBuffer(1024, 1024, CV_8UC3);
    cv::cuda::GpuMat im_search = poolB.getBuffer(1024, 1024, CV_8UC3);

    return 0;
}