diff --git a/Cargo.lock b/Cargo.lock index be8e47dbd..0acc5fcc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5906,7 +5906,6 @@ dependencies = [ "clap", "either", "fs-err 3.1.1", - "regex", "schemars", "serde", "thiserror 2.0.12", diff --git a/crates/uv-torch/Cargo.toml b/crates/uv-torch/Cargo.toml index 2190598e7..fdaa4653e 100644 --- a/crates/uv-torch/Cargo.toml +++ b/crates/uv-torch/Cargo.toml @@ -19,7 +19,6 @@ uv-static = { workspace = true } clap = { workspace = true, optional = true } either = { workspace = true } fs-err = { workspace = true } -regex = { workspace = true } schemars = { workspace = true, optional = true } serde = { workspace = true } thiserror = { workspace = true } diff --git a/crates/uv-torch/src/accelerator.rs b/crates/uv-torch/src/accelerator.rs index 1ae4fa07e..0bcdca246 100644 --- a/crates/uv-torch/src/accelerator.rs +++ b/crates/uv-torch/src/accelerator.rs @@ -1,7 +1,6 @@ use std::path::Path; use std::str::FromStr; -use regex::Regex; use tracing::debug; use walkdir::WalkDir; @@ -64,7 +63,6 @@ impl Accelerator { /// 5. `nvidia-smi --query-gpu=driver_version --format=csv,noheader`. /// 6. `rocm_agent_enumerator`, which lists the AMD GPU architectures. /// 7. `/sys/bus/pci/devices`, filtering for the Intel GPU via PCI. - /// 8. `powershell` command querying `Win32_VideoController` to detect Intel GPU. pub fn detect() -> Result, AcceleratorError> { // Constants used for PCI device detection const PCI_BASE_CLASS_MASK: u32 = 0x00ff_0000; @@ -202,33 +200,6 @@ impl Accelerator { } } - // Query Intel GPU by `powershell` command via `Win32_VideoController`. - // - // See: https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-videocontroller - if let Ok(output) = std::process::Command::new("powershell") - .arg("-Command") - .arg("Get-WmiObject Win32_VideoController | Select-Object -ExpandProperty PNPDeviceID") - .output() - { - if output.status.success() { - let stdout = String::from_utf8(output.stdout)?; - let re = Regex::new(r"VEN_([0-9A-Fa-f]{4})").unwrap(); - for caps in re.captures_iter(&stdout) { - let vendor = u32::from_str_radix(&caps[1], 16)?; - if vendor == PCI_VENDOR_ID_INTEL { - debug!("Detected Intel GPU from PCI, vendor=0x{:04x}", vendor); - return Ok(Some(Self::Xpu)); - } - } - } else { - debug!( - "Failed to query Intel GPU with powershell with status `{}`: {}", - output.status, - String::from_utf8_lossy(&output.stderr) - ); - } - } - debug!("Failed to detect GPU driver version"); Ok(None) diff --git a/crates/uv-torch/src/backend.rs b/crates/uv-torch/src/backend.rs index 646fdb7f3..5ad71b385 100644 --- a/crates/uv-torch/src/backend.rs +++ b/crates/uv-torch/src/backend.rs @@ -351,10 +351,11 @@ impl TorchStrategy { } }, TorchStrategy::Xpu { os } => match os { - Os::Manylinux { .. } | Os::Windows => Either::Right(Either::Right(Either::Left( + Os::Manylinux { .. } => Either::Right(Either::Right(Either::Left( std::iter::once(TorchBackend::Xpu.index_url()), ))), - Os::Musllinux { .. } + Os::Windows + | Os::Musllinux { .. } | Os::Macos { .. } | Os::FreeBsd { .. } | Os::NetBsd { .. } diff --git a/docs/guides/integration/pytorch.md b/docs/guides/integration/pytorch.md index 880293a72..f060cbb6b 100644 --- a/docs/guides/integration/pytorch.md +++ b/docs/guides/integration/pytorch.md @@ -460,4 +460,12 @@ $ # With an environment variable. $ UV_TORCH_BACKEND=cu126 uv pip install torch torchvision ``` +On Windows, Intel GPU (XPU) is not automatically selected with `--torch-backend=auto`, but you can +manually specify it using `--torch-backend=xpu`: + +```shell +$ # Manual selection for Intel GPU. +$ uv pip install torch torchvision --torch-backend=xpu +``` + At present, `--torch-backend` is only available in the `uv pip` interface.