Python build from the source Failed

I am trying to build Pytorch from the source without CUDA and ROCM on linux
OS: CentOS Linux release 8.2.2004 and Ubuntu 18.04.5 LTS

Got error below:

./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<unique_t>(_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<unique_t>(_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.

Steps I have run:

(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

The used commands look right. Could you post the commit you are using from the master branch so that I could try to reproduce the build issue?

The current upstream commit:

bb1e3d8008 (HEAD -> master, origin/master, origin/HEAD) Enable lint for test_module_interface.py (#83359)

works fine for me using your commands in a new and clean environment.

I am using master branch

I’m using it too as you can see in the commit and cannot reproduce the issue and don’t know why your build would fail.

How can I collect environment information summary so I can paste here ?

Which OS are you running on? Do you have more environment information so I can have a comparison. Thanks

I’m running Ubuntu 20.04.