Pytorch 1.0 build failed on Mac OS 10.13

OS: MAC OS 10.13
python: anaconda 3.7
Compiler: gcc-8 and g+±8
NO_CUDA=1 CC=gcc-8 CXX=g+±8 python setup.py install

this also does not work for
NO_CUDA=1 NO_DISTRIBUTED=1 NO_QNNPACK=1 DEBUG=1 NO_CAFFE2_OPS=1 CC=gcc-8 CXX=g+±8 python setup.py install

– ******** Summary ********
– CMake version : 3.12.3
– CMake command : /usr/local/Cellar/cmake/3.12.3/bin/cmake
– System : Darwin
– C++ compiler : /usr/local/bin/g+±8
– C++ compiler version : 8.2.0
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations
– Build type : Debug
– Compile definitions :
– CMAKE_PREFIX_PATH : /anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/torch/lib/tmp_install
– CMAKE_MODULE_PATH : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/cmake/Modules

– ONNX version : 1.3.0
– ONNX NAMESPACE : onnx_torch
– ONNX_BUILD_TESTS : OFF
– ONNX_BUILD_BENCHMARKS : OFF
– ONNX_USE_LITE_PROTO : OFF
– ONNXIFI_DUMMY_BACKEND : OFF

– Protobuf compiler :
– Protobuf includes :
– Protobuf libraries :
– BUILD_ONNX_PYTHON : OFF
– Found gcc >=5 and CUDA <= 7.5, adding workaround C++ flags
– Could not find CUDA with FP16 support, compiling without torch.CudaHalfTensor
– Removing -DNDEBUG from compile flags
– MAC OS Darwin Version: 17
– Compiling with OpenMP support
– MAGMA not found. Compiling without MAGMA support
– Could not find hardware support for NEON on this machine.
– No OMAP3 processor on this machine.
– No OMAP4 processor on this machine.
– AVX compiler support found
– AVX2 compiler support found
– Atomics: using C11 intrinsics
– Found a library with LAPACK API. (accelerate)
– CuDNN not found. Compiling without CuDNN support
disabling CUDA because NOT USE_CUDA is set
– MIOpen not found. Compiling without MIOpen support
disabling ROCM because NOT USE_ROCM is set
disabling MKLDNN because USE_MKLDNN is not set
– GCC 8.2.0: Adding gcc and gcc_s libs to link line
– Using python found in /anaconda3/bin/python
disabling CUDA because USE_CUDA is set false
– Found OpenMP_C: -fopenmp
– Found OpenMP_CXX: -fopenmp
– Found OpenMP: TRUE
– Configuring build for SLEEF-v3.2
Target system: Darwin-17.7.0
Target processor: x86_64
Host system: Darwin-17.7.0
Host processor: x86_64
Detected C compiler: GNU @ /usr/local/bin/gcc-8
– Using option -Wall -Wno-unused -Wno-attributes -Wno-unused-result -Wno-psabi -ffp-contract=off -fno-math-errno -fno-trapping-math to compile libsleef
– Building shared libs : OFF
– MPFR : /usr/local/lib/libmpfr.dylib
– MPFR header file in /usr/local/include
– GMP : /usr/local/lib/libgmp.dylib
– RUNNING_ON_TRAVIS : 0
– COMPILER_SUPPORTS_OPENMP : 1
– Using python found in /anaconda3/bin/python
– /usr/local/bin/g+±8 /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/torch/abi-check.cpp -o /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/build/abi-check
– Determined _GLIBCXX_USE_CXX11_ABI=1
– NCCL operators skipped due to no CUDA support
– Excluding ideep operators as we are not using ideep
– Excluding image processing operators due to no opencv
– Excluding video processing operators due to no opencv
– MPI operators skipped due to no MPI support
– Include Observer library
– Using lib/python3.7/site-packages as python relative installation path
– Automatically generating missing init.py files.
– A previous caffe2 cmake run already created the init.py files.
CMake Warning at CMakeLists.txt:387 (message):
Generated cmake files are only fully tested if one builds with system glog,
gflags, and protobuf. Other settings may generate files that are not well
tested.


