Hang seen in cmake while compiling pytorch from source

username: Surajit_Podder
cooked: <p>Hi Everyone,</p>
<p>I am seeing a hang while compiling pytorch from source:<br>
sudo NO_CUDA=1 DEBUG=1 USE_MKLDNN=0 python3  setup.py build develop</p>
<p>The setup.py call stack is below which is calling cmake:<br>
/usr/bin/pdb3(1688)()<br>
 → pdb.main()<br>
/usr/lib/python3.5/pdb.py(1661)main()<br>
 → pdb._runscript(mainpyfile)<br>
/usr/lib/python3.5/pdb.py(1542)_runscript()<br>
 → self.run(statement)<br>
/usr/lib/python3.5/bdb.py(431)run()<br>
 → exec(cmd, globals, locals)<br>
(1)()<br>
/home/spodder/Code/pytorch_root/8thMay/pytorch/setup.py(153)()<br>
 → from <strong>future</strong> import print_function<br>
/home/spodder/Code/pytorch_root/8thMay/pytorch/setup.py(294)build_deps()<br>
 → build_dir=‘build’)<br>
/home/spodder/Code/pytorch_root/8thMay/pytorch/tools/build_pytorch_libs.py(269)build_caffe2()<br>
 → my_env)<br>
/home/spodder/Code/pytorch_root/8thMay/pytorch/tools/build_pytorch_libs.py(249)run_cmake()<br>
 → check_call(cmake_args, cwd=build_dir, env=my_env)<br>
/usr/lib/python3.5/subprocess.py(576)check_call()<br>
 → retcode = call(*popenargs, **kwargs)<br>
/usr/lib/python3.5/subprocess.py(559)call()<br>
 → return p.wait(timeout=timeout)<br>
/usr/lib/python3.5/subprocess.py(1658)wait()<br>
 → (pid, sts) = self._try_wait(0)<br>
/usr/lib/python3.5/subprocess.py(1608)_try_wait()<br>
 → (pid, sts) = os.waitpid(self.pid, wait_flags)<br>
/usr/lib/python3.5/pdb.py(191)sigint_handler()<br>
 → signal.signal(signal.SIGINT, self._previous_sigint_handler)</p>
<blockquote>
<p>/usr/lib/python3.5/signal.py(45)signal()</p>
</blockquote>
<p>Cmake is stuck in below call stack:<br>
<span class="hashtag-raw">#0</span>  0x00007f09b2a995b3 in select () from /lib/x86_64-linux-gnu/libc.so.6<br>
<span class="hashtag-raw">#1</span>  0x0000000000741fb2 in cmsysProcess_WaitForData ()<br>
<span class="hashtag-raw">#2</span>  0x0000000000542514 in cmSystemTools::RunSingleCommand(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;<em>, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;</em>, int*, char const*, cmSystemTools::OutputOption, double) ()<br>
<span class="hashtag-raw">#3</span>  0x00000000005736a1 in cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile*) ()<br>
<span class="hashtag-raw">#4</span>  0x00000000006b79f1 in cmGlobalGenerator::EnableLanguage(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, cmMakefile*, bool) ()<br>
<span class="hashtag-raw">#5</span>  0x000000000057380a in cmGlobalNinjaGenerator::EnableLanguage(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, cmMakefile*, bool) ()<br>
<span class="hashtag-raw">#6</span>  0x00000000004f4a41 in cmMakefile::EnableLanguage(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, bool) ()<br>
<span class="hashtag-raw">#7</span>  0x00000000005e8e58 in cmProjectCommand::InitialPass(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, cmExecutionStatus&amp;) ()<br>
<span class="hashtag-raw">#8</span>  0x00000000004fd86d in cmMakefile::ExecuteCommand(cmListFileFunction const&amp;, cmExecutionStatus&amp;) ()<br>
<span class="hashtag-raw">#9</span>  0x00000000004fdeb8 in cmMakefile::ReadListFile(cmListFile const&amp;, std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; const&amp;) ()<br>
<span class="hashtag-raw">#10</span> 0x00000000004ffe68 in cmMakefile::Configure() ()<br>
<span class="hashtag-raw">#11</span> 0x00000000006bf69b in cmGlobalGenerator::Configure() ()<br>
<span class="hashtag-raw">#12</span> 0x000000000055ba29 in cmake::ActualConfigure() ()<br>
<span class="hashtag-raw">#13</span> 0x000000000055c3b4 in cmake::Configure() ()<br>
<span class="hashtag-raw">#14</span> 0x0000000000561740 in cmake::Run(std::vector&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt;, std::allocator&lt;std::__cxx11::basic_string&lt;char, std::char_traits, std::allocator &gt; &gt; &gt; const&amp;, bool) ()<br>
<span class="hashtag-raw">#15</span> 0x00000000004bdf94 in do_cmake(int, char const* const*) ()<br>
<span class="hashtag-raw">#16</span> 0x00000000004b98e6 in main ()</p>
<p>The cmake commandline is:<br>
root      9981  0.0  0.0 151628 10884 pts/19   S+   13:58   0:00 cmake -GNinja -DBUILDING_WITH_TORCH_LIBS=ON -DBUILD_BINARY=False -DBUILD_CAFFE2_OPS=True -DBUILD_PYTHON=True -DBUILD_SHARED_LIBS=ON -DBUILD_TEST=True -DBUILD_TORCH=ON -DCAFFE2_STATIC_LINK_CUDA=False -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=  -DCMAKE_C_FLAGS=  -DCMAKE_EXE_LINKER_FLAGS= -DCMAKE_INSTALL_PREFIX=/home/spodder/Code/pytorch_root/8thMay/pytorch/torch -DCMAKE_PREFIX_PATH=/usr/lib/python3/dist-packages -DCMAKE_SHARED_LINKER_FLAGS= -DINSTALL_TEST=True -DNCCL_EXTERNAL=False -DNUMPY_INCLUDE_DIR=/usr/local/lib/python3.5/dist-packages/numpy/core/include -DONNX_ML=False -DONNX_NAMESPACE=onnx_torch -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/libpython3.5m.so.1.0 -DTHD_SO_VERSION=1 -DTORCH_BUILD_VERSION=1.1.0a0+26dd65e -DUSE_CUDA=False -DUSE_DISTRIBUTED=True -DUSE_FBGEMM=True -DUSE_FFMPEG=False -DUSE_LEVELDB=False -DUSE_LMDB=False -DUSE_MKLDNN=False -DUSE_NCCL=False -DUSE_NNPACK=True -DUSE_NUMPY=True -DUSE_OPENCV=False -DUSE_QNNPACK=True -DUSE_ROCM=False -DUSE_SYSTEM_EIGEN_INSTALL=OFF -DUSE_SYSTEM_NCCL=False -DUSE_TENSORRT=False /home/spodder/Code/pytorch_root/8thMay/pytorch</p>
<p>I have seen this cmake issue being discussed online, but did not find any solution.<br>
Has anyone else encountered this issue?</p>
<p>Thanks</p>