mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Update getDevices() to account for getting the devices list from mounts
Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
parent
f46d1861d3
commit
7313069d4c
@ -240,7 +240,25 @@ func getDevicesFromMounts(root string, mounts []Mount) *string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, privileged bool, legacyImage bool) *string {
|
func getDevices(hookConfig *HookConfig, env map[string]string, mounts []Mount, privileged bool, legacyImage bool) *string {
|
||||||
return getDevicesFromEnvvar(env, legacyImage)
|
// Try and get the device list from mount volumes first
|
||||||
|
devices := getDevicesFromMounts(*hookConfig.DeviceListVolumeMount, mounts)
|
||||||
|
if devices != nil {
|
||||||
|
return devices
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback to reading from the environment variable if privileges are correct
|
||||||
|
devices = getDevicesFromEnvvar(env, legacyImage)
|
||||||
|
if devices == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if privileged || hookConfig.AcceptEnvvarUnprivileged {
|
||||||
|
return devices
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error out otherwise
|
||||||
|
log.Panicln("insufficient privileges to read device list from NVIDIA_VISIBLE_DEVICES envvar")
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMigConfigDevices(env map[string]string) *string {
|
func getMigConfigDevices(env map[string]string) *string {
|
||||||
|
Loading…
Reference in New Issue
Block a user