Building PyTorch from source fails

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).

I’m trying to install torchvision 0.15.1 with these instructions setting the branch to v0.15.1 and the BUILD_VERSION=0.15.1.

When running

python3 install --user

I get the following error

ValueError: Unknown CUDA arch (8.7+PTX) or GPU not supported

Any idea why this is happening and how I could solve it?


Hi @christina.malliou, I wonder if you need to apply this patch to PyTorch which enables SM_87:

IIRC, when building torchvision, it uses this 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/

Does it matter that I have installed the jetpack 5.1?

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)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.