Cannot compile PyTorch under gcc 7, 8, 10, 11, or 12

Hello folks, I’m struggling to compile PyTorch. It doesn’t compile on my Ubuntu 22.04 machine with gcc version 10 or 11, due to crashes in gcc (I get cc1plus: internal compiler error: Segmentation fault), it doesn’t compile with gcc version 12 due to an Nvidia header rejecting gcc 12, but even if I comment out that check it still fails to compile with gcc 12, due to some warnings that are promoted to errors while compiling some MKL stuff (even when I set USE_MKLDNN=0). I’ve also tried compiling in the pytorch/pytorch:1.12.1-cuda11.3-cudnn8-devel and pytorch/pytorch:latest docker containers, and I can’t get it compiling there under gcc 7 or 8 either, following the exact instructions from the main README – again, I get internal compiler error: Segmentation fault crashes.

I’m struggling to see how one is supposed to be able to build PyTorch from source. Is there some docker container that it’s known to build in? I feel like I’ve tried every permutation of environments, and they all crash one way or another.



These containers are building PyTorch:

I don’t know which base OS they are using but if it’s Ubuntu 22.04, they would be using gcc 9.4 (I think).
The wheels are using a CentOS container but I don’t know which gcc version they are using.