Installing PyTorch 1.10.0 from source

username: vsant
cooked: <p>Hello,</p>
<p>I have been trying to install the new version of PyTorch (1.10.0) from source. I have followed the instructions from the <a href="https://github.com/pytorch/pytorch#from-source" rel="noopener nofollow ugc">PyTorch team</a>, and seen <a href="https://github.com/pytorch/pytorch/issues/47717" rel="noopener nofollow ugc">other sites</a> regarding this issue.</p>
<p>Tools/Libraries/OS versions: Python 3.7.6, Cuda 11.0, PyTorch 1.10.0, Linux RedHat.</p>
<p>The entire script is below (I have created a conda environment):</p>
<pre><code class="lang-auto">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 https://github.com/pytorch/pytorch
cd pytorch
git checkout v1.10.0

USE_CUDA=1
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 setup.py install

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

git clone --recursive https://github.com/pytorch/vision
cd vision
python setup.py install
</code></pre>
<p>Note that, according to this <a href="https://github.com/pytorch/pytorch/issues/47717" rel="noopener nofollow ugc">post</a>, <code>conda install -c conda-forge gcc_linux-64 gxx_linux-64 -y</code> would install the correct gcc version. But it seems that it is not. In the same post, it is said that (see walterddr):</p>
<blockquote>
<p>you should actually remove <code>-std=c++xx</code> all together in your env CXXFLAGS because cmake will do the configuration for you.</p>
</blockquote>
<p>But it is not clear how the command should look like. Here, it is part of the error message:</p>
<pre><code class="lang-auto">-- Building version 1.10.0a0+git36449ea
cmake -GNinja -DBUILD_PYTHON=True -DBUILD_TEST=True -DCMAKE_BUILD_TYPE=Release -
...
-- 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:
  https://github.com/pytorch/pytorch/issues/5229
Call Stack (most recent call first):
  CMakeLists.txt:642 (include)


</code></pre>
<p>And the CMakeError.log is:</p>
<pre><code class="lang-auto">Run Build Command(s):.../miniconda3/envs/pyts/bin/ninja cmTC_7c658 &amp;&amp; [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 &lt;cmath&gt;
  #include &lt;string&gt;

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

    return 0;
    }
</code></pre>
<p>Any hints? Thanks.</p>