diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84d4cc52a..4fca8d3de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -329,12 +329,16 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: bash tools/release/promoted-bins.sh "$RAEA_PROMOTED_FROM" target/dist + # ONNX Runtime as Microsoft builds it (MIT), beside raea.exe, which loads it when a model first runs (#110): the + # static runtime ort links by default is built for AVX2 and stopped raea.exe at start on CPUs without it + - name: ONNX Runtime (tools/release/onnxruntime.sh) + run: bash tools/release/onnxruntime.sh target/dist # which DLLs raea needs from the machine (the CRT's come from the VC++ redistributable) - name: What raea.exe imports run: | - { echo '### what raea.exe, raea_bundle.dll and raea-perceive.exe import'; echo '```' + { echo '### what raea.exe, raea_bundle.dll, raea-perceive.exe and onnxruntime.dll import'; echo '```' dumpbin=$(ls "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/MSVC/*/bin/HostX64/x64/dumpbin.exe | head -1) - "$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe | grep -iE '\.dll$|Dump of' | sed 's/^ *//' + "$dumpbin" -nologo -dependents target/dist/raea.exe target/dist/raea_bundle.dll target/dist/raea-perceive.exe target/dist/onnxruntime.dll | grep -iE '\.dll$|Dump of' | sed 's/^ *//' echo '```'; } | tee -a "$GITHUB_STEP_SUMMARY" || true # release.sh's checks render on Mesa's lavapipe (software Vulkan, MIT; on the runner only, never in the zip): the # runner has no GPU, and WARP, Windows' own software DX12, crashes compiling one of Bevy's compute shaders there diff --git a/Cargo.lock b/Cargo.lock index 1412233bf..5d21833f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -761,7 +761,7 @@ version = "0.38.0+1.3.281" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb44936d800fea8f016d7f2311c6a4f97aebd5dc86f09906139ec848cf3a46f" dependencies = [ - "libloading", + "libloading 0.8.9", ] [[package]] @@ -4806,7 +4806,7 @@ checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" dependencies = [ "glob", "libc", - "libloading", + "libloading 0.8.9", ] [[package]] @@ -6320,7 +6320,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" dependencies = [ - "libloading", + "libloading 0.8.9", ] [[package]] @@ -8895,7 +8895,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" dependencies = [ "libc", - "libloading", + "libloading 0.8.9", "pkg-config", ] @@ -9171,6 +9171,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "libloading" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1832accd5a4ca2795ace4d05d15c4039be15b62d3b950eff99746a990e3cc10" +dependencies = [ + "cfg-if", + "windows-link", +] + [[package]] name = "libm" version = "0.2.16" @@ -11989,6 +11999,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4336a1e2b38848325241c72889086886004e589b7c74f335e60a8e8db5138a0b" dependencies = [ "half", + "libloading 0.9.1", "ndarray 0.17.2", "ort-sys", "smallvec", @@ -15129,7 +15140,7 @@ name = "raea-runtime-bundle-lib" version = "0.1.0" dependencies = [ "dunce", - "libloading", + "libloading 0.8.9", "raea-io-home", "serde_json", ] @@ -17958,7 +17969,7 @@ dependencies = [ "image", "js-sys", "libc", - "libloading", + "libloading 0.8.9", "objc2 0.5.3", "objc2 0.6.5", "objc2-app-kit 0.2.2", @@ -22400,7 +22411,7 @@ dependencies = [ "js-sys", "khronos-egl", "libc", - "libloading", + "libloading 0.8.9", "log", "naga", "naga-types", @@ -23253,7 +23264,7 @@ dependencies = [ "as-raw-xcb-connection", "gethostname", "libc", - "libloading", + "libloading 0.8.9", "once_cell", "rustix 1.1.5", "x11rb-protocol", diff --git a/docs/manual/whats-new/0.1.8.md b/docs/manual/whats-new/0.1.8.md index 5664cf1fa..56a3bbed1 100644 --- a/docs/manual/whats-new/0.1.8.md +++ b/docs/manual/whats-new/0.1.8.md @@ -40,6 +40,9 @@ On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`. first. - Agents' npm tools and MCP servers start without a shell, and their arguments arrive as written in folders with spaces or letters outside ASCII. +- raea starts on a PC whose processor has no AVX2, such as an Intel Core from 2011 or 2012 (#110). The ONNX Runtime + raea linked was built for newer processors and stopped raea.exe before it did anything. raea now loads Microsoft's + own build when a model first runs, and it picks its code for the processor it finds. **Local models with nothing installed first.** Stable Audio Open's sound effects, matchmove (`raea track`), Gaussian splats (`raea splat train`), liquids and TokenSynth's instruments set themselves up on a Mac, Windows or diff --git a/systems/columns/Cargo.toml b/systems/columns/Cargo.toml index cf3e5532e..b4154089b 100644 --- a/systems/columns/Cargo.toml +++ b/systems/columns/Cargo.toml @@ -23,3 +23,9 @@ half = "2" serde = { version = "1", features = ["derive"] } serde_json = "1" anyhow = "1" + +# Windows x64: ONNX Runtime is loaded from onnxruntime.dll beside the executable when a model first runs, never linked +# in (#110; tools/release/onnxruntime.sh ships Microsoft's build). The static runtime ort downloads is built for AVX2, and +# its static initializers ran before main, so raea.exe stopped at start on any CPU without AVX2 or BMI2. +[target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies] +ort = { version = "=2.0.0-rc.13", features = ["load-dynamic"] } diff --git a/systems/index/Cargo.toml b/systems/index/Cargo.toml index bc9bdfe0b..e6002c03f 100644 --- a/systems/index/Cargo.toml +++ b/systems/index/Cargo.toml @@ -39,3 +39,9 @@ objc2-app-kit = { version = "0.3", default-features = false, features = ["std", block2 = "0.6" # a file kept only in iCloud (cloud.rs): its picture from Quick Look, without downloading the original objc2-quick-look-thumbnailing = { version = "0.3", default-features = false, features = ["std", "block2", "objc2-core-foundation", "objc2-core-graphics", "QLThumbnailGenerator", "QLThumbnailGenerationRequest", "QLThumbnailRepresentation"] } + +# Windows x64: ONNX Runtime is loaded from onnxruntime.dll beside the executable when a model first runs, never linked +# in (#110; tools/release/onnxruntime.sh ships Microsoft's build). The static runtime ort downloads is built for AVX2, and +# its static initializers ran before main, so raea.exe stopped at start on any CPU without AVX2 or BMI2. +[target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies] +ort = { version = "=2.0.0-rc.13", features = ["load-dynamic"] } diff --git a/systems/ml/Cargo.toml b/systems/ml/Cargo.toml index c8c9ab5a1..9e24c21b1 100644 --- a/systems/ml/Cargo.toml +++ b/systems/ml/Cargo.toml @@ -19,3 +19,9 @@ half = "2" anyhow = "1" # models fetched once from Hugging Face into the model cache (models.rs) ureq = "2" + +# Windows x64: ONNX Runtime is loaded from onnxruntime.dll beside the executable when a model first runs, never linked +# in (#110; tools/release/onnxruntime.sh ships Microsoft's build). The static runtime ort downloads is built for AVX2, and +# its static initializers ran before main, so raea.exe stopped at start on any CPU without AVX2 or BMI2. +[target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies] +ort = { version = "=2.0.0-rc.13", features = ["load-dynamic"] } diff --git a/systems/song/Cargo.toml b/systems/song/Cargo.toml index cef5a9ab7..1dbc9f016 100644 --- a/systems/song/Cargo.toml +++ b/systems/song/Cargo.toml @@ -26,3 +26,9 @@ ndarray = { version = "0.15", optional = true } # Core ML on Apple only: ort has no prebuilt runtime with it elsewhere (the link fails) [target.'cfg(target_vendor = "apple")'.dependencies] ort = { version = "=2.0.0-rc.13", features = ["coreml"] } + +# Windows x64: ONNX Runtime is loaded from onnxruntime.dll beside the executable when a model first runs, never linked +# in (#110; tools/release/onnxruntime.sh ships Microsoft's build). The static runtime ort downloads is built for AVX2, and +# its static initializers ran before main, so raea.exe stopped at start on any CPU without AVX2 or BMI2. +[target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies] +ort = { version = "=2.0.0-rc.13", features = ["load-dynamic"] } diff --git a/systems/speech/Cargo.toml b/systems/speech/Cargo.toml index 837464c16..3674460a8 100644 --- a/systems/speech/Cargo.toml +++ b/systems/speech/Cargo.toml @@ -13,3 +13,9 @@ ort = { version = "=2.0.0-rc.13", features = ["half"] } anyhow = "1" serde_json = "1" tokenizers = { version = "0.23", default-features = false, features = ["onig"] } + +# Windows x64: ONNX Runtime is loaded from onnxruntime.dll beside the executable when a model first runs, never linked +# in (#110; tools/release/onnxruntime.sh ships Microsoft's build). The static runtime ort downloads is built for AVX2, and +# its static initializers ran before main, so raea.exe stopped at start on any CPU without AVX2 or BMI2. +[target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies] +ort = { version = "=2.0.0-rc.13", features = ["load-dynamic"] } diff --git a/tools/release-check.sh b/tools/release-check.sh index 70545cedb..7d8331752 100644 --- a/tools/release-check.sh +++ b/tools/release-check.sh @@ -151,8 +151,14 @@ api=$(cat "$check"/raea/bin/* | grep -aoE '(api|sign)\.raea\.io|RAEA_(SIGN|GEN)_ keys=$(grep -rlE 'sk-or-v1-[0-9a-f]{20}|sk-ant-[A-Za-z0-9_-]{20}|(^|[^A-Za-z0-9+/])AKIA[0-9A-Z]{16}([^A-Za-z0-9+/=]|$)|BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY' "$check/raea" 2>/dev/null | head -5 || true) [ -z "$keys" ] || fail "key-shaped text in: $keys" # Windows: our binaries only. Any other DLL, or a file named like the CRT, the SDK or DirectX's redistributables, is -# Microsoft's and isn't ours to ship -ms=$(cd "$check/raea" && find . -type f \( -iname '*.dll' ! -path './bin/raea_bundle.dll' -o -iname 'vcruntime*' -o -iname 'msvcp*' -o -iname 'ucrtbase*' -o -iname 'api-ms-win*' -o -iname 'concrt*' -o -iname 'vccorlib*' -o -iname '*.lib' -o -iname '*.pdb' -o -iname 'd3dcompiler*' -o -iname 'dxcompiler*' -o -iname 'dxil*' \) | head -5) +# Microsoft's and isn't ours to ship. The one exception is ONNX Runtime's onnxruntime.dll, which Microsoft publishes +# under MIT, shipped with its licence (#110: tools/release/onnxruntime.sh) +ms=$(cd "$check/raea" && find . -type f \( -iname '*.dll' ! -path './bin/raea_bundle.dll' ! -path './bin/onnxruntime.dll' -o -iname 'vcruntime*' -o -iname 'msvcp*' -o -iname 'ucrtbase*' -o -iname 'api-ms-win*' -o -iname 'concrt*' -o -iname 'vccorlib*' -o -iname '*.lib' -o -iname '*.pdb' -o -iname 'd3dcompiler*' -o -iname 'dxcompiler*' -o -iname 'dxil*' \) | head -5) [ -z "$ms" ] || fail "files that aren't ours: $ms" +if [ -f "$check/raea/bin/raea.exe" ]; then + for f in onnxruntime.dll onnxruntime-LICENSE.txt onnxruntime-ThirdPartyNotices.txt; do + [ -f "$check/raea/bin/$f" ] || fail "bin/$f is missing: raea.exe loads ONNX Runtime from it, and its licence goes with it (#110)" + done +fi echo "release: $archive checked: an unpacked copy rendered a frame and checked an app on both targets with RAEA_NO_TREE=1" rm -rf "$check" diff --git a/tools/release.sh b/tools/release.sh index 498eff603..d34cd1f90 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -131,6 +131,12 @@ Wayland; Xvfb on a server, as raea app check does there too), libxkbcommon-x11, loader (Debian and Ubuntu: apt install libxkbcommon-x11-0 libxcursor1 libxi6 libxrandr2 libx11-xcb1 libvulkan1)." > "$stage/README" ;; windows-x86_64) cp "$bin/raea.exe" "$bin/raea_bundle.dll" "$bin/raea-perceive.exe" "$bin/raea-rune-host.exe" "$bin/raea-page-host.exe" "$stage/bin/" + # ONNX Runtime as Microsoft builds it (MIT), which raea.exe and raea-perceive.exe load when a model first runs (#110), + # with its licence and notices; tools/release/onnxruntime.sh put them beside the build + for f in onnxruntime.dll onnxruntime-LICENSE.txt onnxruntime-ThirdPartyNotices.txt; do + [ -f "$bin/$f" ] || { echo "release.sh: $bin has no $f (tools/release/onnxruntime.sh $bin)" >&2; exit 1; } + cp "$bin/$f" "$stage/bin/" + done # the C runtime isn't in the zip (ort's ONNX Runtime needs its DLLs, and they're Microsoft's to ship): the VC++ # redistributable, which most Windows machines already have, provides it printf '%s\r\n' "raea $version for Windows x86_64 (Windows 10 or 11, a DirectX 12 or Vulkan GPU driver; with no GPU, Mesa's lavapipe and WGPU_BACKEND=vulkan)." \ diff --git a/tools/release/onnxruntime.sh b/tools/release/onnxruntime.sh new file mode 100755 index 000000000..d92194ebe --- /dev/null +++ b/tools/release/onnxruntime.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Windows x64's ONNX Runtime as Microsoft builds it (the Microsoft.ML.OnnxRuntime package on NuGet, MIT): onnxruntime.dll, +# its LICENSE and its ThirdPartyNotices.txt, put in DEST beside raea.exe for tools/release.sh to pack. +# +# raea.exe loads it when a model first runs (ort's load-dynamic on Windows x64, #110). It used to link the static runtime +# ort downloads, which is built for AVX2: its static initializers ran before main, so raea.exe stopped at start on every +# CPU without AVX2 and BMI2 (an Ivy Bridge, a Celeron), whatever was asked of it. Microsoft's runtime picks its kernels +# by the CPU it finds; it loads and opens raea's models under Intel's emulator as an Ivy Bridge and a Sandy Bridge. +# 1.28.0 is the runtime the static build was (ort-sys 2.0.0-rc.13's ms@1.28.0); ort asks for API 17 or newer. +# tools/release/onnxruntime.sh DEST +set -euo pipefail +die() { echo "onnxruntime: $*" >&2; exit 1; } +dest=${1:?DEST} +v=1.28.0 +# the package's sha256; its sha512 is the one NuGet records for it (packageHash) +sum=769d1d3ea8ab6cd69f737c9dd4d4462aa4ad0ccfa106eaf506efc40d7bead5db +url=https://api.nuget.org/v3-flatcontainer/microsoft.ml.onnxruntime/$v/microsoft.ml.onnxruntime.$v.nupkg +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +curl -fsSL --retry 5 --retry-all-errors --connect-timeout 30 -o "$tmp/ort.nupkg" "$url" || die "couldn't download $url" +got=$( (sha256sum "$tmp/ort.nupkg" 2>/dev/null || shasum -a 256 "$tmp/ort.nupkg") | cut -d' ' -f1) +[ "$got" = "$sum" ] || die "Microsoft.ML.OnnxRuntime $v is $got, not the $sum pinned here" +unzip -q -o "$tmp/ort.nupkg" runtimes/win-x64/native/onnxruntime.dll LICENSE ThirdPartyNotices.txt -d "$tmp/x" +mkdir -p "$dest" +cp "$tmp/x/runtimes/win-x64/native/onnxruntime.dll" "$dest/onnxruntime.dll" +cp "$tmp/x/LICENSE" "$dest/onnxruntime-LICENSE.txt" +cp "$tmp/x/ThirdPartyNotices.txt" "$dest/onnxruntime-ThirdPartyNotices.txt" +echo "onnxruntime: Microsoft.ML.OnnxRuntime $v's onnxruntime.dll ($(wc -c < "$dest/onnxruntime.dll" | tr -d ' ') bytes) and its notices in $dest"