mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 13:35:00 +00:00
Merge branch 'set-default-to-index' into 'main'
Use device index as CDI device names by default See merge request nvidia/container-toolkit/container-toolkit!273
This commit is contained in:
commit
6d1639a513
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## v1.12.0-rc.4
|
## v1.12.0-rc.4
|
||||||
|
|
||||||
|
* Generate a minimum CDI spec version for improved compatibility.
|
||||||
|
* Add `--device-name-strategy` options to the `nvidia-ctk cdi generate` command that can be used to control how device names are constructed.
|
||||||
|
* Set default for CDI device name generation to `index` to generate device names such as `nvidia.com/gpu=0` or `nvidia.com/gpu=1:0` by default.
|
||||||
## v1.12.0-rc.3
|
## v1.12.0-rc.3
|
||||||
|
|
||||||
* Don't fail if by-path symlinks for DRM devices do not exist
|
* Don't fail if by-path symlinks for DRM devices do not exist
|
||||||
|
@ -89,8 +89,8 @@ func (m command) build() *cli.Command {
|
|||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "device-name-strategy",
|
Name: "device-name-strategy",
|
||||||
Usage: "Specify the strategy for generating device names. One of [type-index | index | uuid]",
|
Usage: "Specify the strategy for generating device names. One of [index | uuid | type-index]",
|
||||||
Value: deviceNameStrategyTypeIndex,
|
Value: deviceNameStrategyIndex,
|
||||||
Destination: &cfg.deviceNameStrategy,
|
Destination: &cfg.deviceNameStrategy,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
@ -117,7 +117,7 @@ func (m command) validateFlags(r *cli.Context, cfg *config) error {
|
|||||||
return fmt.Errorf("invalid output format: %v", cfg.format)
|
return fmt.Errorf("invalid output format: %v", cfg.format)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := NewDeviceNamer(cfg.deviceNameStrategy)
|
_, err := newDeviceNamer(cfg.deviceNameStrategy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ func (m command) validateFlags(r *cli.Context, cfg *config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m command) run(c *cli.Context, cfg *config) error {
|
func (m command) run(c *cli.Context, cfg *config) error {
|
||||||
deviceNamer, err := NewDeviceNamer(cfg.deviceNameStrategy)
|
deviceNamer, err := newDeviceNamer(cfg.deviceNameStrategy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create device namer: %v", err)
|
return fmt.Errorf("failed to create device namer: %v", err)
|
||||||
}
|
}
|
||||||
@ -279,6 +279,8 @@ func (m command) generateSpec(root string, nvidiaCTKPath string, namer deviceNam
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to get minumum required CDI spec version: %v", err)
|
return nil, fmt.Errorf("failed to get minumum required CDI spec version: %v", err)
|
||||||
}
|
}
|
||||||
|
m.logger.Infof("Using minimum required CDI spec version: %s", minVersion)
|
||||||
|
|
||||||
spec.Version = minVersion
|
spec.Version = minVersion
|
||||||
|
|
||||||
return &spec, nil
|
return &spec, nil
|
||||||
|
@ -40,9 +40,9 @@ type deviceNameIndex struct {
|
|||||||
}
|
}
|
||||||
type deviceNameUUID struct{}
|
type deviceNameUUID struct{}
|
||||||
|
|
||||||
// NewDeviceNamer creates a Device Namer based on the supplied strategy.
|
// newDeviceNamer creates a Device Namer based on the supplied strategy.
|
||||||
// This namer can be used to construct the names for MIG and GPU devices when generating the CDI spec.
|
// This namer can be used to construct the names for MIG and GPU devices when generating the CDI spec.
|
||||||
func NewDeviceNamer(strategy string) (deviceNamer, error) {
|
func newDeviceNamer(strategy string) (deviceNamer, error) {
|
||||||
switch strategy {
|
switch strategy {
|
||||||
case deviceNameStrategyIndex:
|
case deviceNameStrategyIndex:
|
||||||
return deviceNameIndex{}, nil
|
return deviceNameIndex{}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user