When I build pytorch from source, The generated torch/version.py file has a weird version number which I think is wrong.
I first clone pytorch like this git clone --depth 1 --branch v2.0.1 https://github.com/pytorch/pytorch
Then I follow the instructions here: GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration
to build from source. The problem is the installed wheels have a generated version.py like this:
__version__ = '2.0.0a0+gite9ebda2'
debug = False
cuda = '11.8'
git_version = 'e9ebda29d87ce0916ab08c06ab26fd3766a870e5'
hip = None
This is a problem because next, I want to test it however the test application requires torchvision. So I use pip to install the latest version which is allowed to work with the latest pytorch, but it sees version 2.0.0 even though I’ve checked out tag v2.0.1, thus it overwrites my installed pytorch which I built from scratch with its own 2.0.1 from pypi.
Inspecting the CMakeLists.txt
file, I see the version.py
is generated with the tool tool/generate_torch_version.py
. Looking at this code, there seems to be a section meant to look at git tags and grab the version from there, but debugging shows that code section isn’t working, and the regex isn’t matching anything.
I then discovered PYTORCH_BUILD_VERSION
and PYTORCH_BUILD_NUMBER
environment variables which are also mentioned in setup.py
as used to make pytorch builds for release.
Thus my question is: Is PYTORCH_BUILD_VERSION
and PYTORCH_BUILD_NUMBER
actually the accepted method for making pytorch builds of a particular version? or have I done something incorrect?