Installing pytorch on raspberry pi 3

jacobcvt12: <p>Any easy/less painful ways of installing pytorch on a raspberry pi than <code>python setup.py build</code> with the source?</p>

Howlshigh: <p>I’m not too sure, have tried using pip3, and keep getting the ‘not supported on this platform’ error. I have got 64bit arch software, and the raspi 3 is 64 arch hardware, so I am as baffled as you.</p>
<p>Did you manage to get it working?</p>

ptrblck: <p>You could try to build from source, as I’m not sure if someone published arm binaries of PyTorch.<br>
Even though the RPi uses a 64bit CPU, the architecture differs from the official binaries (x86).</p>

Howlshigh: <p>I’ve been trying to build from source for the past month, it’s a very painful experience, mainly because of raspi not releasing 64 bit software, I have been using ubuntu server 64bit for aarm but, after a month of constant trial and error, it’s becoming a project I’m tiring of, and was hoping someone might have had more success.<br>
Still, I have reduced the amount of errors I am having by almost half, so I guess I’m doing something right <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

ptrblck: <p>Oh that doesn’t sound like a good experience. <img src="https://discuss.pytorch.org/images/emoji/apple/confused.png?v=9" title=":confused:" class="emoji" alt=":confused:"><br>
What kind of errors do you get?</p>

Howlshigh: <p>Good question, I am currently re-installing my backup image of the last stable state of the SD card, and then shall compile again, and record the feedback for you.</p>
<p>Okay so far I have this, right at the beginning</p>
<p>[  0%] Building C object confu-deps/pthreadpool/CMakeFiles/pthreadpool.dir/src/threadpool-pthreads.c.o<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c: In function ‘clog_vlog_fatal’:<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c:120:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]<br>
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c: In function ‘clog_vlog_error’:<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c:196:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]<br>
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c: In function ‘clog_vlog_warning’:<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c:272:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]<br>
write(STDERR_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c: In function ‘clog_vlog_info’:<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c:348:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]<br>
write(STDOUT_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c: In function ‘clog_vlog_debug’:<br>
/home/ubuntu/pytorch/third_party/QNNPACK/deps/clog/src/clog.c:424:4: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]<br>
write(STDOUT_FILENO, out_buffer, prefix_chars + format_chars + CLOG_SUFFIX_LENGTH);<br>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p>
<p>Which has confused me a little, as I set environments as follows:</p>
<p>export NO_CUDA=1<br>
export NO_DISTRIBUTED=0<br>
export NO_MKLDNN=1<br>
export NO_NNPACK=1<br>
export NO_QNNPACK=1</p>

Howlshigh: <p>Okay, it’s 48 hours in to compiling, and at 92%, but I’m getting many warnings about deprecation, and the dangerous use of tmpnam, and that I should be using mkstemp, but these are things I have no control over, correct?</p>

Howlshigh: <p>This is the error I recieved during the night</p>
<p>[ 92%] Building CXX object test_api/CMakeFiles/test_api.dir/dataloader.cpp.o<br>
caffe2/CMakeFiles/op_registration_test.dir/build.make:62: recipe for target ‘caffe2/CMakeFiles/op_registration_test.dir/__/aten/src/ATen/core/op_registration/op_registration_test.cpp.o’ failed<br>
CMakeFiles/Makefile2:3922: recipe for target ‘caffe2/CMakeFiles/op_registration_test.dir/all’ failed</p>
<p>[ 93%] Built target test_api<br>
Makefile:140: recipe for target ‘all’ failed<br>
Building wheel torch-1.3.0a0+c2549cb<br>
– Building version 1.3.0a0+c2549cb<br>
cmake -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/ubuntu/pytorch/torch -DCMAKE_PREFIX_PATH=/usr/lib/python3/dist-packages -DNUMPY_INCLUDE_DIR=/home/ubuntu/.local/lib/python3.6/site-packages/numpy/core/include -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib/libpython3.6m.so.1.0 -DTORCH_BUILD_VERSION=1.3.0a0+c2549cb -DUSE_CUDA=False -DUSE_DISTRIBUTED=True -DUSE_NUMPY=True /home/ubuntu/pytorch<br>
cmake --build . --target install --config Release – -j 4</p>

Winston_Fan: <p>hi <a class="mention" href="/u/howlshigh">@Howlshigh</a> have you managed to get it done?</p>

