Build from source failed in linux

username: Nazmul_Alom
cooked: <p>I am using Ubuntu 20.04<br>
My GPU: GTX 710<br>
conda 4.8.3<br>
Python 3.7.7<br>
I am following the instruction from Github to install it from source. But when I run this command:</p>
<pre><code class="lang-auto">python setup.py install
</code></pre>
<p>The following error occured:</p>
<pre><code class="lang-auto">Traceback (most recent call last):
  File "setup.py", line 737, in &lt;module&gt;
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "/home/nazmul/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/nazmul/miniconda3/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '6']' returned non-zero exit status 1.
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/d/7/d73a1b6fd87cb23651c80b91b35b1e027bfaabec.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/d73a1b6fd87cb23651c80b91b35b1e027bfaabec" title="Screenshot from 2020-07-28 13-11-19"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d73a1b6fd87cb23651c80b91b35b1e027bfaabec_2_690x372.jpeg" alt="Screenshot from 2020-07-28 13-11-19" data-base62-sha1="uHZ9jlPbjZt9j7LZvy9m3ZQCS7O" width="690" height="372" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d73a1b6fd87cb23651c80b91b35b1e027bfaabec_2_690x372.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d73a1b6fd87cb23651c80b91b35b1e027bfaabec_2_1035x558.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/d/7/d73a1b6fd87cb23651c80b91b35b1e027bfaabec_2_1380x744.jpeg 2x" data-dominant-color="07080C"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot from 2020-07-28 13-11-19</span><span class="informations">1842×994 635 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>Could you post the build log directly by wrapping it into three backticks ```?<br>
I think the error might have been raised before the actual failure and your screenshot doesn’t seem to show it.</p>

username: Nazmul_Alom
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> this is the log</p>
<pre><code class="lang-auto">Building wheel torch-1.7.0a0+d6f1346
-- Building version 1.7.0a0+d6f1346
cmake --build . --target install --config Release -- -j 6
[2/4962] Performing build step for 'nccl_external'
FAILED: nccl_external-prefix/src/nccl_external-stamp/nccl_external-build nccl/lib/libnccl_static.a 
cd /home/nazmul/pytorch/third_party/nccl/nccl &amp;&amp; env CCACHE_DISABLE=1 SCCACHE_DISABLE=1 make CXX=/usr/bin/c++ CUDA_HOME=/usr NVCC=/usr/bin/nvcc NVCC_GENCODE=-gencode=arch=compute_35,code=sm_35 BUILDDIR=/home/nazmul/pytorch/build/nccl VERBOSE=0 -j &amp;&amp; /home/nazmul/miniconda3/bin/cmake -E touch /home/nazmul/pytorch/build/nccl_external-prefix/src/nccl_external-stamp/nccl_external-build
make -C src build BUILDDIR=/home/nazmul/pytorch/build/nccl
make[1]: Entering directory '/home/nazmul/pytorch/third_party/nccl/nccl/src'
make[2]: Entering directory '/home/nazmul/pytorch/third_party/nccl/nccl/src/collectives/device'
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/functions.dep] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/sendrecv.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/broadcast.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/reduce.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/all_gather.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/reduce_scatter.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/all_reduce.dep] Error 1
make[2]: Leaving directory '/home/nazmul/pytorch/third_party/nccl/nccl/src/collectives/device'
make[1]: *** [Makefile:50: /home/nazmul/pytorch/build/nccl/obj/collectives/device/colldevice.a] Error 2
make[1]: Leaving directory '/home/nazmul/pytorch/third_party/nccl/nccl/src'
make: *** [Makefile:25: src.build] Error 2
[7/4962] Building CXX object third_par.../src/google/protobuf/message_lite.cc.o
In file included from /usr/include/string.h:495,
                 from ../third_party/protobuf/src/google/protobuf/stubs/port.h:39,
                 from ../third_party/protobuf/src/google/protobuf/stubs/common.h:46,
                 from ../third_party/protobuf/src/google/protobuf/message_lite.h:45,
                 from ../third_party/protobuf/src/google/protobuf/message_lite.cc:36:
In function ‘void* memcpy(void*, const void*, size_t)’,
    inlined from ‘google::protobuf::uint8* google::protobuf::io::EpsCopyOutputStream::WriteRaw(const void*, int, google::protobuf::uint8*)’ at ../third_party/protobuf/src/google/protobuf/io/coded_stream.h:699:16,
    inlined from ‘bool google::protobuf::MessageLite::SerializePartialToZeroCopyStream(google::protobuf::io::ZeroCopyOutputStream*) const’ at ../third_party/protobuf/src/google/protobuf/implicit_weak_message.h:87:28:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:34:33: warning: ‘void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)’ specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   34 |   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 737, in &lt;module&gt;
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "/home/nazmul/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/nazmul/miniconda3/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '6']' returned non-zero exit status 1.
</code></pre>

