无法从源代码构建onnxruntime-FileNotFoundError

时间:2020-08-31 21:26:10

标签: python windows winapi build onnxruntime

我正在尝试从源代码构建onnxruntime,但是遇到了以下问题。

执行后

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

我遇到以下错误

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

尽管我不确定这是否是问题,但我尝试更具体地介绍Visual Studio版本。添加标签--msvc 16.7.2会产生相同的错误。这似乎是一条相当普通的错误消息,也许不是特定于onnxruntime构建。

使用管理特权无济于事。

此问题的起因是什么,我需要怎么做才能解决?

2 个答案:

答案 0 :(得分:0)

尝试使用—recursive来下载所有从属子模块。就像是: git clone —recursive https://github.com/microsoft/onnxruntime.git cd onnxruntime ./build.bat

答案 1 :(得分:0)

您应该使用 —recursive 下载所有依赖的子模块:

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

如果你想为 Visual Studio 构建它,你应该打开 “VS 2017 的开发人员命令提示符”“VS 2019 的开发人员命令提示符” > 用于视觉工作室 2019。 如果您使用 Visual Studio 2019,则应将此命令添加到命令 --cmake_generator "Visual Studio 16 2019" 的末尾,例如:

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