Howlshigh: <p>No, unfortunately not, the deprecation warnings became to much. I will try it again later.</p>

tom: <p>I published <a href="http://mathinf.com/pytorch/arm64/" rel="nofollow noopener">ARM64 binaries</a> of PyTorch compiled on the Raspberry  (I actually compiled 1.4, too, just didn’t upload yet). You would need a 64bit distribution (eg Debian for the Raspberry Pi 3) or a 64 bit kernel from the Raspberry Inc and arm64 chroot.</p>
<p>There also are <a href="https://discuss.pytorch.org/t/pytorch-1-3-wheels-for-raspberry-pi-python-3-7/58580">ARM32 binaries</a> from <a class="mention" href="/u/leviviana">@LeviViana</a> . At least in September, some things like JIT tracing didn’t work when I built on ARM32, Levi would know if he fixed it or it’s still open.</p>
<p>Best regards</p>
<p>Thomas</p>

Howlshigh: <p>I have been using Ubuntu Server 18.10 ARM64, and was constantly warned over deprecations within the build. I find a testament to the lack of foresight in Raspberry Pi that they refuse to make an ARM64 architecture software, because of earlier 32 bit Pi models still in use.<br>
But in saying that, it does provide a challenge which is half the fun, but double the frustration.</p>

LeviViana: <p>Indeed I did some quick fixes last year to get torch 1.3 compiled on RPI. However, all the unit tests didn’t pass (this is why I didn’t event try a PR or something), but the main commonly used torch functions are working just as they should. I can make some digging and find out what I did last year, but I got no time for this right now <img src="https://discuss.pytorch.org/images/emoji/apple/frowning.png?v=9" title=":frowning:" class="emoji" alt=":frowning:">, moreover, I think it doesn’t matter that much.</p>
<p>I’ll probably do the same for torch 1.4 in the coming weeks or months.</p>

LeviViana: <p>I just compiled torch 1.4, you’ll find the wheels here:</p>
<p><a href="https://wintics-opensource.s3.eu-west-3.amazonaws.com/torch-1.4.0a0%2B7963631-cp37-cp37m-linux_armv7l.whl" class="onebox" target="_blank" rel="nofollow noopener">https://wintics-opensource.s3.eu-west-3.amazonaws.com/torch-1.4.0a0%2B7963631-cp37-cp37m-linux_armv7l.whl</a></p>
<p>Have fun !</p>

Howlshigh: <p>Thanks, I will give them a shot later <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>

louisabraham: <p>Could you provide build instructions? I get some nasty compilation errors (<a href="https://github.com/pytorch/pytorch/issues/35049" rel="nofollow noopener">https://github.com/pytorch/pytorch/issues/35049</a>)</p>

crytoy: <p>did the wheels by LeviViana work?</p>

crytoy: <p>LeviViana how did you compile?<br>
what options did you set?</p>

LeviViana: <p>I hope <a href="https://discuss.pytorch.org/t/pytorch-1-3-wheels-for-raspberry-pi-python-3-7/58580/8">this post</a> will help you out !</p>

choonkiatlee: <p>Just in case its helpful, I’ve also compiled a version of torch 1.4 and torchvision 0.5 for the Raspberry Pi (Tested with an RPi 3B). These wheels have the NEON optimisations enabled, and can support the new torch jit functionality also.</p>
<p>You can find the wheels here:<br>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="16" height="16">
      <a href="https://github.com/choonkiatlee/pi-torch" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars0.githubusercontent.com/u/26285364?s=400&amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/choonkiatlee/pi-torch" target="_blank" rel="nofollow noopener">choonkiatlee/pi-torch</a></h3>

<p>Contribute to choonkiatlee/pi-torch development by creating an account on GitHub.</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>
<p>and the docker images I used to compile these wheels here:<br>
<aside class="onebox whitelistedgeneric">
  <header class="source">
      <img src="https://github.githubassets.com/favicons/favicon.svg" class="site-icon" width="16" height="16">
      <a href="https://github.com/choonkiatlee/qemu-raspbian" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars0.githubusercontent.com/u/26285364?s=400&amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/choonkiatlee/qemu-raspbian" target="_blank" rel="nofollow noopener">choonkiatlee/qemu-raspbian</a></h3>

<p>Contribute to choonkiatlee/qemu-raspbian development by creating an account on GitHub.</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>
</p>