Skip to content

Commit f39a194

Browse files
committed
Add basic integration tests for forward compat
Signed-off-by: Evan Lezar <[email protected]>
1 parent 7d5360c commit f39a194

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

tests/e2e/nvidia-container-toolkit_test.go

+50-1
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
@@ -166,4 +168,51 @@ var _ = Describe("docker", Ordered, func() {
166168
Expect(referenceOutput).To(Equal(out4))
167169
})
168170
})
171+
172+
Describe("CUDA Forward compatibility", Ordered, func() {
173+
BeforeAll(func(ctx context.Context) {
174+
_, _, err := r.Run("docker pull nvcr.io/nvidia/cuda:12.8.0-base-ubi8")
175+
Expect(err).ToNot(HaveOccurred())
176+
})
177+
178+
BeforeAll(func(ctx context.Context) {
179+
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.*.*\"")
180+
Expect(err).ToNot(HaveOccurred())
181+
Expect(compatOutput).ToNot(BeEmpty())
182+
compatDriverVersion := strings.TrimPrefix(filepath.Base(compatOutput), "libcuda.so.")
183+
compatMajor := strings.SplitN(compatDriverVersion, ".", 2)[0]
184+
185+
driverOutput, _, err := r.Run("nvidia-smi -q | grep \"Driver Version\"")
186+
Expect(err).ToNot(HaveOccurred())
187+
parts := strings.SplitN(driverOutput, ":", 2)
188+
Expect(parts).To(HaveLen(2))
189+
190+
hostDriverVersion := strings.TrimSpace(parts[1])
191+
Expect(hostDriverVersion).ToNot(BeEmpty())
192+
driverMajor := strings.SplitN(hostDriverVersion, ".", 2)[0]
193+
194+
if driverMajor >= compatMajor {
195+
GinkgoLogr.Info("CUDA Forward Compatibility tests require an older driver version", "hostDriverVersion", hostDriverVersion, "compatDriverVersion", compatDriverVersion)
196+
Skip("CUDA Forward Compatibility tests require an older driver version")
197+
}
198+
})
199+
200+
It("should work with the nvidia runtime in legacy mode", func(ctx context.Context) {
201+
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\"")
202+
Expect(err).ToNot(HaveOccurred())
203+
Expect(ldconfigOut).To(ContainSubstring("/usr/local/cuda/compat"))
204+
})
205+
206+
It("should work with the nvidia runtime in CDI mode", func(ctx context.Context) {
207+
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\"")
208+
Expect(err).ToNot(HaveOccurred())
209+
Expect(ldconfigOut).To(ContainSubstring("/usr/local/cuda/compat"))
210+
})
211+
212+
It("should NOT work with nvidia-container-runtime-hook", func(ctx context.Context) {
213+
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\"")
214+
Expect(err).ToNot(HaveOccurred())
215+
Expect(ldconfigOut).To(ContainSubstring("/usr/lib64"))
216+
})
217+
})
169218
})

0 commit comments

Comments
 (0)