Install from Source Fatal error: mpi.h: No such file or directory

I tried installing Pytorch. I follow the commands in GitHub - pytorch/pytorch: Tensors and Dynamic neural networks in Python with strong GPU acceleration
My gcc version 7.5.0
magma-cuda113 , version ==2.5.2 from conda
But still meet some problems

Performing C++ SOURCE FILE Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING failed with the following output:
Change Dir: /root/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/conda/bin/ninja cmTC_b2ec6 && [1/2] Building CXX object CMakeFiles/cmTC_b2ec6.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_b2ec6.dir/src.cxx.o 
/usr/bin/c++ -DCAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING  -std=c++14 -o CMakeFiles/cmTC_b2ec6.dir/src.cxx.o -c /root/pytorch/build/CMakeFiles/CMakeTmp/src.cxx
/root/pytorch/build/CMakeFiles/CMakeTmp/src.cxx:1:10: fatal error: glog/stl_logging.h: No such file or directory
 #include <glog/stl_logging.h>
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.

/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:1311:1: error: inlining failed in call to always_inline ‘_mm256_set1_ps’: target specific option mismatch
 _mm256_set1_ps (float __A)
 ^~~~~~~~~~~~~~
/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:7:7: note: called from here
     a = _mm256_set1_ps(0);
     ~~^~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.


/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:6:17: error: incompatible types when initializing type ‘__m512i {aka __vector(8) long long int}’ using type ‘int’
ninja: build stopped: subcommand failed.


/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:6:17: error: incompatible types when initializing type ‘__m512i {aka __vector(8) long long int}’ using type ‘int’
ninja: build stopped: subcommand failed.


cc: error: /arch:AVX512: No such file or directory
ninja: build stopped: subcommand failed.

/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:1311:1: error: inlining failed in call to always_inline ‘_mm256_set1_ps’: target specific option mismatch
 _mm256_set1_ps (float __A)
 ^~~~~~~~~~~~~~


/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:6:17: error: incompatible types when initializing type ‘__m512i {aka __vector(8) long long int}’ using type ‘int’
ninja: build stopped: subcommand failed.


/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:6:17: error: incompatible types when initializing type ‘__m512i {aka __vector(8) long long int}’ using type ‘int’
ninja: build stopped: subcommand failed.


cc: error: /arch:AVX512: No such file or directory
ninja: build stopped: subcommand failed.

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /root/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/opt/conda/bin/ninja cmTC_72b2d && [1/2] Building C object CMakeFiles/cmTC_72b2d.dir/src.c.o
[2/2] Linking C executable cmTC_72b2d
FAILED: cmTC_72b2d 
: && /usr/bin/cc  -rdynamic CMakeFiles/cmTC_72b2d.dir/src.c.o -o cmTC_72b2d   && :
CMakeFiles/cmTC_72b2d.dir/src.c.o: In function `main':
src.c:(.text+0x3e): undefined reference to `pthread_create'
src.c:(.text+0x4a): undefined reference to `pthread_detach'
src.c:(.text+0x56): undefined reference to `pthread_cancel'
src.c:(.text+0x67): undefined reference to `pthread_join'
src.c:(.text+0x7b): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


/root/pytorch/build/CMakeFiles/CMakeTmp/src.c:3:10: error: #error AVX only on x86_64
         #error AVX only on x86_64
          ^~~~~
ninja: build stopped: subcommand failed.

c++: error: unrecognized command line option '-Wshorten-64-to-32'
c++: error: unrecognized command line option '-Wshorten-64-to-32'
ninja: build stopped: subcommand failed.

c++: error: unrecognized command line option '-wd654'
c++: error: unrecognized command line option '-wd654'
ninja: build stopped: subcommand failed.

c++: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
c++: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
ninja: build stopped: subcommand failed.


/opt/conda/share/cmake-3.22/Modules/FindMPI/test_mpi.c:1:10: fatal error: mpi.h: No such file or directory
 #include <mpi.h>
          ^~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.


/usr/bin/cc -DUV_LINT_W4  -fopenmp    /W4 -std=gnu90 -o CMakeFiles/cmTC_470b0.dir/src.c.o -c /root/pytorch/build/CMakeFiles/CMakeTmp/src.c
cc: error: /W4: No such file or directory
ninja: build stopped: subcommand failed.


cc: error: /wd4100: No such file or directory
ninja: build stopped: subcommand failed.


Run Build Command(s):/opt/conda/bin/ninja cmTC_cdd19 && [1/2] Building C object CMakeFiles/cmTC_cdd19.dir/src.c.o
FAILED: CMakeFiles/cmTC_cdd19.dir/src.c.o 
/usr/bin/cc -DUV_LINT_UTF8_MSVC  -fopenmp    /utf-8 -std=gnu90 -o CMakeFiles/cmTC_cdd19.dir/src.c.o -c /root/pytorch/build/CMakeFiles/CMakeTmp/src.c
cc: error: /utf-8: No such file or directory
ninja: build stopped: subcommand failed.


 #include <magma.h>
          ^~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.


/root/pytorch/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: error: ‘strtod_l’ undeclared (first use in this function); did you mean ‘strtoull’?
   return ((int*)(&strtod_l))[argc];
                   ^~~~~~~~
                   strtoull
/root/pytorch/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8:19: note: each undeclared identifier is reported only once for each function it appears in
ninja: build stopped: subcommand failed.

I found some good material

It seems that we need export $LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH