Repository: pytorch
Issue: Build Error: OpenMP library could not be found.  Proceeding might lead to highly sub-optimal performance.
Labels: module: build,triaged,module: mkldnn,module: third_party

### 🐛 Describe the bug

Error Message:
```
Building wheel torch-2.0.0a0+git8992eec
-- Building version 2.0.0a0+git8992eec
cmake -GNinja -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/mnt/c/Users/ZJ/Raw/pytorch/torch -DCMAKE_PREFIX_PATH=/home/u/anaconda3/lib/python3.9/site-packages;/home/u/anaconda3 -DNUMPY_INCL
UDE_DIR=/home/u/anaconda3/lib/python3.9/site-packages/numpy/core/include -DPYTHON_EXECUTABLE=/home/u/anaconda3/bin/python -DPYTHON_INCLUDE_DIR=/home/u/anaconda3/include/python3.9 -DPYTHON_LIBRARY=/home/u/anaconda3/lib/libpython3.9.a
 -DTORCH_BUILD_VERSION=2.0.0a0+git8992eec -DUSE_CUDA=0 -DUSE_NUMPY=True -DUSE_ROCM=0 /mnt/c/Users/ZJ/Raw/pytorch
CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/CMakeDependentOption.cmake:84 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition                             
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the                                 
  cmake_policy command to set the policy and suppress this warning.                                       
Call Stack (most recent call first):                                                                      
  CMakeLists.txt:245 (cmake_dependent_option)                                                             
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/CMakeDependentOption.cmake:84 (message):
  Policy CMP0127 is not set: cmake_dependent_option() supports full Condition
  Syntax.  Run "cmake --help-policy CMP0127" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
Call Stack (most recent call first):
  CMakeLists.txt:276 (cmake_dependent_option)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could not find ccache. Consider installing ccache to speed up compilation.
-- std::exception_ptr is supported.
-- Turning off deprecation warning due to glog.
-- Current compiler supports avx2 extension. Will build perfkernels.
-- Current compiler supports avx512f extension. Will build fbgemm.
-- Building using own protobuf under third_party per request.
-- Use custom protobuf build.
-- 
-- 3.13.0.0
-- Caffe2 protobuf include directory: $<BUILD_INTERFACE:/mnt/c/Users/ZJ/Raw/pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
-- Trying to find preferred BLAS backend of choice: MKL
-- MKL_THREADING = OMP
-- MKL libraries: /home/u/anaconda3/lib/libmkl_intel_lp64.so;/home/u/anaconda3/lib/libmkl_intel_thread.so;/home/u/anaconda3/lib/libmkl_core.so;/home/u/anaconda3/lib/libiomp5.so;/usr/lib/x86_64-linux-gnu/libpthread.a;/usr/lib/x86_64-
linux-gnu/libm.so;/usr/lib/x86_64-linux-gnu/libdl.a
-- MKL include directory: /home/u/anaconda3/include
-- MKL OpenMP type: Intel
-- MKL OpenMP library: /home/u/anaconda3/lib/libiomp5.so
-- Brace yourself, we are building NNPACK
-- NNPACK backend is x86-64
-- Failed to find LLVM FileCheck
-- git version: v1.6.1 normalized to 1.6.1
-- Version: 1.6.1
-- Performing Test HAVE_THREAD_SAFETY_ATTRIBUTES -- failed to compile
-- Performing Test HAVE_STD_REGEX -- success
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK -- success
CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_C)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
  third_party/fbgemm/CMakeLists.txt:85 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_CXX)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
  third_party/fbgemm/CMakeLists.txt:85 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Warning at third_party/fbgemm/CMakeLists.txt:93 (message):
  OpenMP is not supported by the compiler


CMake Warning at third_party/fbgemm/CMakeLists.txt:186 (message):
  ==========


CMake Warning at third_party/fbgemm/CMakeLists.txt:187 (message):
  CMAKE_BUILD_TYPE = Release


CMake Warning at third_party/fbgemm/CMakeLists.txt:188 (message):
  CMAKE_CXX_FLAGS_DEBUG is -g


CMake Warning at third_party/fbgemm/CMakeLists.txt:189 (message):
  CMAKE_CXX_FLAGS_RELEASE is -O3 -DNDEBUG


CMake Warning at third_party/fbgemm/CMakeLists.txt:190 (message):
  ==========


** AsmJit Summary **
   ASMJIT_DIR=/mnt/c/Users/ZJ/Raw/pytorch/third_party/fbgemm/third_party/asmjit
   ASMJIT_TEST=FALSE
   ASMJIT_TARGET_TYPE=STATIC
   ASMJIT_DEPS=pthread;rt
   ASMJIT_LIBS=asmjit;pthread;rt
   ASMJIT_CFLAGS=-DASMJIT_STATIC
   ASMJIT_PRIVATE_CFLAGS=-Wall;-Wextra;-Wconversion;-fno-math-errno;-fno-threadsafe-statics;-fno-semantic-interposition;-DASMJIT_STATIC
   ASMJIT_PRIVATE_CFLAGS_DBG=
   ASMJIT_PRIVATE_CFLAGS_REL=-O2;-fmerge-all-constants
-- Using third party subdirectory Eigen.
-- Found PythonInterp: /home/u/anaconda3/bin/python (found suitable version "3.9.13", minimum required is "3.0") 
-- Found PythonLibs: /home/u/anaconda3/lib/libpython3.9.a (found suitable version "3.9.13", minimum required is "3.0")
-- Using third_party/pybind11.
-- pybind11 include dirs: /mnt/c/Users/ZJ/Raw/pytorch/cmake/../third_party/pybind11/include
-- summary of build options:
    Install prefix:  /mnt/c/Users/ZJ/Raw/pytorch/torch
    Target system:   Linux
    Compiler:
      C compiler:    /usr/bin/clang-14
      CFLAGS:

-- Gloo build as SHARED library
-- Found PythonInterp: /home/u/anaconda3/bin/python (found version "3.9.13") 
-- Found PythonLibs: /home/u/anaconda3/lib/libpython3.9.a (found version "3.9.13") 
Generated: /mnt/c/Users/ZJ/Raw/pytorch/build/third_party/onnx/onnx/onnx_onnx_torch-ml.proto
Generated: /mnt/c/Users/ZJ/Raw/pytorch/build/third_party/onnx/onnx/onnx-operators_onnx_torch-ml.proto
Generated: /mnt/c/Users/ZJ/Raw/pytorch/build/third_party/onnx/onnx/onnx-data_onnx_torch.proto
-- 
-- ******** Summary ********
--   CMake version             : 3.22.1
--   CMake command             : /home/u/anaconda3/bin/cmake
--   System                    : Linux
--   C++ compiler              : /usr/bin/clang++-14
--   C++ compiler version      : 14.0.0
--   CXX flags                 :  -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -Wnon-virtual-dtor
--   Build type                : Release
--   Compile definitions       : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;__STDC_FORMAT_MACROS
--   CMAKE_PREFIX_PATH         : /home/u/anaconda3/lib/python3.9/site-packages;/home/u/anaconda3
--   CMAKE_INSTALL_PREFIX      : /mnt/c/Users/ZJ/Raw/pytorch/torch
--   CMAKE_MODULE_PATH         : /mnt/c/Users/ZJ/Raw/pytorch/cmake/Modules
--
--   ONNX version              : 1.12.0
--   ONNX NAMESPACE            : onnx_torch
--   ONNX_USE_LITE_PROTO       : OFF
--   USE_PROTOBUF_SHARED_LIBS  : OFF
--   Protobuf_USE_STATIC_LIBS  : ON
--   ONNX_DISABLE_EXCEPTIONS   : OFF
--   ONNX_WERROR               : OFF
--   ONNX_BUILD_TESTS          : OFF
--   ONNX_BUILD_BENCHMARKS     : OFF
--   ONNXIFI_DUMMY_BACKEND     : OFF
--   ONNXIFI_ENABLE_EXT        : OFF
--
--   Protobuf compiler         :
--   Protobuf includes         :
--   Protobuf libraries        :
--   BUILD_ONNX_PYTHON         : OFF
-- 
-- ******** Summary ********
--   CMake version         : 3.22.1
--   CMake command         : /home/u/anaconda3/bin/cmake
--   System                : Linux
--   C++ compiler          : /usr/bin/clang++-14
--   C++ compiler version  : 14.0.0
--   CXX flags             :  -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -Wnon-virtual-dtor
--   Build type            : Release
--   Compile definitions   : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1
--   CMAKE_PREFIX_PATH     : /home/u/anaconda3/lib/python3.9/site-packages;/home/u/anaconda3
--   CMAKE_INSTALL_PREFIX  : /mnt/c/Users/ZJ/Raw/pytorch/torch
--   CMAKE_MODULE_PATH     : /mnt/c/Users/ZJ/Raw/pytorch/cmake/Modules
--
--   ONNX version          : 1.4.1
--   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
-- Adding -DNDEBUG to compile flags
-- 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.
-- Found a library with LAPACK API (mkl).
disabling CUDA because NOT USE_CUDA is set
-- USE_CUDNN is set to 0. Compiling without cuDNN support
disabling ROCM because NOT USE_ROCM is set
-- MIOpen not found. Compiling without MIOpen support
-- Will build oneDNN Graph
-- MKLDNN_CPU_RUNTIME = OMP
-- cmake version: 3.22.1
CMake Deprecation Warning at third_party/ideep/mkl-dnn/CMakeLists.txt:36 (cmake_policy):
  The OLD behavior for policy CMP0025 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


-- DNNL_TARGET_ARCH: X64
-- DNNL_LIBRARY_NAME: dnnl
CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_C)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
  third_party/ideep/mkl-dnn/third_party/oneDNN/cmake/OpenMP.cmake:69 (find_package)
  third_party/ideep/mkl-dnn/third_party/oneDNN/CMakeLists.txt:117 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) 
CMake Warning (dev) at /home/u/anaconda3/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (OpenMP_CXX)
  does not match the name of the calling package (OpenMP).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/Modules/FindOpenMP.cmake:576 (find_package_handle_standard_args)
  third_party/ideep/mkl-dnn/third_party/oneDNN/cmake/OpenMP.cmake:69 (find_package)
  third_party/ideep/mkl-dnn/third_party/oneDNN/CMakeLists.txt:117 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
-- Could NOT find OpenMP (missing: OpenMP_C_FOUND OpenMP_CXX_FOUND)
CMake Error at third_party/ideep/mkl-dnn/third_party/oneDNN/cmake/OpenMP.cmake:118 (message):
  OpenMP library could not be found.  Proceeding might lead to highly
  sub-optimal performance.
Call Stack (most recent call first):
  third_party/ideep/mkl-dnn/third_party/oneDNN/CMakeLists.txt:117 (include)
```

