Repository: pytorch
Issue: libtorch_cpu.so is getting too large.
Labels: oncall: releng,triaged

## 🐛 Bug

PyTorch is keep getting larger and larger.
In our build with debuginfo, libtorch_cpu.so itself is over 4GB, to the point where we want to package it before install but rpm is complaining about the size: `
error: create archive failed on file /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/BUILD/usr/local/lib/libtorch_cpu.so: cpio: File too large for archive {:level=>:info}
`

Note this is not about CUDA fat bin getting too fat, it's about CPU code.

Full log, with an fpm command for packaging to rpm, and 2 ls showing the file size.

```
[root@81e4afd8dfe3 scripts]# fpm --after-install /tmp/scratch/pytorch/install.0esMaNk7e0/root/../fpm/post_install_gen.sh --after-remove /tmp/scratch/pytorch/install.0esMaNk7e0/root/../fpm/post_install_gen.sh --chdir /tmp/scratch/pytorch/install.0esMaNk7e0/root --exclude-file /tmp/scratch/pytorch/install.0esMaNk7e0/root/../fpm/exclude.conf --input-type dir --iteration 4847 --name roaster-pytorch --output-type rpm --package /tmp/scratch/pytorch/install.0esMaNk7e0/root/.. --deb-compression gz --rpm-compression none --rpm-digest sha512 --rpm-dist gf8ca704 --vendor CodingCafe --version 1.8.0.1 --verbose
No args, but -s dir and -C are given, assuming '.' as input {:level=>:info}
Setting workdir {:workdir=>"/tmp", :level=>:info}
Setting from flags: epoch= {:level=>:info}
Setting from flags: iteration=4847 {:level=>:info}
Setting from flags: name=roaster-pytorch {:level=>:info}
Setting from flags: url=http://example.com/no-uri-given {:level=>:info}
Setting from flags: vendor=CodingCafe {:level=>:info}
Setting from flags: version=1.8.0.1 {:level=>:info}
Converting dir to rpm {:level=>:info}
Reading template {:path=>"/opt/rh/rh-ruby26/root/usr/local/share/gems/gems/fpm-1.13.0/templates/rpm.erb", :level=>:info}
Running rpmbuild {:args=>["rpmbuild", "-bb", "--define", "dist .gf8ca704", "--define", "buildroot /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/BUILD", "--define", "_topdir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22", "--define", "_sourcedir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22", "--define", "_rpmdir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/RPMS", "--define", "_tmppath /tmp", "/tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/SPECS/roaster-pytorch.spec"], :level=>:info}
Executing(%prep): /bin/sh -e /tmp/rpm-tmp.yzaIno {:level=>:info}
Executing(%build): /bin/sh -e /tmp/rpm-tmp.GArPqB {:level=>:info}
Executing(%install): /bin/sh -e /tmp/rpm-tmp.Gp9puO {:level=>:info}
Processing files: roaster-pytorch-1.8.0.1-4847.gf8ca704.x86_64 {:level=>:info}
Provides: roaster-pytorch = 1.8.0.1-4847.gf8ca704 roaster-pytorch(x86-64) = 1.8.0.1-4847.gf8ca704 {:level=>:info}
Requires(interp): /bin/sh /bin/sh {:level=>:info}
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1 {:level=>:info}
Requires(post): /bin/sh {:level=>:info}
Requires(postun): /bin/sh {:level=>:info}
error: create archive failed on file /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/BUILD/usr/local/lib/libtorch_cpu.so: cpio: File too large for archive {:level=>:info}
 {:level=>:info}
    create archive failed on file /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/BUILD/usr/local/lib/libtorch_cpu.so: cpio: File too large for archive {:level=>:info}
 {:level=>:info}
RPM build errors: {:level=>:info}
Process failed: rpmbuild failed (exit code 1). Full command was:["rpmbuild", "-bb", "--define", "dist .gf8ca704", "--define", "buildroot /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/BUILD", "--define", "_topdir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22", "--define", "_sourcedir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22", "--define", "_rpmdir /tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/RPMS", "--define", "_tmppath /tmp", "/tmp/package-rpm-build-a7c767ced6fdb9d0da76cf30b0a31d7cb7ef8e7bb90a9f238223dea0bc22/SPECS/roaster-pytorch.spec"] {:level=>:error}
[root@81e4afd8dfe3 scripts]# ls -lah /tmp/scratch/pytorch/install.0esMaNk7e0/root/usr/local/lib/libtorch_cpu.so
-rwxr-xr-x 1 root root 4.1G Jul  5 15:47 /tmp/scratch/pytorch/install.0esMaNk7e0/root/usr/local/lib/libtorch_cpu.so
[root@81e4afd8dfe3 scripts]# ls -lah /tmp/scratch/pytorch/install.0esMaNk7e0/root/usr/local/lib/libtorch_cuda.so
-rwxr-xr-x 1 root root 2.1G Jul  5 15:51 /tmp/scratch/pytorch/install.0esMaNk7e0/root/usr/local/lib/libtorch_cuda.so
```

Here's out cmake args:
https://github.com/xkszltl/Roaster/blob/7c32fff569cab864e0c03bdc0591e4c73be5249d/pkgs/pytorch.sh#L101-L143

## Environment

 - PyTorch Version (e.g., 1.0): master
 - OS (e.g., Linux): CentOS 7
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): cmake+gcc-9
 - Python version: 3.6
 - CUDA/cuDNN version: 11.3