Failed to compile pytorch with cuda9.2

Could anyone please help? I followed the instructions on git page step by step. Installed cuda9.2 and cudnn7.4. Here is the error I got:

Building wheel torch-1.0.0a0+60e7d04
running install
setup.py::run()
running build_deps
setup.py::build_deps::run()

  • SYNC_COMMAND=cp
    ++ command -v rsync
  • ‘[’ -x /usr/bin/rsync ‘]’
  • SYNC_COMMAND=‘rsync -lptgoD’
  • CMAKE_COMMAND=cmake
    ++ command -v cmake3
  • [[ -x ‘’ ]]
  • USE_CUDA=0
  • USE_FBGEMM=0
  • USE_ROCM=0
  • USE_NNPACK=0
  • USE_MKLDNN=0
  • USE_QNNPACK=0
  • USE_GLOO_IBVERBS=0
  • CAFFE2_STATIC_LINK_CUDA=0
  • RERUN_CMAKE=1
  • [[ 5 -gt 0 ]]
  • case “$1” in
  • USE_CUDA=1
  • shift
  • [[ 4 -gt 0 ]]
  • case “$1” in
  • USE_NNPACK=1
  • shift
  • [[ 3 -gt 0 ]]
  • case “$1” in
  • USE_MKLDNN=1
  • shift
  • [[ 2 -gt 0 ]]
  • case “$1” in
  • USE_QNNPACK=1
  • shift
  • [[ 1 -gt 0 ]]
  • case “$1” in
  • break
  • CMAKE_INSTALL=‘make install’
  • BUILD_SHARED_LIBS=ON
  • USER_CFLAGS=
  • USER_LDFLAGS=
  • [[ -n ‘’ ]]
  • [[ -n ‘’ ]]
  • [[ -n ‘’ ]]
    ++ uname
  • ‘[’ Linux == Darwin ‘]’
    +++ dirname …/tools/build_pytorch_libs.sh
    ++ cd …/tools/…
    +++ pwd
    ++ printf ‘%q\n’ /home/ubuntu/pytorch
  • BASE_DIR=/home/ubuntu/pytorch
  • TORCH_LIB_DIR=/home/ubuntu/pytorch/torch/lib
  • INSTALL_DIR=/home/ubuntu/pytorch/torch/lib/tmp_install
  • THIRD_PARTY_DIR=/home/ubuntu/pytorch/third_party
  • C_FLAGS=
  • C_FLAGS=’ -DOMPI_SKIP_MPICXX=1’
  • LDFLAGS=
  • LD_POSTFIX=.so
    ++ uname
  • [[ Linux == \D\a\r\w\i\n ]]
  • [[ 0 -eq 1 ]]
  • LDFLAGS=’ -Wl,-rpath,$ORIGIN’
  • CPP_FLAGS=’ -std=c++11 ’
  • THD_FLAGS=
  • [[ 0 -eq 1 ]]
  • CUDA_NVCC_FLAGS=’ -DOMPI_SKIP_MPICXX=1’
  • [[ -z ‘’ ]]
  • CUDA_DEVICE_DEBUG=0
  • ‘[’ -z ‘’ ‘]’
    ++ getconf _NPROCESSORS_ONLN
  • MAX_JOBS=12
  • BUILD_TYPE=Release
  • [[ -n ‘’ ]]
  • [[ -n ‘’ ]]
  • echo ‘Building in Release mode’
    Building in Release mode
  • mkdir -p /home/ubuntu/pytorch/torch/lib/tmp_install
  • for arg in ‘"$@"’
  • [[ caffe2 == \c\a\f\f\e\2 ]]
  • build_caffe2
  • [[ -z ‘’ ]]
  • EXTRA_CAFFE2_CMAKE_FLAGS=()
  • [[ -n ‘’ ]]
  • [[ -n /home/ubuntu/anaconda3/bin/…/;/home/ubuntu/anaconda3/lib/python3.7/site-packages ]]
  • EXTRA_CAFFE2_CMAKE_FLAGS+=("-DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH")
  • [[ 1 -eq 1 ]]
  • cmake /home/ubuntu/pytorch -DPYTHON_EXECUTABLE=/home/ubuntu/anaconda3/bin/python -DPYTHON_LIBRARY=/home/ubuntu/anaconda3/lib/libpython3.7m.so.1.0 -DPYTHON_INCLUDE_DIR=/home/ubuntu/anaconda3/include/python3.7m -DBUILDING_WITH_TORCH_LIBS=ON -DTORCH_BUILD_VERSION=1.0.0a0+60e7d04 -DCMAKE_BUILD_TYPE=Release -DBUILD_TORCH=ON -DBUILD_PYTHON=ON -DBUILD_SHARED_LIBS=ON -DBUILD_BINARY=OFF -DBUILD_TEST=ON -DINSTALL_TEST=ON -DBUILD_CAFFE2_OPS=ON -DONNX_NAMESPACE=onnx_torch -DUSE_CUDA=1 -DUSE_DISTRIBUTED=ON -DUSE_FBGEMM=0 -DUSE_NUMPY= -DNUMPY_INCLUDE_DIR=/home/ubuntu/anaconda3/lib/python3.7/site-packages/numpy/core/include -DCAFFE2_STATIC_LINK_CUDA=0 -DUSE_ROCM=0 -DUSE_NNPACK=1 -DUSE_LEVELDB=OFF -DUSE_LMDB=OFF -DUSE_OPENCV=OFF -DUSE_QNNPACK=1 -DUSE_FFMPEG=OFF -DUSE_GLOG=OFF -DUSE_GFLAGS=OFF -DUSE_SYSTEM_EIGEN_INSTALL=OFF -DCUDNN_INCLUDE_DIR= -DCUDNN_LIB_DIR= -DCUDNN_LIBRARY= -DUSE_MKLDNN=1 -DNCCL_EXTERNAL=1 -DCMAKE_INSTALL_PREFIX=/home/ubuntu/pytorch/torch/lib/tmp_install -DCMAKE_C_FLAGS= -DCMAKE_CXX_FLAGS= '-DCMAKE_EXE_LINKER_FLAGS= -Wl,-rpath,$ORIGIN ’ '-DCMAKE_SHARED_LINKER_FLAGS= -Wl,-rpath,$ORIGIN ’ -DTHD_SO_VERSION=1 ‘-DCMAKE_PREFIX_PATH=/home/ubuntu/anaconda3/bin/…/;/home/ubuntu/anaconda3/lib/python3.7/site-packages’
    – std::exception_ptr is supported.
    – NUMA is disabled
    – 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.
    – Caffe2 protobuf include directory: $<BUILD_INTERFACE:/home/ubuntu/pytorch/third_party/protobuf/src>$<INSTALL_INTERFACE:include>
    – The BLAS backend of choice:MKL
    – Checking for [mkl_intel_lp64 - mkl_gnu_thread - mkl_core - gomp - pthread - m - dl]
    – Library mkl_intel_lp64: /home/ubuntu/anaconda3/lib/libmkl_intel_lp64.so
    – Library mkl_gnu_thread: /home/ubuntu/anaconda3/lib/libmkl_gnu_thread.so
    – Library mkl_core: /home/ubuntu/anaconda3/lib/libmkl_core.so
    – Found OpenMP_C: -fopenmp
    – Found OpenMP_CXX: -fopenmp
    – Library gomp: -fopenmp
    – Library pthread: /usr/lib/x86_64-linux-gnu/libpthread.so
    – Library m: /usr/lib/x86_64-linux-gnu/libm.so
    – Library dl: /usr/lib/x86_64-linux-gnu/libdl.so
    – Brace yourself, we are building NNPACK
    – Found PythonInterp: /home/ubuntu/anaconda3/bin/python (found version “3.7”)
    – Failed to find LLVM FileCheck
    – git Version: v1.4.0-505be96a
    – Version: 1.4.0
    – 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
    – Using third party subdirectory Eigen.
    Python 3.7.0
    – Found PythonInterp: /home/ubuntu/anaconda3/bin/python (found suitable version “3.7”, minimum required is “2.7”)
    – Could NOT find pybind11 (missing: pybind11_DIR)
    – Could NOT find pybind11 (missing: pybind11_INCLUDE_DIR)
    – Using third_party/pybind11.
    – Found CUDA: /usr/local/cuda (found suitable version “9.2”, minimum required is “7.0”)
    – Caffe2: CUDA detected: 9.2
    – Caffe2: CUDA nvcc is: /usr/local/cuda/bin/nvcc
    – Caffe2: CUDA toolkit directory: /usr/local/cuda
    – Caffe2: Header version is: 9.2
    – Could NOT find CUDNN (missing: CUDNN_INCLUDE_DIR CUDNN_LIBRARY)
    CMake Warning at cmake/public/cuda.cmake:101 (message):
    Caffe2: Cannot find cuDNN library. Turning the option off
    Call Stack (most recent call first):
    cmake/Dependencies.cmake:655 (include)
    CMakeLists.txt:201 (include)

