Angus Fong
Angus Fong

Reputation: 11

Building PyTorch from source: error: ‘XXX’ is not a member of ‘torch::jit::cuda’; did you mean ‘c10::cuda::XXX’

I am building PyTorch from source on CUDA following https://github.com/pytorch/pytorch#from-source.

uname -a: Linux ares 5.8.0-59-generic #66~20.04.1-Ubuntu SMP Thu Jun 17 11:14:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

cuda version: 11.1

When I run python setup.py install, I get the following errors:

/home/angus/pytorch/torch/csrc/jit/ir/ir.cpp: In member function ‘bool torch::jit::Node::hasSideEffects() const’:
/home/angus/pytorch/torch/csrc/jit/ir/ir.cpp:1143:16: error: ‘set_stream’ is not a member of ‘torch::jit::cuda’; did you mean ‘c10::cuda::set_stream’?
 1143 |     case cuda::set_stream:
      |                ^~~~~~~~~~
In file included from /home/angus/pytorch/aten/src/ATen/core/Dimname.h:3,
                 from /home/angus/pytorch/aten/src/ATen/core/NamedTensor.h:3,
                 from /home/angus/pytorch/build/aten/src/ATen/core/TensorBody.h:24,
                 from /home/angus/pytorch/aten/src/ATen/Tensor.h:3,
                 from /home/angus/pytorch/aten/src/ATen/Context.h:4,
                 from /home/angus/pytorch/aten/src/ATen/ATen.h:9,
                 from /home/angus/pytorch/torch/csrc/jit/ir/attributes.h:2,
                 from /home/angus/pytorch/torch/csrc/jit/ir/ir.h:3,
                 from /home/angus/pytorch/torch/csrc/jit/ir/ir.cpp:1:
/home/angus/pytorch/aten/src/ATen/core/interned_strings.h:317:11: note: ‘c10::cuda::set_stream’ declared here
  317 |   _(cuda, set_stream)                \
      |           ^~~~~~~~~~
/home/angus/pytorch/aten/src/ATen/core/interned_strings.h:595:35: note: in definition of macro ‘DEFINE_SYMBOL’
  595 |   namespace ns { constexpr Symbol s(static_cast<unique_t>(_keys::ns##_##s)); }
      |                                   ^
/home/angus/pytorch/aten/src/ATen/core/interned_strings.h:596:1: note: in expansion of macro ‘FORALL_NS_SYMBOLS’
  596 | FORALL_NS_SYMBOLS(DEFINE_SYMBOL)

I tried adding #include <torch/script.h> to the top of /home/angus/pytorch/torch/csrc/jit/ir/ir, but the error persists.

Could someone explain what is going on here?

Upvotes: 1

Views: 1469

Answers (1)

Sam
Sam

Reputation: 11

I'm not sure about how this issue came to be, but for anyone still having this issue, I was able to solve it by editing the source code on the 4 successive lines pointed to by your error:

In member function 'bool torch::jit::Node::hasSideEffects() const' is not a member of 'torch::jit::cuda';

the automated suggestion, namely "did you mean ‘c10::cuda::set_stream’?"

is essentially what I changed, and the same things on the 3 following lines, and this did the trick.

Upvotes: 1

Related Questions