pykeio / ort

Fast ML inference & training for Rust with ONNX Runtime
https://ort.pyke.io/
Apache License 2.0
786 stars 91 forks source link

Cannot build ort-2.0.0-rc.2 on Windows Server 2019 #239

Closed Chiranmb closed 1 month ago

Chiranmb commented 1 month ago

I was trying to run an inference on an onnx model that I had converted from Tensorflow. It worked fine on my MacBook but when I tried the same on a VM on Azure, I got the following error message when compiling my app:

PS C:\Users\myname\Desktop\ort-test> cargo run
    Blocking waiting for file lock on package cache
   Compiling cfg-if v1.0.0
   Compiling getrandom v0.2.15
   Compiling once_cell v1.19.0
   Compiling quote v1.0.36
   Compiling filetime v0.2.23
   Compiling ring v0.17.8
   Compiling crc32fast v1.4.2
   Compiling syn v2.0.71
   Compiling sha2 v0.10.8
   Compiling flate2 v1.0.30
   Compiling tar v0.4.41
   Compiling num-traits v0.2.19
   Compiling rawpointer v0.2.1
   Compiling matrixmultiply v0.3.8
   Compiling num-integer v0.1.46
   Compiling rustls-webpki v0.102.5
   Compiling rustls v0.23.11
   Compiling num-complex v0.4.6
   Compiling tracing-core v0.1.32
   Compiling pin-project-lite v0.2.14
   Compiling ndarray v0.15.6
   Compiling half v2.4.1
   Compiling tracing-attributes v0.1.27
   Compiling thiserror-impl v1.0.62
   Compiling ureq v2.10.0
   Compiling thiserror v1.0.62
   Compiling tracing v0.1.40
   Compiling ort-sys v2.0.0-rc.4
error: failed to run custom build command for `ort-sys v2.0.0-rc.4`

Caused by:
  process didn't exit successfully: `C:\Users\myname\Desktop\ort-test\target\debug\build\ort-sys-777b9668927fecb2\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-env-changed=LIBONNXRUNTIME_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=LIBONNXRUNTIME_STATIC
  cargo:rerun-if-env-changed=LIBONNXRUNTIME_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=LIBONNXRUNTIME_STATIC
  cargo:rerun-if-env-changed=LIBONNXRUNTIME_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
  cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_msvc
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  onnxruntime not found using pkg-config, falling back to manual setup.
  cargo:rerun-if-env-changed=ORT_LIB_LOCATION
  cargo:rerun-if-env-changed=ORT_LIB_PROFILE
  selected feature set: none

  --- stderr
  thread 'main' panicked at C:\Users\myname\.cargo\registry\src\index.crates.io-6f17d22bba15001f\ort-sys-2.0.0-rc.4\build.rs:29:31:
  Failed to GET `https://parcel.pyke.io/v2/delivery/ortrs/packages/msort-binary/1.18.1/ortrs-msort_static-v1.18.1-x86_64-pc-windows-msvc.tgz`: https://parcel.pyke.io/v2/delivery/ortrs/packages/msort-binary/1.18.1/ortrs-msort_static-v1.18.1-x86_64-pc-windows-msvc.tgz: Connection Failed: tls connection init failed: unexpected end of file
  note: run with `RUST_BACKTRACE=1` environment variable to display a b

This is my Cargo.toml file for reference:

name = "ort-test"
version = "0.1.0"
edition = "2021"

[dependencies]
ort = "2.0.0-rc.2"

And my main.rs

use ort::{GraphOptimizationLevel, Session};

fn main() {

    let resource_path = "model_registry/onnx_model";
    let plus_model = Session::builder().unwrap()
        .with_optimization_level(GraphOptimizationLevel::Level3).unwrap()
        .with_intra_threads(1).unwrap()
        .commit_from_file(resource_path).unwrap();
}

Not sure why its not working on the Windows VM.

Some info about the device:

Windows Server 2019 Datacenter Intel(R) Xeon(R) Platinum 8171M CPU @ 2.60GHz 2.10 GHz x86_64-pc-windows-msvc.exe

decahedron1 commented 1 month ago

Connection Failed: tls connection init failed: unexpected end of file

Strange - can the VM access the internet? Is the parcel.pyke.io domain being blocked?

Chiranmb commented 1 month ago

Connection Failed: tls connection init failed: unexpected end of file

Strange - can the VM access the internet? Is the parcel.pyke.io domain being blocked?

The VM can access the internet. It seems that its the parcel.pyke.io domain being blocked.

When I try to visit it on any browser, I get the error message:

Action: Deny. Reason: No rule matched. Proceeding with default action.

I found a similar error at the end of this discussion, but given that I have not blocked any domains on my VM, im not sure how I can resolve this

Chiranmb commented 1 month ago

@decahedron1 Sorry, what does it mean if the issue is closed as not planned?

decahedron1 commented 1 month ago

It just means that this issue is unactionable on my side 🙂

Chiranmb commented 1 month ago

Fair enough. Do you have any suggestions or alternatives? I linked the other discussion to highlight the fact that this is a known issue when compiling the ort crate so I had hoped that maybe you had some ideas on how to workaround this. Is there also a chance its the domain blocking the VM? And if im able to get the .tgz file in another device is there a way i can send that to my VM to help with the installation?

decahedron1 commented 1 month ago

Unfortunately, every time I've used the Azure platform, I've gotten lost, so I'm not familiar with their compute offerings or firewall configuration. Apparently, there's a default firewall rule that isn't permitting parcel.pyke.io (for whatever reason). I think it would be easiest in the long run to add a firewall exclusion for the domain, but if that's not possible, you could extract the .tgz somewhere and set the environment variable ORT_LIB_LOCATION to the path the archive was extracted to. (If you're using CUDA binaries, you'll need to set up load-dynamic instead).

Chiranmb commented 1 month ago

ok thank you