– Autodetected CUDA architecture(s): 6.1
– Added CUDA NVCC flags for: -gencode;arch=compute_61,code=sm_61
– Could NOT find NCCL (missing: NCCL_INCLUDE_DIRS NCCL_LIBRARIES)
– Could NOT find CUB (missing: CUB_INCLUDE_DIR)
– CUDA detected: 9.2

– ******** Summary ********
– CMake version : 3.12.0
– CMake command : /home/ubuntu/anaconda3/lib/python3.7/site-packages/cmake/data/bin/cmake
– System : Linux
– C++ compiler : /usr/bin/c++
– C++ compiler version : 5.4.0
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden
– Build type : Release
– Compile definitions : TH_BLAS_MKL
– CMAKE_PREFIX_PATH : /home/ubuntu/anaconda3/bin/…/;/home/ubuntu/anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /home/ubuntu/pytorch/torch/lib/tmp_install
– CMAKE_MODULE_PATH : /home/ubuntu/pytorch/cmake/Modules;/home/ubuntu/pytorch/cmake/public/…/Modules_CUDA_fix

– 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 CUDA with FP16 support, compiling with torch.cuda.HalfTensor
– Removing -DNDEBUG from compile flags
– Compiling with OpenMP support
– Compiling with MAGMA support
– MAGMA INCLUDE DIRECTORIES: /home/ubuntu/anaconda3/include
– MAGMA LIBRARIES: /home/ubuntu/anaconda3/lib/libmagma.a
– MAGMA V2 check: 1
– 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 GCC intrinsics
– Found a library with BLAS API (mkl).
– Found a library with LAPACK API. (mkl)
– Found CUDA: /usr/local/cuda (found suitable version “9.2”, minimum required is “5.5”)
– CuDNN not found. Compiling without CuDNN support
disabling ROCM because NOT USE_ROCM is set
– MIOpen not found. Compiling without MIOpen support
CMake Error at cmake/Modules/FindMKLDNN.cmake:120 (ADD_SUBDIRECTORY):
The source directory

