Why doesn't PyTorch have a universal installation mechanism like TensorFlow's 'pip install tensorflow'?

username: ellie-misaki
cooked: <p>I have a question regarding the installation mechanism of PyTorch and the differences it has compared to TensorFlow. I have noticed that TensorFlow can be easily installed from PyPI using the command <code>pip install tensorflow</code>, regardless of whether it is the CPU or CUDA version. However, PyTorch seems to have a different approach. I would like to understand the reasons behind this difference.</p>
<p>Is the decision to not implement a similar installation mechanism in PyTorch due to technical challenges or a deliberate choice made by the developers? I am curious to know the factors that led to this divergence and the implications it may have for users.</p>
<p>Btw, I am using mono repo to manage my projects, so lock files are necessary for me. However, generating lock files for PyTorch becomes quite cumbersome due to the requirement of calculating hashes each time. This is why I am particularly interested in seeking an answer to this question.</p>

username: ptrblck
cooked: <aside class="quote no-group" data-username="ellie-misaki" data-post="1" data-topic="181787">
<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/ellie-misaki/48/59333_2.png" class="avatar"> ellie-misaki:</div>
<blockquote>
<p>However, PyTorch seems to have a different approach.</p>
</blockquote>
</aside>
<p>PyTorch uses a similar install command for the “default” wheels via <code>pip install torch</code> as mentioned in the <a href="https://pytorch.org/get-started/locally/">install matrix</a> and I’m unsure which difference you are trying to point out.</p>

username: ellie-misaki
cooked: <p>Thank you for your response.</p>
<p>Unlike TensorFlow, which only requires the ‘pip install tensorflow’ command for installation regardless of the device’s CUDA compatibility (after version 1.15), without the need for practices like ‘–index-url <a href="https://download.pytorch.org/whl/cu118" rel="noopener nofollow ugc">https://download.pytorch.org/whl/cu118</a>’, PyTorch’s installation process is different.</p>
<p>I understand that this difference doesn’t pose any challenges when using pip alone. However, in the case of using environment managers such as Poetry or PDM (which I use) with a lockfile, the need to download and calculate hashes for the large packages from the third-party index can become burdensome.<br>
I would like to know the reason behind PyTorch not bundling the CUDA dependency together, similar to TensorFlow.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.tensorflow.org/install/gpu?hl=ja#pip_package">
  <header class="source">
      <img src="https://www.gstatic.com/devrel-devsite/prod/v5352c76a61023ba6abb02944a7cc6c9587eaa549f6c24b7a02aa7c55bb3cc8bd/tensorflow/images/favicon.png" class="site-icon" width="32" height="32">

      <a href="https://www.tensorflow.org/install/gpu?hl=ja#pip_package" target="_blank" rel="noopener nofollow ugc">TensorFlow</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/388;"><img src="https://www.tensorflow.org/static/images/tf_logo_social.png?hl=ja" class="thumbnail" width="690" height="388"></div>

<h3><a href="https://www.tensorflow.org/install/gpu?hl=ja#pip_package" target="_blank" rel="noopener nofollow ugc">GPU サポート  |  TensorFlow</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


username: ellie-misaki
cooked: <p>there is an open issue on Poetry’s GitHub repository that has been discussing how to install PyTorch for the past two years: <a href="https://github.com/python-poetry/poetry/issues/6409" class="inline-onebox" rel="noopener nofollow ugc">Instructions for installing PyTorch · Issue #6409 · python-poetry/poetry · GitHub</a>. I believe this demonstrates the difficulties encountered when using PyTorch with package management tools.</p>

username: ptrblck
cooked: <p>PyTorch’s install commands differ for the non-default binaries while the default ones (currently <code>2.0.1+cu117</code>) are installed via a simple <code>pip install torch</code> command.<br>
This command will download all necessary CUDA runtime dependencies and will allow you to directly execute any PyTorch workload on your GPU without the need to install any other CUDA dependencies such as the CUDA toolkit.</p>
<p>Correct me if I’m missing something, but according to <a href="https://www.tensorflow.org/install/pip#linux">these TensorFlow install instructions</a> you are supposed to:</p>
<ul>
<li>download and install <code>conda</code> first</li>
<li>install a <code>cudatoolkit</code> from <code>conda-forge</code></li>
<li>install <code>cudnn</code> and <code>tensorflow</code> from PyPI</li>
<li>create custom folders</li>
<li>move env variables to your conda environment</li>
<li><code>source</code> the newly installed environment</li>
</ul>
<p>while the CPU-only version only requires <code>pip install tensorflow</code>.</p>
<aside class="quote no-group" data-username="ellie-misaki" data-post="1" data-topic="181787">
<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/ellie-misaki/48/59333_2.png" class="avatar"> ellie-misaki:</div>
<blockquote>
<p>Is the decision to not implement a similar installation mechanism in PyTorch due to technical challenges</p>
</blockquote>
</aside>
<p>The opposite is the case. We are making sure that no other CUDA requirements are needed and that each command installs the desired PyTorch version with all needed CUDA depndencies.<br>
Only if you are building from source or a custom CUDA extension would a locally installed CUDA toolkit be needed.</p>

username: ellie-misaki
cooked: <p>Thank you for your response.<br>
May I ask another question? Why is the default installation behavior different between Windows and Linux?</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://pytorch.org/get-started/locally/#:~:text=Compute%20Platform-,Run%20this%20Command%3A,-Stable%20(2.0.1)">
  <header class="source">
      <img src="https://pytorch.org/favicon.ico?" class="site-icon" width="32" height="32">

      <a href="https://pytorch.org/get-started/locally/#:~:text=Compute%20Platform-,Run%20this%20Command%3A,-Stable%20(2.0.1)" target="_blank" rel="noopener nofollow ugc">pytorch.org</a>
  </header>

  <article class="onebox-body">
    <img src="https://pytorch.org/assets/images/pytorch-logo.png" class="thumbnail onebox-avatar" width="500" height="500">

<h3><a href="https://pytorch.org/get-started/locally/#:~:text=Compute%20Platform-,Run%20this%20Command%3A,-Stable%20(2.0.1)" target="_blank" rel="noopener nofollow ugc">PyTorch</a></h3>

  <p>An open source machine learning framework that accelerates the path from research prototyping to production deployment.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


username: ptrblck
cooked: <p>A few dependencies could be missing for Windows on PyPI, but that’s my guess. However, due to the low number of Windows users the priority to host the PyTorch wheels with CUDA support on PyPI might be lower.</p>