Skip to content

Commit 2f1f798

Browse files
committed
Use fs_err:read_dir instead of Walkdir
1 parent 5bb8b45 commit 2f1f798

3 files changed

Lines changed: 5 additions & 20 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/uv-torch/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ serde = { workspace = true }
2424
thiserror = { workspace = true }
2525
tracing = { workspace = true }
2626
url = { workspace = true }
27-
walkdir = { workspace = true }
2827

2928
[lints]
3029
workspace = true

crates/uv-torch/src/accelerator.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::path::Path;
22
use std::str::FromStr;
33

44
use tracing::debug;
5-
use walkdir::WalkDir;
65

76
use uv_pep440::Version;
87
use uv_static::EnvVars;
@@ -17,8 +16,6 @@ pub enum AcceleratorError {
1716
Utf8(#[from] std::string::FromUtf8Error),
1817
#[error(transparent)]
1918
ParseInt(#[from] std::num::ParseIntError),
20-
#[error(transparent)]
21-
WalkDir(#[from] walkdir::Error),
2219
#[error("Unknown AMD GPU architecture: {0}")]
2320
UnknownAmdGpuArchitecture(String),
2421
}
@@ -168,15 +165,10 @@ impl Accelerator {
168165
}
169166

170167
// Read from `/sys/bus/pci/devices` to filter for Intel GPU via PCI.
171-
match WalkDir::new("/sys/bus/pci/devices")
172-
.min_depth(1)
173-
.max_depth(1)
174-
.into_iter()
175-
.collect::<Result<Vec<_>, _>>()
176-
{
168+
match fs_err::read_dir("/sys/bus/pci/devices") {
177169
Ok(entries) => {
178-
for entry in entries {
179-
match parse_pci_device_ids(entry.path()) {
170+
for entry in entries.flatten() {
171+
match parse_pci_device_ids(&entry.path()) {
180172
Ok((class, vendor)) => {
181173
if (class & PCI_BASE_CLASS_MASK) == PCI_BASE_CLASS_DISPLAY
182174
&& vendor == PCI_VENDOR_ID_INTEL
@@ -191,13 +183,8 @@ impl Accelerator {
191183
}
192184
}
193185
}
194-
Err(e)
195-
if e.io_error()
196-
.is_some_and(|io| io.kind() == std::io::ErrorKind::NotFound) => {}
197-
Err(e) => {
198-
debug!("Failed to read PCI device directory with WalkDir: {e}");
199-
return Err(e.into());
200-
}
186+
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
187+
Err(e) => return Err(e.into()),
201188
}
202189

203190
debug!("Failed to detect GPU driver version");

0 commit comments

Comments
 (0)