Error converting GpuMat to Texture2D

Hi everyone! I’m trying to convert a GpuMat (3 channels, CV_8U format) to a texture. I’m doing this:

cv::ogl::Texture2D tex;

The code compiles but I get this error at run time.
OpenCV(4.5.1) Error: Gpu API call (OS call failed or operation not supported on this OS) in 'anonymous-namespace'::CudaResource::registerBuffer, file C:\lib\opencv-4.5.1\modules\core\src\opengl.cpp, line176

More Info
OpenCV Version: 4.5.1, with CUDA and OpenGL, x64
Cuda Version: 10.1
Graphics card: GTX1650
Visual Studio 2017

Does anyone know why this is? Thanks!