Return an error if there aren't any TPU devices when --tpuproxy is enabled.

PiperOrigin-RevId: 667648344
This commit is contained in:
Lucas Manning
2024-08-26 11:18:02 -07:00
committed by gVisor bot
parent bc4a23853e
commit 8db8a6b7de
+5
View File
@@ -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
}