Pytorch 1.8.1+cu111 package size and memory usage issue

Hao-Yan: <p>I am trying to upgrade torch 1.8.1 to use CUDA11.1, but I found 2 issues compared with the cuda10.2 one:</p>
<ul>
<li>
<p>The package Size</p>
<ul>
<li>The cuda10.2 one is about 900M, while the cuda11.1 one is about 1900M. <strong>Is this expected?</strong></li>
</ul>
</li>
<li>
<p>Runtime memory usage when no CUDA related function is called</p>
<ul>
<li>
<p>I tested by running <code>python3 -c 'import torch'</code> for both version. The memory usage had big difference. For cuda10.2 version, it only uses about 180M, but for cuda11.1, it uses about 1.0G. Below is the loaded library for each version in gdb, looks like for cuda11.1 one, even no cuda related function is called, it will still load those cuda kernels like libtorch_cuda_cu.so. <strong>Is this an issue?</strong></p>
<p>For cuda11.1 one:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/7/9/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c.png" data-download-href="https://discuss.pytorch.org/uploads/default/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c_2_647x499.png" alt="image" data-base62-sha1="hoZJ9p3yThbJLEhFDqWoNFha2Ty" width="647" height="499" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c_2_647x499.png, https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c_2_970x748.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/7/9/79f849b279367b7fd1d8b37437a3b9cc5bb22b5c_2_1294x998.png 2x" data-dominant-color="323231"><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">2243×1732 505 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>
<p>For cuda10.2 one:</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/5/85ca8600565f06057adbd33c516a12cf41e11ace.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/85ca8600565f06057adbd33c516a12cf41e11ace" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/5/85ca8600565f06057adbd33c516a12cf41e11ace_2_674x500.jpeg" alt="image" data-base62-sha1="j5zpiwpV5PHFkyU9cHmYCoHTeFM" width="674" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/5/85ca8600565f06057adbd33c516a12cf41e11ace_2_674x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/8/5/85ca8600565f06057adbd33c516a12cf41e11ace_2_1011x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/8/5/85ca8600565f06057adbd33c516a12cf41e11ace_2_1348x1000.jpeg 2x" data-dominant-color="303030"><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">1920×1424 414 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>
</li>
</ul>
</li>
</ul>
<p>BTW, the cuda10.2 one is installed with <code>pip install torch==1.8.1</code>, while the cuda11.1 one is installed with <code>pip install torch==1.8.1+cu111 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html</code>.</p>

ptrblck: <ol>
<li>Yes, since the CUDA libs increased in size.</li>
<li>Unsure, if you are referring to GPU memory, but the CUDA context would use between ~600-1000MB device memory, so the 180MB seem to low for CUDA10.2.</li>
</ol>

Hao-Yan: <p>For 2, the memory I mean the CPU memory. If user only run <code>import tensor</code>, it should not load any CUDA related libraries into CPU memory per my understanding. I compared the shared libraries of this 2 version. For cuda11.1 one, the libtorch_cuda_cu.so and libtroch_cuda_cpp.so are new and both are very big, not sure whether it is related or not. <a class="mention" href="/u/alband">@albanD</a> , any idea?</p>
<p>For torch with cuda11.1:<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/6/0/609aa91ee5d18666be87283c8cbe09c954083001.png" data-download-href="https://discuss.pytorch.org/uploads/default/609aa91ee5d18666be87283c8cbe09c954083001" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/6/0/609aa91ee5d18666be87283c8cbe09c954083001.png" alt="image" data-base62-sha1="dMBc9xnLpT0Vn3r29cmEUejSSCR" width="690" height="346" data-dominant-color="2B332F"><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">1427×716 54.4 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>
<p>For torch with cuda10.2<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/4/f/4f889406812c37d9a0a1522c6c515f6635ef3e5f.png" data-download-href="https://discuss.pytorch.org/uploads/default/4f889406812c37d9a0a1522c6c515f6635ef3e5f" title="image"><img src="https://discuss.pytorch.org/uploads/default/original/3X/4/f/4f889406812c37d9a0a1522c6c515f6635ef3e5f.png" alt="image" data-base62-sha1="blAkVYagzeltIk1FHvnoYwRKUnd" width="690" height="310" data-dominant-color="2B332F"><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">1453×654 52.1 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>