Fuse Module Recipe tutorial error - PyTorch Mobile

dalseeroh: <p>Hello folks,</p>
<p>I am following this tutorial. <a href="https://pytorch.org/tutorials/recipes/fuse.html" rel="noopener nofollow ugc">https://pytorch.org/tutorials/recipes/fuse.html</a></p>
<p>When I try to build the module, I get an error.</p>
<h3>
<a name="3-build-the-android-benchmark-tool-1" class="anchor" href="#3-build-the-android-benchmark-tool-1"></a>3. Build the Android benchmark Tool</h3>
<p>Get the PyTorch source and build the Android benchmark tool as follows:</p>
<pre><code class="lang-auto">git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
git submodule update --init --recursive
BUILD_PYTORCH_MOBILE=1 ANDROID_ABI=arm64-v8a ./scripts/build_android.sh -DBUILD_BINARY=ON
</code></pre>
<p>Since the shall script could not find Android NDK, I manually set them a correct path.</p>
<pre><code class="lang-auto">eugene.roh@IB-LT-42721 MINGW64 ~/pytorch (master)
$ ANDROID_NDK="C:\Users\eugene.roh\AppData\Local\Android\Sdk\ndk\23.1.7779620" BUILD_PYTORCH_MOBILE=1 ANDROID_ABI=arm64-v8a ./scripts/build_android.sh -DBUILD_BINARY=ON
Build with ANDROID_ABI[arm64-v8a], ANDROID_NATIVE_API_LEVEL[21]
Bash: GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Python: 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
Caffe2 path: /c/Users/eugene.roh/pytorch
Using Android NDK at C:\Users\eugene.roh\AppData\Local\Android\Sdk\ndk\23.1.7779620
Android NDK version: 23
-- ANDROID_PLATFORM not set. Defaulting to minimum supported version 16.
-- android-16 is not supported for arm64-v8a. Using minimum supported LP64 version 21.
-- Android: Selected unified Clang toolchain
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Users/eugene.roh/AppData/Local/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe
-- Check for working CXX compiler: C:/Users/eugene.roh/AppData/Local/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "C:/Users/eugene.roh/AppData/Local/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/eugene.roh/pytorch/build_android/CMakeFiles/CMakeTmp

    Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_57be6.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m &amp;&amp; Microsoft (R) Build Engine version 16.11.1+3e40a09f8 for .NET Framework
    Copyright (C) Microsoft Corporation. All rights reserved.

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(439,5): error MSB8020: The build tools for Clang_5_0 (Platform Toolset = 'Clang_5_0') cannot be found. To build using the Clang_5_0 build tools, please install Clang_5_0 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\eugene.roh\pytorch\build_android\CMakeFiles\CMakeTmp\cmTC_57be6.vcxproj]





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:23 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/eugene.roh/pytorch/build_android/CMakeFiles/CMakeOutput.log".
See also "C:/Users/eugene.roh/pytorch/build_android/CMakeFiles/CMakeError.log".
</code></pre>
<p>I guess I am having a problem with locating C++ compiler. How should I solve this problem?</p>

Linbin: <p>Hi <a class="mention" href="/u/dalseeroh">@dalseeroh</a>, please check the notes in the build script <a href="https://github.com/pytorch/pytorch/blob/master/scripts/build_android.sh" class="inline-onebox" rel="noopener nofollow ugc">pytorch/build_android.sh at master · pytorch/pytorch · GitHub</a><br>
and make sure all steps are done.<br>
Also check<br>
<a href="https://developer.android.com/studio/projects/configure-cmake" class="inline-onebox" rel="noopener nofollow ugc">配置 CMake  |  Android 开发者  |  Android Developers</a><br>
for cmake configs.</p>