I’ve installed OpenCV with the script available here in a virtual environment. Although the installation was completed successfully, OpenCV is not included in the list of packages but I’m able to import cv2. I’ve also built PyTorch from source following the instruction from this thread, setting the PyTorch version to 2.0.0. Both the OpenCV and the PyTorch seem to be working with CUDA (see attached).
IIRC, when building torchvision, it uses this cpp_extension.py file from PyTorch. As opposed to entirely rebuilding PyTorch, you could try the fix first by editing your installed version of the file (for example, mine is located at /usr/local/lib/python3.8/dist-packages/torch/utils/cpp_extension.py)
No I don’t believe it should, you might need to slightly adapt that patch to your version of PyTorch though if the underlying sources have changed (for that reason, typically I always apply these patches by hand)