Skip to content

Commit

Permalink
Windows: Instructions for building onnxruntime library
Browse files Browse the repository at this point in the history
Signed-off-by: Tibor Vass <[email protected]>
  • Loading branch information
tiborvass committed Mar 25, 2023
1 parent 80beecb commit feb6890
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ convolution support.

## Build from source

Requirements are: `git`, `cmake`, and your OS's preferred compiler suite.

Use this when cloning:

```
git clone --recurse-submodules --shallow-submodules https://github.com/DamRsn/NeuralNote
```

The following OS-specific build scripts have to be executed at least once before being able to use the project as a normal CMake project. The script downloads onnxruntime static library (that we created
with [ort-builder](https://github.com/olilarkin/ort-builder)) before calling CMake.

#### Mac

```
Expand All @@ -61,13 +66,29 @@ $ ./build.sh

#### Windows

Due to [a known issue](https://github.com/DamRsn/NeuralNote/issues/21), if you're not using Visual Studio 2022 (MSVC version: 19.35.x, check `cl` output), then you'll need to manually build onnxruntime.lib like so:

1. Ensure you have Python installed; if not, download at https://www.python.org/downloads/windows/

2. Execute each of the following lines in a command prompt:

```
> build.bat
git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/tiborvass/libonnxruntime-neuralnote ThirdParty\onnxruntime
cd ThirdParty\onnxruntime
python3 -m venv venv
.\venv\Scripts\activate.bat
pip install -r requirements.txt
.\convert-model-to-ort.bat model.onnx
.\build-win.bat model.required_operators_and_types.with_runtime_opt.config
cp model.with_runtime_opt.ort ..\..\Lib\ModelData\features_model.ort
cd ..\..
```

The build script has to be executed at least once before being able to use the project as a normal CMake project.
The script downloads onnxruntime static library (that we created
with [ort-builder](https://github.com/olilarkin/ort-builder)) before calling CMake.
Now you can get back to building NeuralNote as follows:

```
> .\build.bat
```

#### IDEs

Expand All @@ -86,7 +107,7 @@ But here's a description of the process we followed to create those files:
- `features_model.onnx` was generated by converting a keras model containing only the CQT + Harmonic Stacking part of
the full basic-pitch graph using `tf2onnx` (with manually added weights for batch normalization).
- the `.json` files containing the weights of the basic-pitch cnn were generated from the tensorflow-js model available
in the [basic-pitch-tf repository](https://github.com/spotify/basic-pitch-ts), then converted to onnx with `tf2onnx`.
in the [basic-pitch-ts repository](https://github.com/spotify/basic-pitch-ts), then converted to onnx with `tf2onnx`.
Finally, the weights were gathered manually to `.npy` thanks to [Netron](https://netron.app/) and finally applied to a
split keras model created with [basic-pitch](https://github.com/spotify/basic-pitch) code.

Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if "%extract%" == "true" (
del %archive%
)

wmic get cpu NumberOfLogicalProcessors | findstr /V NumberOfLogicalProcessors > ncpus
wmic cpu get NumberOfLogicalProcessors | findstr /V NumberOfLogicalProcessors > ncpus
set /p ncpus=<ncpus
del ncpus

Expand Down

0 comments on commit feb6890

Please sign in to comment.