microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.6k stars 2.92k forks source link

[Build] fail to build on Windows ARM64 #15252

Open chenfucn opened 1 year ago

chenfucn commented 1 year ago

Describe the issue

After https://github.com/microsoft/onnxruntime/pull/15190 merged. Windows ARM64 build fail with build command:

.\build.bat --config RelWithDebInfo --skip_tests --parallel --cmake_generator "Visual Studio 17 2022"

Error message

2023-03-28 09:52:53,536 build [INFO] - Building protoc for host to be used in cross-compiled build process
2023-03-28 09:52:53,536 util.run [INFO] - Running subprocess in 'C:\Users\fuchen\source\repos\onnxruntime\\build\Windows\host_protoc'
  'C:\Program Files\CMake\bin\cmake.EXE' 'C:\Users\fuchen\source\repos\onnxruntime\cmake\external\protobuf\cmake' -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_WITH_ZLIB_DEFAULT=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -G 'Visual Studio 17 2022' -T host=x64
CMake Error: The source directory "C:/Users/fuchen/source/repos/onnxruntime/cmake/external/protobuf/cmake" does not exist.

Tried to mitigate the issue with provided script, still fails on Windows ARM64 machine:

PS > .\tools\ci_build\github\windows\install_protoc.ps1
ONNX Runtime src root: .\source\repos\onnxruntime

    Directory: .\source\repos

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         3/28/2023   9:57 AM                onnxruntime
/MP /guard:cf /Qspectre /DWIN32 /D_WINDOWS /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DNTDDI_VERSION=0x06010000 /W3 /Zi /O2 /Ob1 /DNDEBUG /Gw /GL
Downloading protobuf from https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.20.2.zip
TempToolPath=C:\temp\v3.20.2.zip
Extracting 'C:\temp\v3.20.2.zip' to 'C:\temp\protobuf'
Install-Protobuf : The term 'C:\Program Files\Git\usr\bin\patch.exe' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At .\source\repos\onnxruntime\tools\ci_build\github\windows\install_protoc.ps1:76 char:1
+ Install-Protobuf -cmake_path $cmake_path -src_root $ort_src_root -bui ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Program Files\Git\usr\bin\patch.exe:String) [Install-Protobuf], Comm
   andNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Install-Protobuf

Urgency

Now ARM64 development is fully blocked. Need to be solved ASAP.

Target platform

Windows ARM64

Build script

.\build.bat --config RelWithDebInfo --skip_tests --parallel --cmake_generator "Visual Studio 17 2022"

Error / output

PS > .\tools\ci_build\github\windows\install_protoc.ps1 ONNX Runtime src root: .\source\repos\onnxruntime

Directory: .\source\repos

Mode LastWriteTime Length Name


d----- 3/28/2023 9:57 AM onnxruntime /MP /guard:cf /Qspectre /DWIN32 /D_WINDOWS /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DNTDDI_VERSION=0x06010000 /W3 /Zi /O2 /Ob1 /DNDEBUG /Gw /GL Downloading protobuf from https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.20.2.zip TempToolPath=C:\temp\v3.20.2.zip Extracting 'C:\temp\v3.20.2.zip' to 'C:\temp\protobuf' Install-Protobuf : The term 'C:\Program Files\Git\usr\bin\patch.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At .\source\repos\onnxruntime\tools\ci_build\github\windows\install_protoc.ps1:76 char:1

Visual Studio Version

2022

GCC / Compiler Version

No response

fdwr commented 1 year ago

We don't support Visual Studio 17.

@pranavsharma - we also use VS 2022 in WindowsAI builds. So this may hit us too after pulling these changes in. Changming clarified below that building with ARM64 VS on ARM64 machines is not supported. Building ARM64 target DLL's on x64 machines is still supported.

snnn commented 1 year ago

Let me clarify it a bit: @chenfucn wants to build ORT code on a Windows ARM64 machine. It is not a typical usage. Our build.py script does not support it well. Arm64 Visual Studio is only a thing since 3 months ago. And at this moment I do not have bandwidth to update all our pipelines to use VS 2022. I really want to see it happening but I need to prioritize the tasks for the upcoming ONNX Runtime release.

snnn commented 1 year ago

Our build.py need to determine if it is doing a cross-compiling build before started to build protoc separately. Previously if we see the target CPU arch is ARM or ARM64 then we are pretty sure on that, because Visual Studio only supported Intel CPUs and we only ran VS on Intel CPUs. Now the situation is changed. That's why you see more problems coming out.