Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
33 lines
1.6 KiB
Rust
33 lines
1.6 KiB
Rust
//! Explicit loader probe for an operator-trusted engine with a side-effect-free --help.
|
|
use std::{error::Error, ffi::OsStr, process::Stdio, time::Duration};
|
|
use tokio::{process::Command, time::timeout};
|
|
|
|
pub async fn check(executable: &OsStr) -> Result<(), Box<dyn Error>> {
|
|
// Keep the memfd alive until the help process has exited. Serving may have
|
|
// already resolved the payload and keeps its own lifetime guard.
|
|
let embedded = crate::embedded_engine::resolve(executable)?;
|
|
let executable = embedded
|
|
.as_ref()
|
|
.map_or(executable, |e| e.executable.as_os_str());
|
|
let mut child = Command::new(executable)
|
|
.arg("--help")
|
|
.env("CUDA_VISIBLE_DEVICES", "")
|
|
.stdin(Stdio::null())
|
|
.stdout(Stdio::null())
|
|
.stderr(Stdio::null())
|
|
.kill_on_drop(true)
|
|
.spawn()
|
|
.map_err(|_| "engine loader probe could not start; check executable permissions, ELF architecture and loader/shared-library dependencies")?;
|
|
match timeout(Duration::from_secs(10), child.wait()).await {
|
|
Ok(Ok(status)) if status.success() => Ok(()),
|
|
Ok(Ok(status)) => Err(format!("engine --help probe failed ({status}); check loader/shared-library dependencies or use a profile with a working --help command").into()),
|
|
failure => {
|
|
let _ = child.kill().await;
|
|
Err(match failure {
|
|
Err(_) => "engine --help probe timed out after 10 seconds; check the selected engine before preparing the model",
|
|
_ => "engine --help probe could not be collected; check the selected engine",
|
|
}.into())
|
|
}
|
|
}
|
|
}
|