/home/ubuntu/pytorch/third_party/ideep/mkl-dnn

does not contain a CMakeLists.txt file.
Call Stack (most recent call first):
cmake/Dependencies.cmake:1315 (FIND_PACKAGE)
CMakeLists.txt:201 (include)

CMake Warning (dev) at cmake/public/mkldnn.cmake:1 (find_package):
Policy CMP0074 is not set: find_package uses PackageName_ROOT variables.
Run “cmake --help-policy CMP0074” for policy details. Use the cmake_policy
command to set the policy and suppress this warning.

CMake variable MKLDNN_ROOT is set to:

/home/ubuntu/pytorch/third_party/ideep/mkl-dnn

For compatibility, CMake is ignoring the variable.
Call Stack (most recent call first):
cmake/Dependencies.cmake:1316 (INCLUDE)
CMakeLists.txt:201 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

– GCC 5.4.0: Adding gcc and gcc_s libs to link line
– Using python found in /home/ubuntu/anaconda3/bin/python
– Found OpenMP_C: -fopenmp
– Found OpenMP_CXX: -fopenmp
– Configuring build for SLEEF-v3.2
Target system: Linux-4.15.0-39-generic
Target processor: x86_64
Host system: Linux-4.15.0-39-generic
Host processor: x86_64
Detected C compiler: GNU @ /usr/bin/cc
– 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 : /home/ubuntu/anaconda3/lib/libmpfr.so
– MPFR header file in /home/ubuntu/anaconda3/include
– GMP : /home/ubuntu/anaconda3/lib/libgmp.so
– RUNNING_ON_TRAVIS : 0
– COMPILER_SUPPORTS_OPENMP : 1
– Using python found in /home/ubuntu/anaconda3/bin/python
– /usr/bin/c++ /home/ubuntu/pytorch/torch/abi-check.cpp -o /home/ubuntu/pytorch/build/abi-check
– Determined _GLIBCXX_USE_CXX11_ABI=1
– Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
– Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
– Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
– Found CUDA: /usr/local/cuda (found suitable version “9.2”, minimum required is “7.5”)
– Building the gloo backend with TCP support only
– Found CUDA: /usr/local/cuda (found version “9.2”)
– Building C10D with CUDA support
– Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
– Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
– Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
– Not able to find MPI, will compile c10d without MPI support
– Include NCCL operators
– Including IDEEP operators
– 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:389 (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.0
– CMake command : /home/ubuntu/anaconda3/lib/python3.7/site-packages/cmake/data/bin/cmake
– System : Linux
– C++ compiler : /usr/bin/c++
– C++ compiler version : 5.4.0
– BLAS : MKL
– CXX flags : -Wno-deprecated -fvisibility-inlines-hidden -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-unused-but-set-variable -Wno-maybe-uninitialized
– Build type : Release
– Compile definitions : TH_BLAS_MKL;ONNX_NAMESPACE=onnx_torch;MAGMA_V2;USE_GCC_ATOMICS=1;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1;HAVE_MALLOC_USABLE_SIZE=1
– CMAKE_PREFIX_PATH : /home/ubuntu/anaconda3/bin/…/;/home/ubuntu/anaconda3/lib/python3.7/site-packages
– CMAKE_INSTALL_PREFIX : /home/ubuntu/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 : /home/ubuntu/anaconda3/bin/python
– Pythonlibs version : 3.7.0
– Python library : /home/ubuntu/anaconda3/lib/libpython3.7m.so.1.0
– Python includes : /home/ubuntu/anaconda3/include/python3.7m
– Python site-packages: lib/python3.7/site-packages
– BUILD_CAFFE2_OPS : ON
– BUILD_SHARED_LIBS : ON
– BUILD_TEST : ON
– USE_ASAN : OFF
– USE_CUDA : 1
– CUDA static link : 0
– USE_CUDNN : OFF
– CUDA version : 9.2
– CUDA root directory : /usr/local/cuda
– CUDA library : /usr/lib/x86_64-linux-gnu/libcuda.so
– cudart library : /usr/local/cuda/lib64/libcudart_static.a;-pthread;dl;/usr/lib/x86_64-linux-gnu/librt.so
– cublas library : /usr/local/cuda/lib64/libcublas.so
– cufft library : /usr/local/cuda/lib64/libcufft.so
– curand library : /usr/local/cuda/lib64/libcurand.so
– nvrtc : /usr/local/cuda/lib64/libnvrtc.so
– CUDA include path : /usr/local/cuda/include
– NVCC executable : /usr/local/cuda/bin/nvcc
– CUDA host compiler : /usr/bin/cc
– USE_TENSORRT : OFF
– USE_ROCM : OFF
– USE_EIGEN_FOR_BLAS :
– USE_FBGEMM : 0
– USE_FFMPEG : OFF
– USE_GFLAGS : OFF
– USE_GLOG : OFF
– USE_LEVELDB : OFF
– USE_LITE_PROTO : OFF
– USE_LMDB : OFF
– USE_METAL : OFF
– USE_MKL : ON
– USE_MKLDNN : ON
– USE_MOBILE_OPENGL : OFF
– USE_NCCL : ON
– USE_SYSTEM_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 : 1
– USE_REDIS : OFF
– USE_ROCKSDB : OFF
– USE_ZMQ : OFF
– USE_DISTRIBUTED : ON
– USE_MPI : OFF
– USE_GLOO : ON
– USE_GLOO_IBVERBS : OFF
– Public Dependencies : Threads::Threads;caffe2::mkl;caffe2::mkldnn
– Private Dependencies : qnnpack;nnpack;cpuinfo;fp16;gloo;aten_op_header_gen;onnxifi_loader;rt;gcc_s;gcc;dl
– Configuring incomplete, errors occurred!
See also “/home/ubuntu/pytorch/build/CMakeFiles/CMakeOutput.log”.
See also “/home/ubuntu/pytorch/build/CMakeFiles/CMakeError.log”.
Failed to run ‘bash …/tools/build_pytorch_libs.sh --use-cuda --use-nnpack --use-mkldnn --use-qnnpack caffe2’

Can anyone take a look and help?