@@ -18,13 +18,15 @@ package e2e
1818
1919import (
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,51 @@ 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+ BeforeAll (func (ctx context.Context ) {
173+ 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.*.*\" " )
174+ Expect (err ).ToNot (HaveOccurred ())
175+ Expect (compatOutput ).ToNot (BeEmpty ())
176+ compatDriverVersion := strings .TrimPrefix (filepath .Base (compatOutput ), "libcuda.so." )
177+ compatMajor := strings .SplitN (compatDriverVersion , "." , 2 )[0 ]
178+
179+ driverOutput , _ , err := r .Run ("nvidia-smi -q | grep \" Driver Version\" " )
180+ Expect (err ).ToNot (HaveOccurred ())
181+ parts := strings .SplitN (driverOutput , ":" , 2 )
182+ Expect (parts ).To (HaveLen (2 ))
183+
184+ hostDriverVersion := strings .TrimSpace (parts [1 ])
185+ Expect (hostDriverVersion ).ToNot (BeEmpty ())
186+ driverMajor := strings .SplitN (hostDriverVersion , "." , 2 )[0 ]
187+
188+ if driverMajor >= compatMajor {
189+ GinkgoLogr .Info ("CUDA Forward Compatibility tests require an older driver version" , "hostDriverVersion" , hostDriverVersion , "compatDriverVersion" , compatDriverVersion )
190+ Skip ("CUDA Forward Compatibility tests require an older driver version" )
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+ Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
198+ })
199+
200+ It ("should work with the nvidia runtime in CDI mode" , func (ctx context.Context ) {
201+ 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\" " )
202+ Expect (err ).ToNot (HaveOccurred ())
203+ Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
204+ })
205+
206+ It ("should NOT work with nvidia-container-runtime-hook" , func (ctx context.Context ) {
207+ 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\" " )
208+ Expect (err ).ToNot (HaveOccurred ())
209+ Expect (ldconfigOut ).To (ContainSubstring ("/usr/lib64" ))
210+ })
211+ })
163212})
0 commit comments