Repository: pytorch
Issue: Pytorch Installation from source fails (GCC-8.4/CUDA-10.2/RHEL7) and (GCC-7.5/CUDA-10.2/RHEL7)
Labels: module: build,triaged

## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

OS: RHEL 7
GCC: 7.5 & 8.4
CUDA: 10.2

Pytorch installation form source fails with following message

```
Building wheel torch-1.7.0a0+8daaa3b
-- Building version 1.7.0a0+8daaa3b
cmake --build . --target install --config Release -- -j 56
[1/5] Building CXX object c10/test/CMakeFiles/c10_complex_math_test.dir/util/complex_math_test.cpp.o
FAILED: c10/test/CMakeFiles/c10_complex_math_test.dir/util/complex_math_test.cpp.o
/home/gakadam/tools/gcc-8.4/bin/g++  -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DIDEEP_USE_MKL -DMAGMA_V2 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTH_BLAS_MKL -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -Iaten/src -I../aten/src -I. -I../ -I../cmake/../third_party/benchmark/include -Icaffe2/contrib/aten -I../third_party/onnx -Ithird_party/onnx -I../third_party/foxi -Ithird_party/foxi -I../c10/.. -isystem third_party/gloo -isystem ../cmake/../third_party/gloo -isystem ../cmake/../third_party/googletest/googlemock/include -isystem ../cmake/../third_party/googletest/googletest/include -isystem ../third_party/protobuf/src -isystem /home/gakadam/tools/anaconda3/include -isystem ../third_party/gemmlowp -isystem ../third_party/neon2sse -isystem ../third_party/XNNPACK/include -isystem ../third_party -isystem ../cmake/../third_party/eigen -isystem /home/gakadam/tools/anaconda3/include/python3.8 -isystem /home/gakadam/tools/anaconda3/lib/python3.8/site-packages/numpy/core/include -isystem ../cmake/../third_party/pybind11/include -isystem ../cmake/../third_party/cub -isystem /home/gakadam/tools/cuda-10.2/include -isystem ../third_party/ideep/mkl-dnn/include -isystem ../third_party/ideep/include -isystem ../third_party/googletest/googlemock/include -isystem ../third_party/googletest/googlemock -isystem ../third_party/googletest/googletest/include -isystem ../third_party/googletest/googletest -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow -O3 -DNDEBUG -DNDEBUG -fPIE   -DCAFFE2_USE_GLOO -DCUDA_HAS_FP16=1 -DHAVE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD -pthread -std=gnu++14 -MD -MT c10/test/CMakeFiles/c10_complex_math_test.dir/util/complex_math_test.cpp.o -MF c10/test/CMakeFiles/c10_complex_math_test.dir/util/complex_math_test.cpp.o.d -o c10/test/CMakeFiles/c10_complex_math_test.dir/util/complex_math_test.cpp.o -c ../c10/test/util/complex_math_test.cpp
init2.c:52: MPFR assertion failed: p >= 2 && p <= ((mpfr_prec_t)((mpfr_uprec_t)(~(mpfr_uprec_t)0)>>1))
during GIMPLE pass: fre
In file included from ../c10/test/util/complex_math_test.cpp:4:
../c10/test/util/complex_math_test_common.h: In member function ‘virtual void TestRevTrigonometric_Rev_Test::TestBody()’:
../c10/test/util/complex_math_test_common.h:503:1: internal compiler error: Aborted
 }
 ^
0xb3805f crash_signal
        ../../gcc/toplev.c:325
0x7fe84604624f ???
        /usr/src/debug/glibc-2.17-c758a686/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7fe8460461d7 __GI_raise
        ../nptl/sysdeps/unix/sysv/linux/raise.c:56
0x7fe8460478c7 __GI_abort
        /usr/src/debug/glibc-2.17-c758a686/stdlib/abort.c:90
0x8df310 do_mpc_arg1
        ../../gcc/fold-const-call.c:346
0x8df310 do_mpc_arg1
        ../../gcc/fold-const-call.c:326
0x8e0cf2 fold_const_call_cc
        ../../gcc/fold-const-call.c:1032
0x8e0cf2 fold_const_call_1
        ../../gcc/fold-const-call.c:1125
0xe42331 gimple_resimplify1(gimple**, code_helper*, tree_node*, tree_node**, tree_node* (*)(tree_node*))
        ../../gcc/gimple-match-head.c:89
0xf06e05 gimple_simplify(gimple*, code_helper*, tree_node**, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*))
        ../../gcc/gimple-match-head.c:782
0x904bca gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*))
        ../../gcc/gimple-fold.c:6107
0xcadc89 visit_use
        ../../gcc/tree-ssa-sccvn.c:4132
0xcafa46 process_scc
        ../../gcc/tree-ssa-sccvn.c:4346
0xcafa46 extract_and_process_scc_for_name
        ../../gcc/tree-ssa-sccvn.c:4448
0xcafa46 DFS
        ../../gcc/tree-ssa-sccvn.c:4498
0xcafdc7 sccvn_dom_walker::before_dom_children(basic_block_def*)
        ../../gcc/tree-ssa-sccvn.c:4940
0x11f40f7 dom_walker::walk(basic_block_def*)
        ../../gcc/domwalk.c:353
0xcb0a98 run_scc_vn(vn_lookup_kind)
        ../../gcc/tree-ssa-sccvn.c:5047
0xcb126a execute
        ../../gcc/tree-ssa-sccvn.c:6080
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
[2/5] Building CXX object caffe2/torch/CMakeFiles/torch_python.dir/csrc/DataLoader.cpp.o
FAILED: caffe2/torch/CMakeFiles/torch_python.dir/csrc/DataLoader.cpp.o
/home/gakadam/tools/gcc-8.4/bin/g++  -DBUILDING_TESTS -DFMT_HEADER_ONLY=1 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DIDEEP_USE_MKL -DMAGMA_V2 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTHP_BUILD_MAIN_LIB -DTH_BLAS_MKL -DUSE_C10D -DUSE_C10D_GLOO -DUSE_C10D_NCCL -DUSE_CUDA -DUSE_CUDNN -DUSE_DISTRIBUTED -DUSE_EXTERNAL_MZCRC -DUSE_NCCL -DUSE_NUMPY -DUSE_TENSORPIPE -D_FILE_OFFSET_BITS=64 -Dtorch_python_EXPORTS -Iaten/src -I../aten/src -I. -I../ -I../cmake/../third_party/benchmark/include -Icaffe2/contrib/aten -I../third_party/onnx -Ithird_party/onnx -I../third_party/foxi -Ithird_party/foxi -I../torch/.. -I../torch/../aten/src -I../torch/../aten/src/TH -Icaffe2/aten/src -Ithird_party -I../torch/../third_party/gloo -I../torch/../third_party/onnx -I../torch/csrc -I../torch/csrc/api/include -I../torch/lib -I../torch/lib/libshm -I../torch/csrc/api -I../c10/.. -Ithird_party/ideep/mkl-dnn/include -I../third_party/ideep/mkl-dnn/src/../include -I../c10/cuda/../.. -I../torch/lib/libshm/../../../torch/lib -I../third_party/fmt/include -I../torch/lib/c10d/.. -I../torch/lib/c10d/../../.. -Inccl/include -I../third_party/tensorpipe -Ithird_party/tensorpipe -isystem third_party/gloo -isystem ../cmake/../third_party/gloo -isystem ../cmake/../third_party/googletest/googlemock/include -isystem ../cmake/../third_party/googletest/googletest/include -isystem ../third_party/protobuf/src -isystem /home/gakadam/tools/anaconda3/include -isystem ../third_party/gemmlowp -isystem ../third_party/neon2sse -isystem ../third_party/XNNPACK/include -isystem ../third_party -isystem ../cmake/../third_party/eigen -isystem /home/gakadam/tools/anaconda3/include/python3.8 -isystem /home/gakadam/tools/anaconda3/lib/python3.8/site-packages/numpy/core/include -isystem ../cmake/../third_party/pybind11/include -isystem ../cmake/../third_party/cub -isystem /home/gakadam/tools/cuda-10.2/include -isystem ../third_party/ideep/mkl-dnn/include -isystem ../third_party/ideep/include -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow -DHAVE_AVX_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION -O3 -DNDEBUG -DNDEBUG -fPIC   -DCAFFE2_USE_GLOO -DCUDA_HAS_FP16=1 -DHAVE_GCC_GET_CPUID -DUSE_AVX -DUSE_AVX2 -DTH_HAVE_THREAD -fno-strict-aliasing -Wno-write-strings -Wno-strict-aliasing -pthread -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -std=gnu++14 -MD -MT caffe2/torch/CMakeFiles/torch_python.dir/csrc/DataLoader.cpp.o -MF caffe2/torch/CMakeFiles/torch_python.dir/csrc/DataLoader.cpp.o.d -o caffe2/torch/CMakeFiles/torch_python.dir/csrc/DataLoader.cpp.o -c ../torch/csrc/DataLoader.cpp
../torch/csrc/DataLoader.cpp: In function ‘PyObject* THPModule_removeWorkerPIDs(PyObject*, PyObject*)’:
../torch/csrc/DataLoader.cpp:185:21: error: expected primary-expression before ‘(’ token
     throw ValueError("Cannot find worker information for _BaseDataLoaderIter with id %" PRId64, key);
                     ^
../torch/csrc/DataLoader.cpp:185:88: error: expected ‘)’ before ‘PRId64’
     throw ValueError("Cannot find worker information for _BaseDataLoaderIter with id %" PRId64, key);
                     ~                                                                  ^~~~~~~
                                                                                        )
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 747, in <module>
    build_deps()
  File "setup.py", line 326, in build_deps
    build_caffe2(version=version,
  File "/home/gakadam/tools/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/gakadam/tools/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/gakadam/tools/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/gakadam/tools/anaconda3/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '56']' returned non-zero exit status 1.
```



## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0): 1.6
 - OS (e.g., Linux): RHEL7
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): python setup.py install
 - Python version: 3.8
 - CUDA/cuDNN version: 10.2
 - GPU models and configuration: Tesla k40c, SM_35
 - Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->


cc @malfet @seemethere @walterddr