Python build from the source Failed

vivianw: <p>I am trying to build Pytorch from the source without CUDA and ROCM on linux<br>
OS: CentOS Linux release 8.2.2004  and Ubuntu 18.04.5 LTS</p>
<p>Got error below:</p>
<pre><code class="lang-auto">./pytorch/torch/csrc/jit/ir/ir.cpp:1189:16: error: ‘set_stream’ is not a member of ‘torch::jit::cuda’
     case cuda::set_stream:
                ^~~~~~~~~~
./pytorch/torch/csrc/jit/ir/ir.cpp:1189:16: note: suggested alternative:
In file included from./pytorch/torch/csrc/jit/ir/ir.h:18,
                 from ./pytorch/torch/csrc/jit/ir/ir.cpp:1:
./pytorch/aten/src/ATen/core/interned_strings.h:221:11: note:   ‘c10::cuda::set_stream’
   _(cuda, set_stream)                \
           ^~~~~~~~~~
./pytorch/aten/src/ATen/core/interned_strings.h:344:35: note: in definition of macro ‘DEFINE_SYMBOL’
   namespace ns { constexpr Symbol s(static_cast&lt;unique_t&gt;(_keys::ns##_##s)); }
                                   ^
./pytorch/aten/src/ATen/core/interned_strings.h:345:1: note: in expansion of macro ‘FORALL_NS_SYMBOLS’
 FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
 ^~~~~~~~~~~~~~~~~
./pytorch/torch/csrc/jit/ir/ir.cpp:1190:16: error: ‘_set_device’ is not a member of ‘torch::jit::cuda’
     case cuda::_set_device:
                ^~~~~~~~~~~
./pytorch/torch/csrc/jit/ir/ir.cpp:1190:16: note: suggested alternative:
In file included from /proj/gdba/vivianw/pytorch/torch/csrc/jit/ir/ir.h:18,
                 from /proj/gdba/vivianw/pytorch/torch/csrc/jit/ir/ir.cpp:1:
./pytorch/aten/src/ATen/core/interned_strings.h:220:11: note:   ‘c10::cuda::_set_device’
   _(cuda, _set_device)               \
           ^~~~~~~~~~~
./pytorch/aten/src/ATen/core/interned_strings.h:344:35: note: in definition of macro ‘DEFINE_SYMBOL’
   namespace ns { constexpr Symbol s(static_cast&lt;unique_t&gt;(_keys::ns##_##s)); }
                                   ^
./pytorch/aten/src/ATen/core/interned_strings.h:345:1: note: in expansion of macro ‘FORALL_NS_SYMBOLS’
 FORALL_NS_SYMBOLS(DEFINE_SYMBOL)
 ^~~~~~~~~~~~~~~~~
./pytorch/torch/csrc/jit/ir/ir.cpp:1191:16: error: ‘_current_device’ is not a member of ‘torch::jit::cuda’
     case cuda::_current_device:
                ^~~~~~~~~~~~~~~
./pytorch/torch/csrc/jit/ir/ir.cpp:1191:16: note: suggested alternative:
In file included from /proj/gdba/vivianw/pytorch/torch/csrc/jit/ir/ir.h:18,
                 from /proj/gdba/vivianw/pytorch/torch/csrc/jit/ir/ir.cpp:1:
./pytorch/aten/src/ATen/core/interned_strings.h:222:11: note:   ‘c10::cuda::_current_device’
   _(cuda, _current_device)           \
           ^~~~~~~~~~~~~~~
.....
[70/849] Building CXX object caffe2/CMakeFiles/torch_cpu.dir/__/torch/csrc/jit/passes/tensorexpr_fuser.cpp.o
ninja: build stopped: subcommand failed.
</code></pre>
<p>Steps I have run:</p>
<pre><code class="lang-auto">(base) bash-4.4$ conda create --name pytorch-dev python=3.9.12
(base) bash-4.4$ conda activate pytorch-dev

#install dependencies
(pytorch-dev) bash-4.4$ conda install astunparse numpy ninja pyyaml setuptools cmake cffi typing_extensions future six requests dataclasses
(pytorch-dev) bash-4.4$ conda install mkl mkl-include

#Get the PyTorch Source
(pytorch-dev) bash-4.4$git clone --recursive https://github.com/pytorch/pytorch
(pytorch-dev) bash-4.4$cd pytorch
# if you are updating an existing checkout
(pytorch-dev) bash-4.4$git submodule sync
(pytorch-dev) bash-4.4$git submodule update --init --recursive --jobs 0

#Install PyTorch
(pytorch-dev) bash-4.4$ export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
(pytorch-dev) bash-4.4$ USE_ROCM=0 USE_CUDA=0  python setup.py install
</code></pre>

ptrblck: <p>The used commands look right. Could you post the commit you are using from the <code>master</code> branch so that I could try to reproduce the build issue?</p>

ptrblck: <p>The current upstream commit:</p>
<pre><code class="lang-auto">bb1e3d8008 (HEAD -&gt; master, origin/master, origin/HEAD) Enable lint for test_module_interface.py (#83359)
</code></pre>
<p>works fine for me using your commands in a new and clean environment.</p>

vivianw: <aside class="quote no-group" data-username="ptrblck" data-post="3" data-topic="159071">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/ptrblck/48/1823_2.png" class="avatar"> ptrblck:</div>
<blockquote>
<p><code>in/master, origin/HEAD)</code></p>
</blockquote>
</aside>
<p>I am using master branch</p>

ptrblck: <p>I’m using it too as you can see in the <code>commit</code> and cannot reproduce the issue and don’t know why your build would fail.</p>

vivianw: <p>How can I collect environment information summary so I can paste here ?</p>

vivianw: <p>Which OS are you running on? Do you have more environment information so I can have a comparison.  Thanks</p>

ptrblck: <p>I’m running Ubuntu 20.04.</p>