### Versions

```
Collecting environment information...
PyTorch version: N/A                              
Is debug build: N/A                               
CUDA used to build PyTorch: N/A                   
ROCM used to build PyTorch: N/A                   
                                                  
OS: Ubuntu 22.04.1 LTS (x86_64)                   
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: 14.0.0-1ubuntu1                    
CMake version: version 3.22.1                     
Libc version: glibc-2.35

Python version: 3.9.13 (main, Aug 25 2022, 23:26:10)  [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.35
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] numpydoc==1.4.0
[conda] blas                      1.0                         mkl
[conda] magma-cuda110             2.5.2                         1    pytorch
[conda] mkl                       2021.4.0           h06a4308_640
[conda] mkl-include               2022.1.0           h06a4308_224
[conda] mkl-service               2.4.0            py39h7f8727e_0
[conda] mkl_fft                   1.3.1            py39hd3c417c_0
[conda] mkl_random                1.2.2            py39h51133e4_0
[conda] numpy                     1.21.5           py39h6c91a56_3
[conda] numpy-base                1.21.5           py39ha15fc14_3
[conda] numpydoc                  1.4.0            py39h06a4308_0
```

cc @malfet @seemethere @gujinghui @PenghuiCheng @XiaobingSuper @jianyuh @jgong5 @mingfeima @sanchitintel @ashokei @jingxu10 @min-jean-cho @yanbing-j @Guobing-Chen @Xia-Weiwen