CUDA dependency make Docker Image bloated

username: cin-xing
cooked: <p>According to <a href="https://hub.docker.com/r/pytorch/pytorch/tags" rel="noopener nofollow ugc">Docker hub</a> , the Docker image size increased from 2.76GB (1.12.1) to 5.29 GB (1.13.0).</p>
<p>I also checked the package size installed by pip, there seems not much change in wheel size (776.3MB to 890.1MB). However, we installed these oversized packages:</p>
<pre><code class="lang-bash">nvidia-cublas-cu11==11.10.3.66 (317.1 MB)
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99 (557.1 MB)
nvidia-cudnn-cu11==8.5.0.96
</code></pre>
<p>So what do these do? And could we remove these dependencies?</p>

username: ptrblck
cooked: <p>These “oversized” packages were previously shipped in the PyTorch wheel directly, so the overall size shouldn’t change. Which exact container are you using which increased the size?</p>

username: cin-xing
cooked: <p>For all those packages, I install from PyPi directly</p>
<p>These are official Docker image from PyTorch size compare<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/d/1d966b2a625ca4e40affbbe532b55697bedb9dde.png" data-download-href="https://discuss.pytorch.org/uploads/default/1d966b2a625ca4e40affbbe532b55697bedb9dde" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/d/1d966b2a625ca4e40affbbe532b55697bedb9dde_2_690x41.png" alt="image" data-base62-sha1="4dK7fU0eQaQL2gfeLgsH4vbl8cK" width="690" height="41" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/d/1d966b2a625ca4e40affbbe532b55697bedb9dde_2_690x41.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/d/1d966b2a625ca4e40affbbe532b55697bedb9dde_2_1035x61.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/d/1d966b2a625ca4e40affbbe532b55697bedb9dde.png 2x" data-dominant-color="222325"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1178×71 10.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Thanks for the follow-up. Where did you find:</p>
<aside class="quote no-group" data-username="cin-xing" data-post="1" data-topic="164784">
<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/cin-xing/48/54474_2.png" class="avatar"> cin-xing:</div>
<blockquote>
<pre><code class="lang-auto">nvidia-cublas-cu11==11.10.3.66 (317.1 MB)
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99 (557.1 MB)
nvidia-cudnn-cu11==8.5.0.96
</code></pre>
</blockquote>
</aside>
<p>as these packages are using in the CUDA 11.7 wheels while your containers are using 11.3 and 11.6.<br>
<code>pip list | grep nvidia</code> also doesn’t return anything in the 11.6 container, so are you mixing up a few containers?</p>

username: cin-xing
cooked: <p>Sorry for such a confusing message.</p>
<p>There are two separate problems actually.</p>
<ol>
<li>Docker image size increases a lot from PyTorch 1.12 to 1.13 (as shown in the above image).</li>
<li>The python environment installed torch 1.13 is much larger than 1.12. I ran the pip install in a separate virtual environment to separately compare these two versions. To get the above package:</li>
</ol>
<pre><code class="lang-bash"># Create virtual environment
python3.7 -m venv venv
source venv/bin/activate

# Should be install torch 1.13
pip install torch torchvision

# listing package
pip freeze | grep nvidia
</code></pre>
<p>I list these packages out because I think that they are the root problem that makes PyTorch become too big.</p>