How to build torch as a pip wheel?

I recently submitted a pull request, managed to build and test it locally by copy-pasting some commands from a blog online, but I’d like to test my modifications more thoroughly on another machine. Unfortunately I am unable to build a wheel that is portable and complete (libc++ ABI version mismatch, cuda libraries are not pulled or found, etc.).

There are many different instructions online, none seem up to date or complete. The pytorch/builder repo has dozens of different scripts to build pytorch.

I’d like instructions on:

  • how to generate a clean build environment (in a container without the need for GPU preferably)
  • which environment variables and commands I should run to build a portable wheel package similar to the official release (cuda 11.7).