MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / list_devices

Method list_devices

vmm/src/config.rs:263–284  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

261
262impl GpuConfig {
263 pub(crate) fn list_devices(&self) -> Result<Vec<Device>> {
264 let devices = lspci_filtered(|dev| {
265 if !self.listing.contains(&dev.full_product_id()) {
266 return false;
267 }
268 if self.exclude.contains(&dev.slot) {
269 return false;
270 }
271 if !self.include.is_empty() && !self.include.contains(&dev.slot) {
272 return false;
273 }
274 true
275 })
276 .context("Failed to list GPU devices")?;
277
278 info!(
279 "Found {} GPUs, {} in use",
280 devices.len(),
281 devices.iter().filter(|d| d.in_use()).count()
282 );
283 Ok(devices)
284 }
285}
286
287#[derive(Debug, Clone, Default, Deserialize)]

Callers 1

list_gpusMethod · 0.80

Calls 4

lspci_filteredFunction · 0.85
containsMethod · 0.80
full_product_idMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected