mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 13:35:00 +00:00
Remove getNvidiaConfigLegacy() function
A subsequent commit will add equivalent functionality back in Signed-off-by: Kevin Klues <kklues@nvidia.com>
This commit is contained in:
parent
4791fab747
commit
430dda41e9
@ -245,78 +245,7 @@ func getRequirements(env map[string]string) []string {
|
|||||||
return requirements
|
return requirements
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mimic the new CUDA images if no capabilities or devices are specified.
|
|
||||||
func getNvidiaConfigLegacy(env map[string]string, privileged bool) *nvidiaConfig {
|
|
||||||
var devices string
|
|
||||||
if d := getDevices(env); d == nil {
|
|
||||||
// Environment variable unset: default to "all".
|
|
||||||
devices = "all"
|
|
||||||
} else if len(*d) == 0 || *d == "void" {
|
|
||||||
// Environment variable empty or "void": not a GPU container.
|
|
||||||
return nil
|
|
||||||
} else {
|
|
||||||
// Environment variable non-empty and not "void".
|
|
||||||
devices = *d
|
|
||||||
}
|
|
||||||
if devices == "none" {
|
|
||||||
devices = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var migConfigDevices string
|
|
||||||
if d := getMigConfigDevices(env); d != nil {
|
|
||||||
migConfigDevices = *d
|
|
||||||
}
|
|
||||||
if !privileged && migConfigDevices != "" {
|
|
||||||
log.Panicln("cannot set MIG_CONFIG_DEVICES in non privileged container")
|
|
||||||
}
|
|
||||||
|
|
||||||
var migMonitorDevices string
|
|
||||||
if d := getMigMonitorDevices(env); d != nil {
|
|
||||||
migMonitorDevices = *d
|
|
||||||
}
|
|
||||||
if !privileged && migMonitorDevices != "" {
|
|
||||||
log.Panicln("cannot set MIG_MONITOR_DEVICES in non privileged container")
|
|
||||||
}
|
|
||||||
|
|
||||||
var driverCapabilities string
|
|
||||||
if c := getDriverCapabilities(env); c == nil {
|
|
||||||
// Environment variable unset: default to "all".
|
|
||||||
driverCapabilities = allDriverCapabilities
|
|
||||||
} else if len(*c) == 0 {
|
|
||||||
// Environment variable empty: use default capability.
|
|
||||||
driverCapabilities = defaultDriverCapabilities
|
|
||||||
} else {
|
|
||||||
// Environment variable non-empty.
|
|
||||||
driverCapabilities = *c
|
|
||||||
}
|
|
||||||
if driverCapabilities == "all" {
|
|
||||||
driverCapabilities = allDriverCapabilities
|
|
||||||
}
|
|
||||||
|
|
||||||
requirements := getRequirements(env)
|
|
||||||
|
|
||||||
vmaj, vmin, _ := parseCudaVersion(env[envCUDAVersion])
|
|
||||||
cudaRequire := fmt.Sprintf("cuda>=%d.%d", vmaj, vmin)
|
|
||||||
requirements = append(requirements, cudaRequire)
|
|
||||||
|
|
||||||
// Don't fail on invalid values.
|
|
||||||
disableRequire, _ := strconv.ParseBool(env[envNVDisableRequire])
|
|
||||||
|
|
||||||
return &nvidiaConfig{
|
|
||||||
Devices: devices,
|
|
||||||
MigConfigDevices: migConfigDevices,
|
|
||||||
MigMonitorDevices: migMonitorDevices,
|
|
||||||
DriverCapabilities: driverCapabilities,
|
|
||||||
Requirements: requirements,
|
|
||||||
DisableRequire: disableRequire,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getNvidiaConfig(env map[string]string, privileged bool) *nvidiaConfig {
|
func getNvidiaConfig(env map[string]string, privileged bool) *nvidiaConfig {
|
||||||
if isLegacyCUDAImage(env) {
|
|
||||||
return getNvidiaConfigLegacy(env, privileged)
|
|
||||||
}
|
|
||||||
|
|
||||||
var devices string
|
var devices string
|
||||||
d := getDevices(env)
|
d := getDevices(env)
|
||||||
if d == nil || len(*d) == 0 || *d == "void" {
|
if d == nil || len(*d) == 0 || *d == "void" {
|
||||||
|
Loading…
Reference in New Issue
Block a user