How to get torch working in python when building from source

username: jasjuang
cooked: <p>Apologize for the potential obvious question here. I am familiar with C++ but not python.</p>
<p>I am able to build and install pytorch 1.3.0 branch successfully by standard procedures like <code>cmake ..</code>, <code>make -j</code>, <code>sudo make install</code>. I am able to link to pytorch for my C++ inference code and everything works as expected. However, I am having trouble getting pytorch to work in python.</p>
<pre><code class="lang-auto">import torch
</code></pre>
<p>shows error <code>ImportError: No module named torch</code></p>
<p>When I build pytorch from source, the cmake option <code>BUILD_PYTHON</code> is set to on, so python related stuff should be built and installed.</p>
<p>I also looked into <a href="https://pytorch.org/get-started/locally/" rel="nofollow noopener">https://pytorch.org/get-started/locally/</a>, and unfortunately the pre-built binaries requires CUDA 10.1 but my environment is currently at CUDA 10.0.</p>
<p>How can I get torch working in python when building from source?</p>

username: ptrblck
cooked: <p>If you want to build PyTorch from source, follow <a href="https://github.com/pytorch/pytorch#from-source" rel="nofollow noopener">these instructions</a>.</p>
<p>Note that you don’t need a local CUDA installation for the binaries, as they will install <code>cudatoolkit</code> from a conda directly. You would just need the NVIDIA driver on your machine.</p>

username: Rishav_Sapahia
cooked: <p>Have you tried installing it via</p>
<pre><code class="lang-auto">https://download.pytorch.org/whl/cu100/torch_stable.html
</code></pre>
<p>Just  do<br>
<code>pip install torch-1.2.0-cp36-cp36m-manylinux1_x86_64.whl</code><br>
1.2 is torch version and cp36 is python 3.6 and it is for x86_64 architecture so I would go to first link and choose the right python version and architecture and then install it.</p>

username: jasjuang
cooked: <p>I am able to make some progress by <code>python setup.py install</code> as indicated in the link. It seems to install some torch related python files locally, <code>import torch</code> now shows different kinds of error, but it seems to be caused by missing packages and I will try to resolve it.</p>
<p>My problem is I need a <code>deb</code> equivalent for python so that I can distribute the build to my other machines. Based on the verbose message of running <code>python setup.py install</code>, the first line shows</p>
<pre><code class="lang-auto">Building wheel torch-1.3.0a0+de394b6
</code></pre>
<p>After some googling, wheel files seems to be the equivalent of <code>deb</code> files for python, which is good news, but the problem is no wheel file is generated. Am I missing something?</p>

username: jasjuang
cooked: <p>Thanks for the pointer. Do you know what is the difference between</p>
<pre><code class="lang-auto">torch-1.3.0%2Bcu100-cp27-cp27m-linux_x86_64.whl
</code></pre>
<p>and</p>
<pre><code class="lang-auto">torch-1.3.0%2Bcu100-cp27-cp27mu-linux_x86_64.whl
</code></pre>
<p>what does the extra <code>u</code> means?</p>

username: jasjuang
cooked: <p>I figured out how to get the pre-built binaries for CUDA 10.0.</p>
<pre><code class="lang-auto">sudo pip install torch==1.3.0+cu100 torchvision==0.4.1+cu100 -f https://download.pytorch.org/whl/torch_stable.html
</code></pre>
<p>This will work for me. Thanks for all the help.</p>

username: bnikolic
cooked: <aside class="quote no-group" data-username="jasjuang" data-post="5" data-topic="59521" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jasjuang/48/13084_2.png" class="avatar"> jasjuang:</div>
<blockquote>
<p>what does the extra <code>u</code> means?</p>
</blockquote>
</aside>
<p>The difference is the way strings are represented: I believe the extra “u” signifies UCS4 coding, as opposed to UCS2. The two versions are incompatible at the binary level (i.e., the “u” is part of the ABI tag)</p>