username: Usama_Hasan
cooked: <p>Hy <a class="mention" href="/u/nazmul_alom">@Nazmul_Alom</a>.<br>
It looks like your gcc version (C++ compiler)  is incompatible with cuda.<br>
You can check your gcc version through terminal like this.</p>
<pre><code class="lang-auto">gcc --version
</code></pre>
<p>and</p>
<pre><code class="lang-auto">sudo apt install gcc-7 g++-7 
</code></pre>
<p>I guess this should help, if not you should probably have to set cmake to gcc specific version.</p>
<pre><code class="lang-auto">cmake  -D CMAKE_C_COMPILER=/path/to/ gcc/bin/gcc -D CMAKE_CXX_COMPILER=/path/to/gcc/bin/g++`
</code></pre>

username: Nazmul_Alom
cooked: <p>Hey <a class="mention" href="/u/usama_hasan">@Usama_Hasan</a>,<br>
My gcc and g++ version is 9.3.0<br>
though, I installed version 7 as you said. and tried to set compiler in pytorch directory. but the following errors occured:</p>
<pre><code class="lang-auto">CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.


-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:23 (project):
  The CMAKE_CXX_COMPILER:

    /urs/bin/g++-9

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/home/nazmul/pytorch/CMakeFiles/CMakeOutput.log".
See also "/home/nazmul/pytorch/CMakeFiles/CMakeError.log".
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/bin/gcc-9

-- Generating done
-- Build files have been written to: /home/nazmul/pytorch
</code></pre>

username: Nazmul_Alom
cooked: <p>and using gcc and g++ version 7 I was getting same error</p>

username: Nazmul_Alom
cooked: <p>and my <code>python setup.py install</code> returns this now:</p>
<pre><code class="lang-auto">Building wheel torch-1.7.0a0+d6f1346
-- Building version 1.7.0a0+d6f1346
cmake --build . --target install --config Release -- -j 6
[1/4942] Performing build step for 'nccl_external'
FAILED: nccl_external-prefix/src/nccl_external-stamp/nccl_external-build nccl/lib/libnccl_static.a 
cd /home/nazmul/pytorch/third_party/nccl/nccl &amp;&amp; env CCACHE_DISABLE=1 SCCACHE_DISABLE=1 make CXX=/usr/bin/c++ CUDA_HOME=/usr NVCC=/usr/bin/nvcc NVCC_GENCODE=-gencode=arch=compute_35,code=sm_35 BUILDDIR=/home/nazmul/pytorch/build/nccl VERBOSE=0 -j &amp;&amp; /home/nazmul/miniconda3/bin/cmake -E touch /home/nazmul/pytorch/build/nccl_external-prefix/src/nccl_external-stamp/nccl_external-build
make -C src build BUILDDIR=/home/nazmul/pytorch/build/nccl
make[1]: Entering directory '/home/nazmul/pytorch/third_party/nccl/nccl/src'
make[2]: Entering directory '/home/nazmul/pytorch/third_party/nccl/nccl/src/collectives/device'
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
In file included from /usr/include/cuda_runtime.h:83,
                 from &lt;command-line&gt;:
/usr/include/crt/host_config.h:138:2: error: #error -- unsupported GNU version! gcc versions later than 8 are not supported!
  138 | #error -- unsupported GNU version! gcc versions later than 8 are not supported!
      |  ^~~~~
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/all_gather.dep] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/broadcast.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/sendrecv.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/reduce.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/reduce_scatter.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/all_reduce.dep] Error 1
make[2]: *** [Makefile:53: /home/nazmul/pytorch/build/nccl/obj/collectives/device/functions.dep] Error 1
make[2]: Leaving directory '/home/nazmul/pytorch/third_party/nccl/nccl/src/collectives/device'
make[1]: *** [Makefile:50: /home/nazmul/pytorch/build/nccl/obj/collectives/device/colldevice.a] Error 2
make[1]: Leaving directory '/home/nazmul/pytorch/third_party/nccl/nccl/src'
make: *** [Makefile:25: src.build] Error 2
[6/4942] Building CXX object third_par...f/compiler/command_line_interface.cc.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 737, in &lt;module&gt;
    build_deps()
  File "setup.py", line 321, in build_deps
    cmake=cmake)
  File "/home/nazmul/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/nazmul/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/nazmul/miniconda3/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '6']' returned non-zero exit status 1.

</code></pre>