How to compile Pytorch Mobile

valerianG: <p>Hello,</p>
<p>I tried to compile pytorch mobile from source with the following steps:</p>
<pre><code class="lang-bash">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
</code></pre>
<p>But I only achieved to get errors located in the Eigen library :</p>
<pre><code class="lang-auto">../third_party/eigen/blas/../Eigen/src/Core/arch/GPU/Half.h:612:6: error: invalid operands to binary expression ('std::ostream' (aka 'basic_ostream&lt;char&gt;') 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&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:175:27: error: implicit instantiation of undefined template 'std::__ndk1::basic_stringstream&lt;char, std::__ndk1::char_traits&lt;char&gt;, std::__ndk1::allocator&lt;char&gt;&gt;'
../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&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:182:30: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:190:8: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:191:8: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:198:10: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:199:10: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:208:27: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:210:6: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
../third_party/eigen/blas/../Eigen/src/Core/IO.h:211:6: error: implicit instantiation of undefined template 'std::__ndk1::basic_ostream&lt;char, std::__ndk1::char_traits&lt;char&gt;&gt;'
</code></pre>
<p>Did I miss something ? Is there any workaround to disable Eigen and use an other BLAS ?</p>
<p>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.</p>

erksch: <p>Having the same problem currently, did you find a solution?</p>

erksch: <p>In case somebody encounters this issue, the solution is here: <a href="https://github.com/pytorch/pytorch/issues/48183" class="inline-onebox" rel="noopener nofollow ugc">Errors in Eigen library when building pytorch mobile for Android · Issue #48183 · pytorch/pytorch · GitHub</a></p>

yingbo: <p>I tried that approach (NDK version), but didn’t 't work on Pytorch 1.9. Same problems of Blas.</p>

Cagatay_Bilgin: <p>For people who are landing on this page, we have open sourced ExecuTorch a few years ago, deprecating this older stack. <a href="https://github.com/pytorch/executorch" class="inline-onebox" rel="noopener nofollow ugc">GitHub - pytorch/executorch: On-device AI across mobile, embedded and edge for PyTorch</a> Join our discord channel at<br>
<a href="https://discord.gg/Wyn9PWqP" class="inline-onebox" rel="noopener nofollow ugc">PyTorch Edge</a> where the team hangs out and can answer questions. We discuss a lot of the plans openly there.</p>