Skip to content

Commit 59be818

Browse files
authored
Merge pull request #1354 from elezar/optional-explicit-libraries
Make list of explicit driver libraries opt-in
2 parents 6dea491 + 5a3dcbe commit 59be818

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

pkg/nvcdi/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ const (
7777
type FeatureFlag string
7878

7979
const (
80+
// FeatureEnableExplicitDriverLibraries enables the inclusion of a list of
81+
// explicit driver libraries.
82+
FeatureEnableExplicitDriverLibraries = FeatureFlag("enable-explicit-driver-libraries")
8083
// FeatureDisableNvsandboxUtils disables the use of nvsandboxutils when
8184
// querying devices.
8285
FeatureDisableNvsandboxUtils = FeatureFlag("disable-nvsandbox-utils")

pkg/nvcdi/driver-nvml.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ func (l *nvcdilib) getVersionSuffixDriverLibraryMounts(version string) (discover
145145
}
146146

147147
func (l *nvcdilib) getExplicitDriverLibraryMounts() (discover.Discover, error) {
148+
if !l.featureFlags[FeatureEnableExplicitDriverLibraries] {
149+
return nil, nil
150+
}
151+
148152
// List of explicit libraries to locate
149153
// TODO(ArangoGutierrez): we should load the version of the libraries from
150154
// the sandboxutils-filelist or have a way to allow users to specify the

tests/e2e/installer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func NewToolkitInstaller(opts ...installerOption) (*ToolkitInstaller, error) {
8282
// PrepareCache ensures that the installer (package) cache is created on the runner.
8383
// The can be used to ensure that docker is not REQUIRED in an inner container.
8484
func (i *ToolkitInstaller) PrepareCache(runner Runner) (string, string, error) {
85+
if i.ToolkitImage == "disabled:disabled" {
86+
return "", "", nil
87+
}
8588
renderedScript, err := i.renderScript(prepareInstallerCacheTemplate, false)
8689
if err != nil {
8790
return "", "", err

tests/e2e/nvidia-container-toolkit_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,4 +516,21 @@ EOF`)
516516
Expect(strings.TrimSpace(stdout)).To(Equal("Unsuccessful"))
517517
})
518518
})
519+
520+
When("Running a container that installs ocl-icd-libopencl1", Ordered, func() {
521+
BeforeAll(func(ctx context.Context) {
522+
_, _, err := runner.Run("docker pull ubuntu")
523+
Expect(err).ToNot(HaveOccurred())
524+
})
525+
It("should succeed when using the nvidia-container-runtime", func(ctx context.Context) {
526+
_, _, err := runner.Run(`docker run --rm --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all -e NVIDIA_DRIVER_CAPABILITIES=all \
527+
ubuntu bash -c "apt-get update && apt-get install -y ocl-icd-libopencl1"`)
528+
Expect(err).ToNot(HaveOccurred())
529+
})
530+
It("should succeed when using the nvidia-container-runtime-hook", Label("legacy"), func(ctx context.Context) {
531+
_, _, err := runner.Run(`docker run --rm --runtime=runc --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=all \
532+
ubuntu bash -c "apt-get update && apt-get install -y ocl-icd-libopencl1"`)
533+
Expect(err).ToNot(HaveOccurred())
534+
})
535+
})
519536
})

0 commit comments

Comments
 (0)