Build and compile Pytorch

Francesco_C: <p>Good morning</p>
<p>are there some recent and in-depth (step-by-step) guides on build and compiling Pytorch on Ubuntu?<br>
I’have followed <a href="https://github.com/pytorch/pytorch#from-source" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration</a> but perhaps it requires some knowledge that I don’t known (I’m “middle” user of Ubuntu… I’m never compiled anything!).</p>
<p>Or it exists some general guides but with very similar passages?<br>
I have done a lot of proofs of pytorch compiling but I have received many errors.<br>
For example it said me to have installed pytorch1.9 (why not 1.8?) in conda evniroment where I have builded it (and I make also “conda list” to check version), but when I make print pytorch version it writes pytorch 1.5…<br>
And this version works, but it gives smaller accuracy (-20%) of pytorch 1.8.</p>
<p>I don’t understand why… <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=9" title=":frowning:" class="emoji" alt=":frowning:"></p>
<p>Thank you</p>

ptrblck: <aside class="quote no-group" data-username="Francesco_C" data-post="1" data-topic="115197">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/letter_avatar_proxy/v4/letter/f/e274bd/48.png" class="avatar"> Francesco_C:</div>
<blockquote>
<p>For example it said me to have installed pytorch1.9 (why not 1.8?) in conda evniroment where I have builded it (and I make also “conda list” to check version), but when I make print pytorch version it writes pytorch 1.5…</p>
</blockquote>
</aside>
<p>A source build would currently show <code>1.9.0a+commit</code>, since it’s the version <em>after</em> the <code>1.8.0</code> release and is moving towards <code>1.9</code>, so that’s expected.<br>
If your environment shows <code>1.5</code>, then you have most likely installed multiple PyTorch versions in the same environment (via conda, pip, or a source build) and would need to either remove the others or create a new environment and build PyTorch from source there.</p>

Francesco_C: <p>First, Thanks for your response <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"> (I always have used your tips and hints on this forum in the past)<br>
I’m sure that it’s happened as you said, but I don’t know how it’s possible… anyway I will try to format and redo from beginning.</p>
<p>In any case, which is the best walkthrough could you suggest to help me with my build_and_compile problem?<br>
Do you know some guide more detailed?<br>
I really would to learn it <img src="https://discuss.pytorch.org/images/emoji/apple/muscle.png?v=9" title=":muscle:" class="emoji" alt=":muscle:"><br>
Thank you!</p>

ptrblck: <p>I would start with a new and clean conda virtual environment, clone the repository and update all submodules:</p>
<pre><code class="lang-python">git clone --recursive https://github.com/pytorch/pytorch
</code></pre>
<p>and install it using the already posted build instructions.<br>
If you see any issues with the build, just post an update here (with the error message from the logs) and we can check what’s wrong.<br>
In case you have some trouble with finding some CUDA libs during the build process, you could also try to use a docker container with an installed CUDA toolkit first and check the installation inside it.</p>