How to compile Pytorch Mobile

Hello,

I tried to compile pytorch mobile from source with the following steps:

conda install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
./scripts/build_android.sh

But I only achieved to get errors located in the Eigen library :

../third_party/eigen/blas/../Eigen/src/Core/arch/GPU/Half.h:612:6: error: invalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'float')
../third_party/eigen/blas/../Eigen/src/Core/IO.h:144:8: error: no type named 'streamsize' in namespace 'std'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:165:8: error: no type named 'streamsize' in namespace 'std'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:166:43: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:175:27: error: implicit instantiation of undefined template 'std::__ndk1::basic_stringstream<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:181:8: error: no type named 'streamsize' in namespace 'std'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:181:32: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:182:30: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:190:8: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:191:8: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:198:10: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:199:10: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:208:27: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:210:6: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:211:6: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream<char, std::__ndk1::char_traits<char>>'

Did I miss something ? Is there any workaround to disable Eigen and use an other BLAS ?

So far I tried setting the BLAS environnement variable to OpenBLAS, but the change doesn’t seem to be taken in account during the building.

1 Like

Having the same problem currently, did you find a solution?

In case somebody encounters this issue, the solution is here: Errors in Eigen library when building pytorch mobile for Android · Issue #48183 · pytorch/pytorch · GitHub

I tried that approach (NDK version), but didn’t 't work on Pytorch 1.9. Same problems of Blas.