@@ -18,13 +18,15 @@ package e2e
18
18
19
19
import (
20
20
"context"
21
+ "path/filepath"
22
+ "strings"
21
23
22
24
. "github.com/onsi/ginkgo/v2"
23
25
. "github.com/onsi/gomega"
24
26
)
25
27
26
28
// Integration tests for Docker runtime
27
- var _ = Describe ("docker" , Ordered , func () {
29
+ var _ = Describe ("docker" , Ordered , ContinueOnFailure , func () {
28
30
var r Runner
29
31
30
32
// Install the NVIDIA Container Toolkit
@@ -166,4 +168,51 @@ var _ = Describe("docker", Ordered, func() {
166
168
Expect (referenceOutput ).To (Equal (out4 ))
167
169
})
168
170
})
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
+ })
169
218
})
0 commit comments