Skip to content

Commit

Permalink
Return an error if there aren't any TPU devices when --tpuproxy is en…
Browse files Browse the repository at this point in the history
…abled.

PiperOrigin-RevId: 667648344
  • Loading branch information
manninglucas authored and gvisor-bot committed Aug 26, 2024
1 parent bc4a238 commit 8db8a6b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runsc/cmd/chroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,21 @@ func tpuProxyUpdateChroot(chroot string, spec *specs.Spec, conf *config.Config)
// Bind mount device info directories for all TPU devices on the host.
// For v4 TPU, the directory /sys/devices/<pci_bus>/<pci_address>/accel/accel# is mounted;
// For v5e TPU, the directory /sys/devices/<pci_bus>/<pci_address>/vfio-dev/vfio# is mounted.
foundDevices := false
for pathGlob, sysfsFormat := range pathGlobToSysfsFormat {
paths, err := filepath.Glob(pathGlob)
if err != nil {
return fmt.Errorf("enumerating TPU device files: %w", err)
}
for _, devPath := range paths {
foundDevices = true
if err := mountTPUDeviceInfoInChroot(chroot, devPath, sysfsFormat, pathGlobToPciDeviceFormat[pathGlob]); err != nil {
return err
}
}
}
if !foundDevices {
return fmt.Errorf("could not find any TPU devices on the host")
}
return nil
}

0 comments on commit 8db8a6b

Please sign in to comment.