How to build bdist_wheel with CUDA dynamic link

username: Zhao_Junping
cooked: <p>hi,<br>
I have successfully built PyTorch 1.4.1, CentOS 7, cuda10.1, py3.6 from source, using python setup.py build, indeeded it generate the libtorch.so with dynamic linking of cudart/cudnn/cufft etc</p>
<p>However, next when “setup.py bdist_wheel” to pack the results, the final .whl actually is a static libtorch.so and all dynmaic linking are removed inclding cuda, mpi, mkl etc</p>
<p>so wondering how to build .whl with dynamic linking of cudart/cudnn/cufft etc?</p>
<p>Appreciated for help.</p>

username: jie.hang
cooked: <p>When I install the official torch whl package and the package compiled from the source code, why are the linked dynamic libraries different? How does the official compile and link cuda library and system library？</p>
<ul>
<li>Official torch whl,</li>
</ul>
<p>$ ldd libtorch_cuda.so<br>
linux-vdso.so.1 (0x00007fff513fa000)<br>
libcudart-80664282.so.10.2 =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libcudart-80664282.so.10.2 (0x00007fc880a74000)<br>
libc10_cuda.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libc10_cuda.so (0x00007fc880844000)<br>
libnvToolsExt-3965bdd0.so.1 =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libnvToolsExt-3965bdd0.so.1 (0x00007fc88063a000)<br>
libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc88041b000)<br>
libc10.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libc10.so (0x00007fc880184000)<br>
libtorch_cpu.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libtorch_cpu.so (0x00007fc86e040000)<br>
libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc86dca2000)<br>
libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc86da9e000)<br>
librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc86d896000)<br>
libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc86d50d000)<br>
libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc86d2f5000)<br>
libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc86cf04000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007fc8c0803000)<br>
libgomp-a34b3233.so.1 =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libgomp-a34b3233.so.1 (0x00007fc86ccda000)</p>
<ul>
<li>Source compiled whl.</li>
</ul>
<p>$ ldd libtorch_cuda.so<br>
linux-vdso.so.1 (0x00007ffec46ff000)<br>
libcudart.so.10.2 =&gt; /usr/local/cuda/lib64/libcudart.so.10.2 (0x00007f04f4cab000)<br>
libc10_cuda.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libc10_cuda.so (0x00007f04f4a89000)<br>
libcusparse.so.10 =&gt; /usr/local/cuda/lib64/libcusparse.so.10 (0x00007f04ece23000)<br>
libcurand.so.10 =&gt; /usr/local/cuda/lib64/libcurand.so.10 (0x00007f04e8d80000)<br>
libcusolver.so.10 =&gt; /usr/local/cuda/lib64/libcusolver.so.10 (0x00007f04dd5b9000)<br>
libcudnn.so.7 =&gt; /usr/lib/x86_64-linux-gnu/libcudnn.so.7 (0x00007f04c1ccf000)<br>
libnvToolsExt.so.1 =&gt; /usr/local/cuda/lib64/libnvToolsExt.so.1 (0x00007f04c1ac6000)<br>
libmpi_cxx.so.20 =&gt; /usr/lib/x86_64-linux-gnu/libmpi_cxx.so.20 (0x00007f04c18ac000)<br>
libmpi.so.20 =&gt; /usr/lib/x86_64-linux-gnu/libmpi.so.20 (0x00007f04c15ba000)<br>
libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f04c139b000)<br>
libtorch_cpu.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libtorch_cpu.so (0x00007f04baba0000)<br>
libc10.so =&gt; /usr/local/lib/python3.6/dist-packages/torch/lib/./libc10.so (0x00007f04ba932000)<br>
libcufft.so.10 =&gt; /usr/local/cuda/lib64/libcufft.so.10 (0x00007f04b1492000)<br>
libcublas.so.10 =&gt; /usr/lib/x86_64-linux-gnu/libcublas.so.10 (0x00007f04ad1dc000)<br>
libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f04ace53000)<br>
libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f04acab5000)<br>
libomp.so.5 =&gt; /usr/lib/x86_64-linux-gnu/libomp.so.5 (0x00007f04ac800000)<br>
libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f04ac5e8000)<br>
libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f04ac1f7000)<br>
/lib64/ld-linux-x86-64.so.2 (0x00007f0512449000)<br>
libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f04abff3000)<br>
librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007f04abdeb000)<br>
libopen-rte.so.20 =&gt; /usr/lib/x86_64-linux-gnu/libopen-rte.so.20 (0x00007f04abb63000)<br>
libopen-pal.so.20 =&gt; /usr/lib/x86_64-linux-gnu/libopen-pal.so.20 (0x00007f04ab8b1000)<br>
libhwloc.so.5 =&gt; /usr/lib/x86_64-linux-gnu/libhwloc.so.5 (0x00007f04ab674000)<br>
libnuma.so.1 =&gt; /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007f04ab469000)<br>
libblas.so.3 =&gt; /usr/lib/x86_64-linux-gnu/libblas.so.3 (0x00007f04ab1fc000)<br>
liblapack.so.3 =&gt; /usr/lib/x86_64-linux-gnu/liblapack.so.3 (0x00007f04aa95e000)<br>
libcublasLt.so.10 =&gt; /usr/lib/x86_64-linux-gnu/libcublasLt.so.10 (0x00007f04a8acb000)<br>
libutil.so.1 =&gt; /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f04a88c8000)<br>
libltdl.so.7 =&gt; /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f04a86be000)<br>
libgfortran.so.4 =&gt; /usr/lib/x86_64-linux-gnu/libgfortran.so.4 (0x00007f04a82df000)<br>
libquadmath.so.0 =&gt; /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f04a809f000)</p>

username: ptrblck
cooked: <p>The official wheels statically link e.g. <code>libcudart</code> so that you can install the PyTorch wheels without a CUDA toolkit installation on your system (only the NVIDIA drivers need to be installed).<br>
The build scripts can be found in <a href="https://github.com/pytorch/builder/tree/bc3e81ff95a95d7c7cbff1e705c287a783a1846b/manywheel"><code>pytorch/builder</code></a>.</p>

username: jie.hang
cooked: <p>I want to know how to run this script? Could you tell me the arguments to run this script. thank you very much.<br>
<a href="https://github.com/pytorch/builder/blob/master/manywheel/build_libtorch.sh" class="inline-onebox" rel="noopener nofollow ugc">builder/build_libtorch.sh at master · pytorch/builder · GitHub</a>,</p>