Hello, In my previous patch which introduced the AV_CUDA_USE_CURRENT_CONTEXT feature I unintentionally made a mistake of not checking this flag when uninitializing the CUDA. It was causing cuda_device_uninit() function to destroy the CUDA context it didn't create. So far it only reproduces under cuda compute sanitizer: ========= COMPUTE-SANITIZER ========= Program hit invalid device context (error 201) on CUDA API call to cuCtxDestroy_v2. But nonetheless shall be fixed. Please find a fix in attached file, now cuCtxDestroy is called under condition.