Skip to content

Commit 77bfb3c

Browse files
committed
Add basic integration tests for forward compat
Signed-off-by: Evan Lezar <[email protected]>
1 parent 24dfcdd commit 77bfb3c

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

tests/e2e/nvidia-container-toolkit_test.go

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ package e2e
1818

1919
import (
2020
"context"
21+
"path/filepath"
22+
"strings"
2123

2224
. "github.com/onsi/ginkgo/v2"
2325
. "github.com/onsi/gomega"
2426
)
2527

2628
// Integration tests for Docker runtime
27-
var _ = Describe("docker", Ordered, func() {
29+
var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
2830
var r Runner
2931

3032
// Install the NVIDIA Container Toolkit
@@ -160,4 +162,59 @@ var _ = Describe("docker", Ordered, func() {
160162
Expect(referenceOutput).To(Equal(out4))
161163
})
162164
})
165+
166+
Describe("CUDA Forward compatibility", Ordered, func() {
167+
BeforeAll(func(ctx context.Context) {
168+
_, _, err := r.Run("docker pull nvcr.io/nvidia/cuda:12.8.0-base-ubi8")
169+
Expect(err).ToNot(HaveOccurred())
170+
})
171+
172+
var compatExpected bool
173+
BeforeAll(func(ctx context.Context) {
174+
compatOutput, _, err := r.Run("docker run --rm -i -e NVIDIA_VISIBLE_DEVICES=void nvcr.io/nvidia/cuda:12.8.0-base-ubi8 bash -c \"ls /usr/local/cuda/compat/libcuda.*.*\"")
175+
Expect(err).ToNot(HaveOccurred())
176+
Expect(compatOutput).ToNot(BeEmpty())
177+
compatDriverVersion := strings.TrimPrefix(filepath.Base(compatOutput), "libcuda.so.")
178+
compatMajor := strings.SplitN(compatDriverVersion, ".", 2)[0]
179+
180+
driverOutput, _, err := r.Run("nvidia-smi -q | grep \"Driver Version\"")
181+
Expect(err).ToNot(HaveOccurred())
182+
parts := strings.SplitN(driverOutput, ":", 2)
183+
Expect(parts).To(HaveLen(2))
184+
185+
hostDriverVersion := strings.TrimSpace(parts[1])
186+
Expect(hostDriverVersion).ToNot(BeEmpty())
187+
driverMajor := strings.SplitN(hostDriverVersion, ".", 2)[0]
188+
189+
if compatMajor > driverMajor {
190+
compatExpected = true
191+
}
192+
})
193+
194+
It("should work with the nvidia runtime in legacy mode", func(ctx context.Context) {
195+
ldconfigOut, _, err := r.Run("docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia --gpus all nvcr.io/nvidia/cuda:12.8.0-base-ubi8 bash -c \"ldconfig -p | grep libcuda.so.1\"")
196+
Expect(err).ToNot(HaveOccurred())
197+
if compatExpected {
198+
Expect(ldconfigOut).To(ContainSubstring("/usr/local/cuda/compat"))
199+
} else {
200+
Expect(ldconfigOut).ToNot(ContainSubstring("/usr/local/cuda/compat"))
201+
}
202+
})
203+
204+
It("should work with the nvidia runtime in CDI mode", func(ctx context.Context) {
205+
ldconfigOut, _, err := r.Run("docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all nvcr.io/nvidia/cuda:12.8.0-base-ubi8 bash -c \"ldconfig -p | grep libcuda.so.1\"")
206+
Expect(err).ToNot(HaveOccurred())
207+
if compatExpected {
208+
Expect(ldconfigOut).To(ContainSubstring("/usr/local/cuda/compat"))
209+
} else {
210+
Expect(ldconfigOut).ToNot(ContainSubstring("/usr/local/cuda/compat"))
211+
}
212+
})
213+
214+
It("should NOT work with nvidia-container-runtime-hook", func(ctx context.Context) {
215+
ldconfigOut, _, err := r.Run("docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=runc --gpus all nvcr.io/nvidia/cuda:12.8.0-base-ubi8 bash -c \"ldconfig -p | grep libcuda.so.1\"")
216+
Expect(err).ToNot(HaveOccurred())
217+
Expect(ldconfigOut).To(ContainSubstring("/usr/lib64"))
218+
})
219+
})
163220
})

0 commit comments

Comments
 (0)