– ******** Summary ********
– General:
– CMake version : 3.12.3
– CMake command : /usr/local/Cellar/cmake/3.12.3/bin/cmake
– System : Darwin
– C++ compiler : /usr/local/bin/g+±8
– C++ compiler version : 8.2.0
– BLAS : MKL
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -D_FORCE_INLINES -D_MWAITXINTRIN_H_INCLUDED -D__STRICT_ANSI__ -fopenmp -O2 -fPIC -Wno-narrowing -Wall -Wextra -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-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-unused-private-field -Wno-missing-braces -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-stringop-overflow
– Build type : Debug
– Compile definitions : ONNX_NAMESPACE=onnx_torch;USE_C11_ATOMICS=1;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1
– CMAKE_PREFIX_PATH : /anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/torch/lib/tmp_install

– TORCH_VERSION : 1.0.0
– CAFFE2_VERSION : 1.0.0
– BUILD_ATEN_MOBILE : OFF
– BUILD_ATEN_ONLY : OFF
– BUILD_BINARY : OFF
– BUILD_CUSTOM_PROTOBUF : ON
– Link local protobuf : ON
– BUILD_DOCS : OFF
– BUILD_PYTHON : ON
– Python version : 3.7
– Python executable : /anaconda3/bin/python
– Pythonlibs version : 3.7.0
– Python library : /anaconda3/lib/libpython3.7m.dylib
– Python includes : /anaconda3/include/python3.7m
– Python site-packages: lib/python3.7/site-packages
– BUILD_CAFFE2_OPS : OFF
– BUILD_SHARED_LIBS : ON
– BUILD_TEST : ON
– USE_ASAN : OFF
– USE_CUDA : 0
– USE_ROCM : OFF
– USE_EIGEN_FOR_BLAS : ON
– USE_FFMPEG : OFF
– USE_GFLAGS : OFF
– USE_GLOG : OFF
– USE_LEVELDB : OFF
– USE_LITE_PROTO : OFF
– USE_LMDB : OFF
– USE_METAL : OFF
– USE_MKL : OFF
– USE_MKLDNN : OFF
– USE_MOBILE_OPENGL : OFF
– USE_NCCL : OFF
– USE_NNPACK : 1
– USE_NUMPY : ON
– USE_OBSERVERS : ON
– USE_OPENCL : OFF
– USE_OPENCV : OFF
– USE_OPENMP : OFF
– USE_PROF : OFF
– USE_QNNPACK : 0
– USE_REDIS : OFF
– USE_ROCKSDB : OFF
– USE_ZMQ : OFF
– USE_DISTRIBUTED : OFF
– Public Dependencies : Threads::Threads
– Private Dependencies : nnpack;cpuinfo;fp16;onnxifi_loader;gcc_s;gcc
– Configuring done
– Generating done
– Build files have been written to: /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/build

  • ninja install -j4

Error
FAILED: lib/libcaffe2.dylib
ld: library not found for -lgcc_s
collect2: error: ld returned 1 exit status
[1279/1481] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/observer_config.cc.o
[1280/1481] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/net_observer_reporter_print.cc.o
[1281/1481] Building CXX object modules/module_test/CMakeFiles/caffe2_module_test_dynamic.dir/module_test_dynamic.cc.o
ninja: build stopped: subcommand failed.
setup.py::build_deps::run()
Failed to run ‘bash …/tools/build_pytorch_libs.sh --use-nnpack caffe2’

Case 2
OS: Mac OSX 10.13
python: anacnonda 3.7
compiler: clang and clang++
make command: NO_CUDA=1 NO_DISTRIBUTED=1 NO_QNNPACK=1 DEBUG=1 NO_CAFFE2_OPS=1 CC=clang CXX=clang++ python setup.py install

– ******** Summary ********
– CMake version : 3.12.3
– CMake command : /usr/local/Cellar/cmake/3.12.3/bin/cmake
– System : Darwin
– C++ compiler : /Library/Developer/CommandLineTools/usr/bin/clang++
– C++ compiler version : 10.0.0.10001044
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations
– Build type : Debug
– Compile definitions :
– CMAKE_PREFIX_PATH : /anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/torch/lib/tmp_install
– CMAKE_MODULE_PATH : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/cmake/Modules

– ONNX version : 1.3.0
– ONNX NAMESPACE : onnx_torch
– ONNX_BUILD_TESTS : OFF
– ONNX_BUILD_BENCHMARKS : OFF
– ONNX_USE_LITE_PROTO : OFF
– ONNXIFI_DUMMY_BACKEND : OFF

– Protobuf compiler :
– Protobuf includes :
– Protobuf libraries :
– BUILD_ONNX_PYTHON : OFF
– Could not find CUDA with FP16 support, compiling without torch.CudaHalfTensor
– Removing -DNDEBUG from compile flags
– Found OpenMP_C: -Xclang -fopenmp (found version “3.1”)
– Found OpenMP_CXX: -Xclang -fopenmp (found version “3.1”)
– Found OpenMP: TRUE (found version “3.1”)
– Compiling with OpenMP support
– MAGMA not found. Compiling without MAGMA support
– Could not find hardware support for NEON on this machine.
– No OMAP3 processor on this machine.
– No OMAP4 processor on this machine.
– Looking for cpuid.h
– Looking for cpuid.h - found
– Performing Test HAVE_GCC_GET_CPUID
– Performing Test HAVE_GCC_GET_CPUID - Success
– Performing Test NO_GCC_EBX_FPIC_BUG
– Performing Test NO_GCC_EBX_FPIC_BUG - Success
– Performing Test C_HAS_AVX_1
– Performing Test C_HAS_AVX_1 - Failed
– Performing Test C_HAS_AVX_2
– Performing Test C_HAS_AVX_2 - Success
– Performing Test C_HAS_AVX2_1
– Performing Test C_HAS_AVX2_1 - Failed
– Performing Test C_HAS_AVX2_2
– Performing Test C_HAS_AVX2_2 - Success
– Performing Test CXX_HAS_AVX_1
– Performing Test CXX_HAS_AVX_1 - Failed
– Performing Test CXX_HAS_AVX_2
– Performing Test CXX_HAS_AVX_2 - Success
– Performing Test CXX_HAS_AVX2_1
– Performing Test CXX_HAS_AVX2_1 - Failed
– Performing Test CXX_HAS_AVX2_2
– Performing Test CXX_HAS_AVX2_2 - Success
– AVX compiler support found
– AVX2 compiler support found
– Performing Test HAS_C11_ATOMICS
– Performing Test HAS_C11_ATOMICS - Failed
– Performing Test HAS_MSC_ATOMICS
– Performing Test HAS_MSC_ATOMICS - Failed
– Performing Test HAS_GCC_ATOMICS
– Performing Test HAS_GCC_ATOMICS - Success
– Atomics: using GCC intrinsics
– Looking for cheev_
– Looking for cheev_ - found
– Found a library with LAPACK API. (accelerate)
– CuDNN not found. Compiling without CuDNN support
– MIOpen not found. Compiling without MIOpen support
– Looking for mmap
– Looking for mmap - found
– Looking for shm_open
– Looking for shm_open - found
– Looking for shm_unlink
– Looking for shm_unlink - found
– Looking for malloc_usable_size
– Looking for malloc_usable_size - not found
– Performing Test C_HAS_THREAD
– Performing Test C_HAS_THREAD - Success
– Using python found in /anaconda3/bin/python
– Check size of long double
– Check size of long double - done
– Performing Test COMPILER_SUPPORTS_LONG_DOUBLE
– Performing Test COMPILER_SUPPORTS_LONG_DOUBLE - Success
– Performing Test COMPILER_SUPPORTS_FLOAT128
– Performing Test COMPILER_SUPPORTS_FLOAT128 - Failed
– Performing Test COMPILER_SUPPORTS_SSE2
– Performing Test COMPILER_SUPPORTS_SSE2 - Success
– Performing Test COMPILER_SUPPORTS_SSE4
– Performing Test COMPILER_SUPPORTS_SSE4 - Success
– Performing Test COMPILER_SUPPORTS_AVX
– Performing Test COMPILER_SUPPORTS_AVX - Success
– Performing Test COMPILER_SUPPORTS_FMA4
– Performing Test COMPILER_SUPPORTS_FMA4 - Success
– Performing Test COMPILER_SUPPORTS_AVX2
– Performing Test COMPILER_SUPPORTS_AVX2 - Success
– Performing Test COMPILER_SUPPORTS_SVE
– Performing Test COMPILER_SUPPORTS_SVE - Failed
– Performing Test COMPILER_SUPPORTS_AVX512F
– Performing Test COMPILER_SUPPORTS_AVX512F - Success
– Found OpenMP_C: -Xclang -fopenmp (found version “3.1”)
– Found OpenMP_CXX: -Xclang -fopenmp (found version “3.1”)
– Performing Test COMPILER_SUPPORTS_OPENMP
– Performing Test COMPILER_SUPPORTS_OPENMP - Failed
– Performing Test COMPILER_SUPPORTS_WEAK_ALIASES
– Performing Test COMPILER_SUPPORTS_WEAK_ALIASES - Failed
– Performing Test COMPILER_SUPPORTS_BUILTIN_MATH
– Performing Test COMPILER_SUPPORTS_BUILTIN_MATH - Success
– Configuring build for SLEEF-v3.2
– Using option -Wall -Wno-unused -Wno-attributes -Wno-unused-result -ffp-contract=off -fno-math-errno -fno-trapping-math to compile libsleef
– Building shared libs : OFF
– MPFR : /usr/local/lib/libmpfr.dylib
– MPFR header file in /usr/local/include
– GMP : /usr/local/lib/libgmp.dylib
– RUNNING_ON_TRAVIS : 0
– COMPILER_SUPPORTS_OPENMP :
– Using python found in /anaconda3/bin/python
– NCCL operators skipped due to no CUDA support
– Excluding ideep operators as we are not using ideep
– Excluding image processing operators due to no opencv
– Excluding video processing operators due to no opencv
– MPI operators skipped due to no MPI support
– Include Observer library
– Using lib/python3.7/site-packages as python relative installation path
– Automatically generating missing init.py files.

