Build libtorch for android error, ‘ATen/core/TensorBody.h’ file not found

Hi all,

I just want to build libtorch for android. My pytorch verson is 1.6 and ndk version is t19c. I build the libtorch is the follow command:
BUILD_CAFFE2_MOBILE=1 ./scripts/build_android.sh,
But I got this error:

/workspace/tvm/pytorch-mobile/pytorch-1.6/aten/src/ATen/Tensor.h:3:10: fatal error: ‘ATen/core/TensorBody.h’ file not found
#include <ATen/core/TensorBody.h>
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
caffe2/CMakeFiles/torch_cpu.dir/build.make:7262: recipe for target ‘caffe2/CMakeFiles/torch_cpu.dir/operators/rms_norm_op.cc.o’ failed
make[2]: *** [caffe2/CMakeFiles/torch_cpu.dir/operators/rms_norm_op.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs…
CMakeFiles/Makefile2:1362: recipe for target ‘caffe2/CMakeFiles/torch_cpu.dir/all’ failed
make[1]: *** [caffe2/CMakeFiles/torch_cpu.dir/all] Error 2
Makefile:140: recipe for target ‘all’ failed
make: *** [all] Error 2

Anyone knows the reason and how to solve this issue?

Have you updated all submodules via git submodule update --init --recursive and cleaned a recent build via python setup.py clean?

I just clone the pytorch 1.6 again with --recursive option. When I compile with the following command, I still got the same error:

BUILD_CAFFE2_MOBILE=1 ./scripts/build_android.sh,

I don’t know if this is a bug? Previously I have built libtorch.a using pytorch version 1.4 sucessfully with cmd:

BUILD_PYTORCH_MOBILE=1 ./scripts/build_android.sh.

and I can inference using C++ code.

I also want to know the diffenrence between flags BUILD_PYTORCH_MOBILE (v1.4) and BUILD_CAFFE2_MOBILE(v1.6).

Thank you very much

I just found that the pytorch I cloned from github is version 1.8. Maybe this is a bug of version 1.8?

Same thing happening to me in realease/1.9.0

I think that script is for Caffe2. Use this one for PyTorch android: