Is there a slimmed down pytorch for computation?

xiaodai: <p>We developed a neural network in PyTorch and when we try to deploy we had to include PyTorch in the docker image. Backend team complains that PyTorch is “too heavy”. Is there a fast pkg out there that can carry out the computation of a neural network developed by Pytorch?</p>

smth: <p>we provide a <code>cpuonly</code> version of PyTorch without the CUDA functionality, and it is significantly smaller in size (about 5x smaller).</p>
<p>To install it go to <a href="https://pytorch.org">https://pytorch.org</a> and in the Install Selector, select <code>CUDA</code> to be <code>None</code>.</p>
<p>Hopefully your backend team is happy with this version.</p>

xiaodai: <p>Thank you very much! Do you see a possibility of separating out the functionality to run a NN into a separate tiny package that only runs the models? That would be really awesome for deployment.</p>
<p>Thanks again for your help?</p>

smth: <p>we actually provide something like that (a runtime that is ~5MB or lesser), but for Mobile only at the moment, i.e. for iOS / Android: <a href="https://pytorch.org/mobile/home/">https://pytorch.org/mobile/home/</a></p>

smth: <p>part of the challenge when you run on Desktop / Server is not so much the size of PyTorch, but the size of depedencies that make deployment also efficient.</p>
<p>On x86 CPU, you will want Intel MKL and MKLDNN (which PyTorch install provides) which themselves are ~70MB and ~50+MB respectively. They are used for fast matrix multiplications and neural network operations.</p>
<p>on GPU, you will want CUDA and CuDNN, which take about 2GB</p>

xiaodai: <p>Someone on twitter suggested the onnxruntime might be worth looking into</p>
<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/microsoft/onnxruntime" target="_blank" rel="nofollow noopener">GitHub</a>
  </header>
  <article class="onebox-body">
    <img src="https://avatars2.githubusercontent.com/u/6154722?s=400&amp;v=4" class="thumbnail onebox-avatar" width="60" height="60">

<h3><a href="https://github.com/microsoft/onnxruntime" target="_blank" rel="nofollow noopener">microsoft/onnxruntime</a></h3>

<p>ONNX Runtime: cross-platform, high performance scoring engine for ML models - microsoft/onnxruntime</p>


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

<p>including here for ppl stumbling upon this.</p>

suryaprakaz: <p><a class="mention" href="/u/smth">@smth</a> PyTorch could consider shipping with custom builds of MKL libraries that strip out unwanted features. If that happens, most don’t have to go search for an optimized inference engine</p>

smth: <p>in the pytorch CPU-only wheels, we actually do statically link MKL and MKLDNN so that the unneeded symbols are stripped out, hence their respective sizes.</p>
<p>The reality is, whether you use ONNX Runtime or PyTorch wheel, if you want MKL and MKLDNN, you will pay the cost of the size of the routines they ship, and their BLAS routines and their Convolution routines are large (they ship a lot of precompiled codegen).</p>
<p>The PyTorch CPU-only wheel today ships at a size of 127.3MB for PyTorch 1.5.0</p>

suryaprakaz: <p>Transitioning from MKLDNN to a Glow CPU backend would be great!</p>

smth: <p>then we have to include precompiled Glow code?</p>