– ******** Summary ********
– General:
– CMake version : 3.12.3
– CMake command : /usr/local/Cellar/cmake/3.12.3/bin/cmake
– System : Darwin
– C++ compiler : /Library/Developer/CommandLineTools/usr/bin/clang++
– C++ compiler version : 10.0.0.10001044
– BLAS : MKL
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -Wno-deprecated-declarations -Xclang -fopenmp -O2 -fPIC -Wno-narrowing -Wall -Wextra -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-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -faligned-new -Wno-unused-private-field -Wno-missing-braces -Wno-c++14-extensions -Wno-constexpr-not-const
– Build type : Debug
– Compile definitions : ONNX_NAMESPACE=onnx_torch;USE_GCC_ATOMICS=1;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1
– CMAKE_PREFIX_PATH : /anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /Users/krishna.singh/Desktop/Object_Detection/Models/maskrcnn-benchmark/github/pytorch/torch/lib/tmp_install

– TORCH_VERSION : 1.0.0
– CAFFE2_VERSION : 1.0.0
– BUILD_ATEN_MOBILE : OFF
– BUILD_ATEN_ONLY : OFF
– BUILD_BINARY : OFF
– BUILD_CUSTOM_PROTOBUF : ON
– Link local protobuf : ON
– BUILD_DOCS : OFF
– BUILD_PYTHON : ON
– Python version : 3.7
– Python executable : /anaconda3/bin/python
– Pythonlibs version : 3.7.0
– Python library : /anaconda3/lib/libpython3.7m.dylib
– Python includes : /anaconda3/include/python3.7m
– Python site-packages: lib/python3.7/site-packages
– BUILD_CAFFE2_OPS : OFF
– BUILD_SHARED_LIBS : ON
– BUILD_TEST : ON
– USE_ASAN : OFF
– USE_CUDA : 0
– USE_ROCM : OFF
– USE_EIGEN_FOR_BLAS : ON
– USE_FFMPEG : OFF
– USE_GFLAGS : OFF
– USE_GLOG : OFF
– USE_LEVELDB : OFF
– USE_LITE_PROTO : OFF
– USE_LMDB : OFF
– USE_METAL : OFF
– USE_MKL : OFF
– USE_MKLDNN : OFF
– USE_MOBILE_OPENGL : OFF
– USE_NCCL : OFF
– USE_NNPACK : 1
– USE_NUMPY : ON
– USE_OBSERVERS : ON
– USE_OPENCL : OFF
– USE_OPENCV : OFF
– USE_OPENMP : OFF
– USE_PROF : OFF
– USE_QNNPACK : 0
– USE_REDIS : OFF
– USE_ROCKSDB : OFF
– USE_ZMQ : OFF
– USE_DISTRIBUTED : OFF
– Public Dependencies : Threads::Threads
– Private Dependencies : nnpack;cpuinfo;fp16;onnxifi_loader
– Configuring done
– Generating done
Error
“_omp_set_num_threads”, referenced from:
_THSetNumThreads in THGeneral.cpp.o
caffe2::Caffe2SetOpenMPThreads(int*, char***) in init_omp.cc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[1363/1562] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/perf_observer.cc.o
ninja: build stopped: subcommand failed.
setup.py::build_deps::run()
Failed to run ‘bash …/tools/build_pytorch_libs.sh --use-nnpack caffe2’