What gcc version to use for cpp extension

When I run the PyTorch (0.4.1) in Anaconda everything is fine but the pip version some colleages try all result in segfault. The gcc version installed is 5.4, but I do not know which version of gcc those PyTorch binaries are compiled against if I hit this error.

The warning about ABI compatibility is always printed, regardless of when I try 4.8, 4.9 or 5.4

This is line I get the segfault:

0x00007fffe6aff4a0 in construct<_object*, _object*> (__p=0xb, this=0x14d7b08) at /usr/include/c++/4.8/ext/new_allocator.h:120
120 { ::new((void *)__p) _Up(std::forward<_Args>(__args)…); }

Does this mean the pip version of PyTorch is compiled with gcc 4.8? that is too old

For the next person hitting this issue :–)
the environment was a little odd, it was Ubuntu14, and even though

$ gcc --version
gcc (Ubuntu 5.4.1-2ubuntu1~14.04) 5.4.1 2016090

I had

$ x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4

It took some time to see, not matter what I set to $CC or $CXX always x86_64-linux-gnu-gcc was used for building the extension, and that pointed to the old gcc. update-altenatives also did not list the multiple gccs.

Anyways, this was the fix:

sudo update-alternatives --install /usr/bin/x86_64-linux-gnu-gcc x86_64-linux-gnu-gcc /usr/bin/x86_64-linux-gnu-gcc-5 40 --slave /usr/bin/x86_64-linux-gnu-g++ x86_64-linux-gnu-g++ /usr/bin/x86_64-linux-gnu-g++-5
sudo update-alternatives --config x86_64-linux-gnu-gcc