Installing PyTorch 1.10.0 from source


I have been trying to install the new version of PyTorch (1.10.0) from source. I have followed the instructions from the PyTorch team, and seen other sites regarding this issue.

Tools/Libraries/OS versions: Python 3.7.6, Cuda 11.0, PyTorch 1.10.0, Linux RedHat.

The entire script is below (I have created a conda environment):

conda install -c anaconda cudatoolkit
conda install astunparse numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
conda install -c pytorch magma-cuda110
conda install -c conda-forge gcc_linux-64 gxx_linux-64 -y

git clone --recursive
cd pytorch
git checkout v1.10.0

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
export CXXFLAGS="`echo $CXXFLAGS | sed 's/-std=c++17/-std=c++14/'`"
git submodule update --recursive
python install

conda install -c conda-forge freetype jpeg lcms2 libmklml libpng libtiff libwebp-base olefile openjpeg pillow typing-extensions ffmpeg

git clone --recursive
cd vision
python install

Note that, according to this post, conda install -c conda-forge gcc_linux-64 gxx_linux-64 -y would install the correct gcc version. But it seems that it is not. In the same post, it is said that (see walterddr):

you should actually remove -std=c++xx all together in your env CXXFLAGS because cmake will do the configuration for you.

But it is not clear how the command should look like. Here, it is part of the error message:

-- Building version 1.10.0a0+git36449ea
-- The CXX compiler identification is GNU 4.8.5
-- The C compiler identification is GNU 4.8.5
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Not forcing any particular BLAS to be found
-- Could not find ccache. Consider installing ccache to speed up compilation.
-- Performing Test COMPILER_WORKS
-- Performing Test COMPILER_WORKS - Success
-- Performing Test SUPPORT_GLIBCXX_USE_C99
-- Performing Test SUPPORT_GLIBCXX_USE_C99 - Failed
CMake Error at cmake/MiscCheck.cmake:63 (message):
  The C++ compiler does not support required functions.  This is very likely
  due to a known bug in GCC 5 (and maybe other versions) on Ubuntu 17.10 and
  newer.  For more information, see:
Call Stack (most recent call first):
  CMakeLists.txt:642 (include)

And the CMakeError.log is:

Run Build Command(s):.../miniconda3/envs/pyts/bin/ninja cmTC_7c658 && [1/2] Building CXX object CMakeFiles/cmTC_7c658.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_7c658.dir/src.cxx.o
/usr/bin/g++ -DSUPPORT_GLIBCXX_USE_C99  -std=c++14 -std=gnu++1y -o CMakeFiles/cmTC_7c658.dir/src.cxx.o -c src.cxx
g++: error: unrecognized command line option '-std=c++14'
ninja: build stopped: subcommand failed.

Source file was:

  #include <cmath>
  #include <string>

  int main() {
    int a = std::isinf(3.0);
    int b = std::isnan(0.0);
    std::string s = std::to_string(1);

    return 0;

Any hints? Thanks.