Skip to content

Commit 30602d6

Browse files
committed
Add config option for ContainerConfigRoot
This change allows the container compat root for nvgpu (e.g. Orin) systems to be specified either as the nvidia-container-runtime.modes.csv.container-compat-root option in the config.toml file, or with the --csv.container-compat-root (NVIDIA_CTK_CDI_GENERATE_CSV_CONTAINER_COMPAT_ROOT) option when generating CDI specifications. A WithCSVContainerCompatRoot option is also exposed in the nvcdi API. Note that this option is only relevant when nvgpu devices are detected. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent f7004ac commit 30602d6

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ type options struct {
7070
featureFlags []string
7171

7272
csv struct {
73-
files []string
74-
ignorePatterns []string
73+
files []string
74+
ignorePatterns []string
75+
containerCompatRoot string
7576
}
7677

7778
noAllDevice bool
@@ -212,6 +213,12 @@ func (m command) build() *cli.Command {
212213
Destination: &opts.csv.ignorePatterns,
213214
Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_CSV_IGNORE_PATTERNS"),
214215
},
216+
&cli.StringFlag{
217+
Name: "csv.container-compat-root",
218+
Usage: "specify the container folder to use for CUDA Forward Compatibility in non-standard containers",
219+
Destination: &opts.csv.containerCompatRoot,
220+
Sources: cli.EnvVars("NVIDIA_CTK_CDI_GENERATE_CSV_CONTAINER_COMPAT_ROOT"),
221+
},
215222
&cli.StringSliceFlag{
216223
Name: "disable-hook",
217224
Aliases: []string{"disable-hooks"},
@@ -384,6 +391,7 @@ func (m command) generateSpecs(opts *options) ([]generatedSpecs, error) {
384391
nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths),
385392
nvcdi.WithCSVFiles(opts.csv.files),
386393
nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns),
394+
nvcdi.WithCSVContainerCompatRoot(opts.csv.containerCompatRoot),
387395
nvcdi.WithDisabledHooks(opts.disabledHooks...),
388396
nvcdi.WithEnabledHooks(opts.enabledHooks...),
389397
nvcdi.WithFeatureFlags(opts.featureFlags...),

internal/config/runtime.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type jitCDIModeConfig struct {
5353

5454
type csvModeConfig struct {
5555
MountSpecPath string `toml:"mount-spec-path"`
56+
// ContainerCompatRoot specifies the compat root used when the the standard
57+
// CUDA compat libraries should not be used.
58+
ContainerCompatRoot string `toml:"container-compat-root"`
5659
}
5760

5861
type legacyModeConfig struct {

internal/modifier/csv.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func NewCSVModifier(logger logger.Interface, cfg *config.Config, container image
5959
nvcdi.WithNVIDIACDIHookPath(cfg.NVIDIACTKConfig.Path),
6060
nvcdi.WithMode(nvcdi.ModeCSV),
6161
nvcdi.WithCSVFiles(csvFiles),
62+
nvcdi.WithCSVContainerCompatRoot(cfg.NVIDIAContainerRuntimeConfig.Modes.CSV.ContainerCompatRoot),
6263
)
6364
if err != nil {
6465
return nil, fmt.Errorf("failed to construct CDI library: %v", err)

pkg/nvcdi/lib-csv.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ import (
3737
)
3838

3939
type csvOptions struct {
40-
Files []string
41-
IgnorePatterns []string
40+
Files []string
41+
IgnorePatterns []string
42+
ContainerCompatRoot string
4243
}
4344

4445
type csvlib nvcdilib
@@ -52,6 +53,9 @@ func (l *nvcdilib) asCSVLib() *csvlib {
5253
if len(l.csv.Files) == 0 {
5354
l.csv.Files = csv.DefaultFileList()
5455
}
56+
if l.csv.ContainerCompatRoot == "" {
57+
l.csv.ContainerCompatRoot = "/usr/local/cuda/compat-orin"
58+
}
5559
return (*csvlib)(l)
5660
}
5761

@@ -481,7 +485,7 @@ func (l *csvlib) cudaCompatDiscoverer() discover.Discover {
481485
// TODO: Should this be overridable through a feature flag / config option?
482486
if strings.Contains(name, "Orin (nvgpu)") {
483487
// TODO: This should probably be a constant or configurable.
484-
cudaCompatContainerRoot = "/usr/local/cuda/compat-orin"
488+
cudaCompatContainerRoot = l.csv.ContainerCompatRoot
485489
break
486490
}
487491
}

pkg/nvcdi/options.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ func WithCSVIgnorePatterns(csvIgnorePatterns []string) Option {
142142
}
143143
}
144144

145+
// WithCSVContainerCompatRoot sets the compat root to use for the container in
146+
// the case of nvgpu-only devices.
147+
func WithCSVContainerCompatRoot(csvContainerCompatRoot string) Option {
148+
return func(o *nvcdilib) {
149+
o.csv.ContainerCompatRoot = csvContainerCompatRoot
150+
}
151+
}
152+
145153
// WithConfigSearchPaths sets the search paths for config files.
146154
func WithConfigSearchPaths(paths []string) Option {
147155
return func(o *nvcdilib) {

0 commit comments

Comments
 (0)