mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Remove auto-detection for XPU on Windows
This commit is contained in:
parent
2fdfe34853
commit
5bb8b45e33
5 changed files with 11 additions and 33 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5906,7 +5906,6 @@ dependencies = [
|
|||
"clap",
|
||||
"either",
|
||||
"fs-err 3.1.1",
|
||||
"regex",
|
||||
"schemars",
|
||||
"serde",
|
||||
"thiserror 2.0.12",
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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<Option<Self>, 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)
|
||||
|
|
|
@ -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 { .. }
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue