Skip to content

Commit 045e470

Browse files
author
haixuanTao
committed
fixing workflow configuration
fix apple gpu download bug adding windows bindings fixing apple no gpu problem fixing workflow mistake
1 parent 61f05c5 commit 045e470

File tree

6 files changed

+36
-25
lines changed

6 files changed

+36
-25
lines changed

.github/workflows/general.yml

+2-7
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,17 @@ jobs:
7373
# ******************************************************************
7474
- name: Download prebuilt archive (GPU, x86_64-unknown-linux-gnu)
7575
uses: actions-rs/cargo@v1
76-
env:
77-
ORT_USE_CUDA: "yes"
7876
with:
7977
command: build
80-
args: --target x86_64-unknown-linux-gnu
78+
args: --target x86_64-unknown-linux-gnu --features cuda
8179
- name: Verify prebuilt archive downloaded (GPU, x86_64-unknown-linux-gnu)
8280
run: ls -lh target/x86_64-unknown-linux-gnu/debug/build/onnxruntime-sys-*/out/onnxruntime-linux-x64-gpu-1.*.tgz
8381
# ******************************************************************
8482
- name: Download prebuilt archive (GPU, x86_64-pc-windows-msvc)
8583
uses: actions-rs/cargo@v1
86-
env:
87-
ORT_USE_CUDA: "yes"
8884
with:
8985
command: build
90-
args: --target x86_64-pc-windows-msvc
86+
args: --target x86_64-pc-windows-msvc --features cuda
9187
- name: Verify prebuilt archive downloaded (GPU, x86_64-pc-windows-msvc)
9288
run: ls -lh target/x86_64-pc-windows-msvc/debug/build/onnxruntime-sys-*/out/onnxruntime-win-gpu-x64-1.*.zip
9389

@@ -141,7 +137,6 @@ jobs:
141137
uses: actions-rs/cargo@v1
142138
with:
143139
command: build
144-
# Use --manifest-path instead of --package. See https://github.com/actions-rs/cargo/issues/86
145140
args: --manifest-path onnxruntime/Cargo.toml --features model-fetching
146141
- name: Test onnxruntime-sys
147142
uses: actions-rs/cargo@v1

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Generate the bindings:
242242
```sh
243243
❯ docker exec -it --user "$(id -u)":"$(id -g)" rustbuilder /bin/bash
244244
cd onnxruntime-sys
245-
❯ cargo build --features generate-bindings
245+
❯ cargo build --features 'generate-bindings, cuda'
246246
```
247247

248248
### Generating Bindings for Windows With Vagrant
@@ -255,8 +255,8 @@ Windows can build both x86 and x86_64 bindings:
255255
```sh
256256
❯ rustup target add i686-pc-windows-msvc x86_64-pc-windows-msvc
257257
cd onnxruntime-sys
258-
❯ cargo build --features generate-bindings --target i686-pc-windows-msvc
259-
❯ cargo build --features generate-bindings --target x86_64-pc-windows-msvc
258+
❯ cargo build --features 'generate-bindings, cuda' --target i686-pc-windows-msvc
259+
❯ cargo build --features 'generate-bindings, cuda' --target x86_64-pc-windows-msvc
260260
```
261261

262262
## Conduct

onnxruntime-sys/examples/c_api_sample.rs

-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ fn main() {
4949
};
5050

5151
// Optionally add more execution providers via session_options
52-
// E.g. for CUDA include cuda_provider_factory.h and uncomment the following line:
53-
// OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0);
5452

5553
//*************************************************************************
5654
// create session and load model into memory

onnxruntime-sys/src/generated/windows/x86_64/bindings.rs

+27-10
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,21 @@ extern "C" {
476476
_Alignment: usize,
477477
) -> *mut ::std::os::raw::c_void;
478478
}
479-
pub type max_align_t = f64;
479+
extern "C" {
480+
pub fn _errno() -> *mut ::std::os::raw::c_int;
481+
}
482+
extern "C" {
483+
pub fn _set_errno(_Value: ::std::os::raw::c_int) -> errno_t;
484+
}
485+
extern "C" {
486+
pub fn _get_errno(_Value: *mut ::std::os::raw::c_int) -> errno_t;
487+
}
488+
extern "C" {
489+
pub fn __threadid() -> ::std::os::raw::c_ulong;
490+
}
491+
extern "C" {
492+
pub fn __threadhandle() -> usize;
493+
}
480494
pub type _CoreCrtSecureSearchSortCompareFunction = ::std::option::Option<
481495
unsafe extern "C" fn(
482496
arg1: *mut ::std::os::raw::c_void,
@@ -975,15 +989,6 @@ extern "C" {
975989
extern "C" {
976990
pub fn _set_error_mode(_Mode: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
977991
}
978-
extern "C" {
979-
pub fn _errno() -> *mut ::std::os::raw::c_int;
980-
}
981-
extern "C" {
982-
pub fn _set_errno(_Value: ::std::os::raw::c_int) -> errno_t;
983-
}
984-
extern "C" {
985-
pub fn _get_errno(_Value: *mut ::std::os::raw::c_int) -> errno_t;
986-
}
987992
extern "C" {
988993
pub fn __doserrno() -> *mut ::std::os::raw::c_ulong;
989994
}
@@ -6626,6 +6631,18 @@ fn bindgen_test_layout_OrtCustomOp() {
66266631
)
66276632
);
66286633
}
6634+
extern "C" {
6635+
pub fn OrtSessionOptionsAppendExecutionProvider_CPU(
6636+
options: *mut OrtSessionOptions,
6637+
use_arena: ::std::os::raw::c_int,
6638+
) -> OrtStatusPtr;
6639+
}
6640+
extern "C" {
6641+
pub fn OrtSessionOptionsAppendExecutionProvider_CUDA(
6642+
options: *mut OrtSessionOptions,
6643+
device_id: ::std::os::raw::c_int,
6644+
) -> OrtStatusPtr;
6645+
}
66296646
#[repr(C)]
66306647
#[derive(Debug, Copy, Clone)]
66316648
pub struct __crt_locale_data {

onnxruntime-sys/wrapper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "onnxruntime_c_api.h"
2-
#include "cpu_provider_factory.h"
32
#if !defined(__APPLE__)
3+
#include "cpu_provider_factory.h"
44
#include "cuda_provider_factory.h"
5-
#endif
5+
#endif

onnxruntime/src/session.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,16 @@ impl<'a> SessionBuilder<'a> {
131131
}
132132

133133
/// Set the session to use cpu
134+
#[cfg(feature = "cuda")]
134135
pub fn use_cpu(self, use_arena: i32) -> Result<SessionBuilder<'a>> {
135136
unsafe {
136137
sys::OrtSessionOptionsAppendExecutionProvider_CPU(self.session_options_ptr, use_arena);
137138
}
138139
Ok(self)
139140
}
140141

141-
#[cfg(feature = "cuda")]
142142
/// Set the session to use cuda
143+
#[cfg(feature = "cuda")]
143144
pub fn use_cuda(self, device_id: i32) -> Result<SessionBuilder<'a>> {
144145
unsafe {
145146
sys::OrtSessionOptionsAppendExecutionProvider_CUDA(self.session_options_ptr, device_id);

0 commit comments

Comments
 (0)