How to build from source code without trailing torch-1.8.0a0+gitf2a38a0 version

aviezab: <p>Dear Forum,<br>
I am finished compile from source with the following command:</p>
<blockquote>
<p>python setup.py install</p>
</blockquote>
<p>or</p>
<blockquote>
<p>python setup.py bdist_wheel</p>
</blockquote>
<p>but the version is torch-1.8.0a0+gitf2a38a0 not torch-1.8.0 only.</p>
<p>This made the torchvision can’t be installed since pip only can detect the number only.</p>
<p>Here are the pics<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/7/67451e3820385c2fdeb83d4e9fc07c30ff867912.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/67451e3820385c2fdeb83d4e9fc07c30ff867912" title="torch_error2"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/6/7/67451e3820385c2fdeb83d4e9fc07c30ff867912_2_690x85.jpeg" alt="torch_error2" data-base62-sha1="eJzgnw3ybzxcz8U8hC9o1RyAtoK" width="690" height="85" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/6/7/67451e3820385c2fdeb83d4e9fc07c30ff867912_2_690x85.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/6/7/67451e3820385c2fdeb83d4e9fc07c30ff867912_2_1035x127.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/6/7/67451e3820385c2fdeb83d4e9fc07c30ff867912_2_1380x170.jpeg 2x" data-dominant-color="0C0C0C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">torch_error2</span><span class="informations">1478×184 50.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>Might <a class="mention" href="/u/glaringlee">@glaringlee</a> can help? Thanks</p>

jbschlosser: <p>You can hard-code the version in <code>setup.py</code> as a workaround. In my setup.py, it’s on line 295:</p>
<pre><code class="lang-python">version = get_torch_version()
</code></pre>
<p>Change this to:</p>
<pre><code class="lang-python">version = "1.8.0"
</code></pre>
<p>and re-run the installation command.</p>

ptrblck: <p>The desired <code>torchvision</code> wheel requires the PyTorch <code>1.8.0</code> release, while you are using a commit from the master branch before <code>1.8.0</code> was cut.<br>
You could either also use an older <code>torchvision</code> commit and build it from source or alternatively you could <code>git checkout v1.8.0</code> and build the PyTorch release version from source.</p>

aviezab: <p><a class="mention" href="/u/jbschlosser">@jbschlosser</a> <a class="mention" href="/u/ptrblck">@ptrblck</a> great answers.<br>
both working as desired, thanks all!</p>

Virajika: <p>export the PYTORCH_BUILD_VERSION to the required version instead of hardcoding. In your case, export PYTORCH_BUILD_VERSION=1.8.0</p>

ptrblck: <p>Note that setting <code>PYTORCH_BUILD_VERSION</code> could be used to specify the reported version returned by <code>torch.__version__</code>, but you would of course still use the pre-release commit instead of the “stable” release branch.<br>
I’m mentioning it, as this could create really confusing environment where debugging might be hard since your reported version does not match the actual code.</p>

Virajika: <p>Yes, <a class="mention" href="/u/ptrblck">@ptrblck</a>. What you said is entirely accurate. If one is using a stable release branch and need a clean version of the torch then one can export the PYTORCH_BUILD_VERSION based on the release tag.</p>