Search code examples
pythonwindowswinapibuildonnxruntime

Trouble building onnxruntime from source - FileNotFoundError


I am trying to build onnxruntime from source, but I run into the following problem.

After executing

git clone https://github.com/microsoft/onnxruntime.git
cd onnxruntime
./build.bat

I run into the following error

2020-08-31 11:14:05,414 Build [DEBUG] - Defaulting to running update, build [and test for native builds].
2020-08-31 11:14:05,414 Build [INFO] - Build started
2020-08-31 11:14:05,414 Build [DEBUG] - Running subprocess in 'C:\Users\xxx\onnxruntime'
['git', 'submodule', 'sync', '--recursive']
Traceback (most recent call last):
  File "C:\Users\xxx\onnxruntime\\tools\ci_build\build.py", line 1795, in <module>
    sys.exit(main())
  File "C:\Users\xxx\onnxruntime\\tools\ci_build\build.py", line 1603, in main
    update_submodules(source_dir)
  File "C:\Users\xxx\onnxruntime\\tools\ci_build\build.py", line 409, in update_submodules
    run_subprocess(["git", "submodule", "sync", "--recursive"], cwd=source_dir)
  File "C:\Users\xxx\onnxruntime\\tools\ci_build\build.py", line 400, in run_subprocess
    completed_process = subprocess.run(
  File "C:\Users\xxx\Anaconda3\lib\subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\xxx\Anaconda3\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\xxx\Anaconda3\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

I tried being more specific about the visual studio version, though I am not sure if this is the issue. Adding the tag --msvc 16.7.2 yields the same error. This seems like a rather generic error message, maybe not specific to the onnxruntime build.

Using administrative privileges does not help.

What is the cause of this issue and what do I need to do to resolve it?


Solution

  • You should use —recursive to download all the dependent submodules:

    git clone —recursive https://github.com/microsoft/onnxruntime.git
    

    If you want to build it for visual studio , you should open "Developer Command Prompt for VS 2017" for visual studio 2017 or "Developer Command Prompt for VS 2019" for visual studio 2019. If you use visual studio 2019 you should add this command to end of your command --cmake_generator "Visual Studio 16 2019", like:

    cd onnxruntime    
    build.bat --cmake_generator "Visual Studio 16 2019"