@@ -19,6 +19,7 @@ package e2e
1919
2020import (
2121 "context"
22+ "fmt"
2223 "path/filepath"
2324 "strings"
2425
@@ -85,29 +86,29 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
8586 It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
8687 By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
8788 var err error
88- referenceOutput , _ , err = runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
89+ referenceOutput , _ , err = runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all %s" , vectorAddImage ) )
8990 Expect (err ).ToNot (HaveOccurred ())
9091
9192 Expect (referenceOutput ).To (ContainSubstring ("Test PASSED" ))
9293 })
9394
9495 It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
9596 By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
96- out2 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
97+ out2 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all %s" , vectorAddImage ) )
9798 Expect (err ).ToNot (HaveOccurred ())
9899 Expect (referenceOutput ).To (Equal (out2 ))
99100 })
100101
101102 It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
102103 By ("Running docker run with --runtime=nvidia --gpus all" )
103- out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
104+ out3 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia --gpus all %s" , vectorAddImage ) )
104105 Expect (err ).ToNot (HaveOccurred ())
105106 Expect (referenceOutput ).To (Equal (out3 ))
106107 })
107108
108109 It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
109110 By ("Running docker run with --gpus all" )
110- out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
111+ out4 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --gpus all %s" , vectorAddImage ) )
111112 Expect (err ).ToNot (HaveOccurred ())
112113 Expect (referenceOutput ).To (Equal (out4 ))
113114 })
@@ -116,46 +117,41 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
116117 // A deviceQuery sample runs in a container with access to all GPUs
117118 // The following should all produce the same result.
118119 When ("Running the cuda-deviceQuery sample" , Ordered , func () {
119- BeforeAll (func (ctx context.Context ) {
120- _ , _ , err := runner .Run ("docker pull nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
121- Expect (err ).ToNot (HaveOccurred ())
122- })
123-
124120 var referenceOutput string
125121
126122 It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
127123 By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
128124 var err error
129- referenceOutput , _ , err = runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
125+ referenceOutput , _ , err = runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all %s" , deviceQueryImage ) )
130126 Expect (err ).ToNot (HaveOccurred ())
131127 Expect (referenceOutput ).To (ContainSubstring ("Result = PASS" ))
132128 })
133129
134130 It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
135131 By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
136- out2 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
132+ out2 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all %s" , deviceQueryImage ) )
137133 Expect (err ).ToNot (HaveOccurred ())
138134 Expect (referenceOutput ).To (Equal (out2 ))
139135 })
140136
141137 It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
142138 By ("Running docker run with --runtime=nvidia --gpus all" )
143- out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
139+ out3 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --runtime=nvidia --gpus all %s" , deviceQueryImage ) )
144140 Expect (err ).ToNot (HaveOccurred ())
145141 Expect (referenceOutput ).To (Equal (out3 ))
146142 })
147143
148144 It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
149145 By ("Running docker run with --gpus all" )
150- out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
146+ out4 , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i --gpus all %s" , deviceQueryImage ) )
151147 Expect (err ).ToNot (HaveOccurred ())
152148 Expect (referenceOutput ).To (Equal (out4 ))
153149 })
154150 })
155151
156152 When ("Testing CUDA Forward compatibility" , Ordered , func () {
157153 BeforeAll (func (ctx context.Context ) {
158- compatOutput , _ , err := runner .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.*.*\" " )
154+ compatOutput , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i -e NVIDIA_VISIBLE_DEVICES=void %s bash -c \" ls /usr/local/cuda/compat/libcuda.*.*\" " , cudaImage ) )
159155 Expect (err ).ToNot (HaveOccurred ())
160156 Expect (compatOutput ).ToNot (BeEmpty ())
161157
@@ -179,21 +175,21 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
179175
180176 It ("should work with the nvidia runtime in legacy mode" , func (ctx context.Context ) {
181177 By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
182- ldconfigOut , _ , err := runner .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\" " )
178+ ldconfigOut , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia --gpus all %s bash -c \" ldconfig -p | grep libcuda.so.1\" " , cudaImage ) )
183179 Expect (err ).ToNot (HaveOccurred ())
184180 Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
185181 })
186182
187183 It ("should work with the nvidia runtime in CDI mode" , func (ctx context.Context ) {
188184 By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
189- ldconfigOut , _ , err := runner .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\" " )
185+ ldconfigOut , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all %s bash -c \" ldconfig -p | grep libcuda.so.1\" " , cudaImage ) )
190186 Expect (err ).ToNot (HaveOccurred ())
191187 Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
192188 })
193189
194190 It ("should NOT work with nvidia-container-runtime-hook" , func (ctx context.Context ) {
195191 By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --gpus all" )
196- ldconfigOut , _ , err := runner .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\" " )
192+ ldconfigOut , _ , err := runner .Run (fmt . Sprintf ( "docker run --rm -i -e NVIDIA_DISABLE_REQUIRE=true --runtime=runc --gpus all %s bash -c \" ldconfig -p | grep libcuda.so.1\" " , cudaImage ) )
197193 Expect (err ).ToNot (HaveOccurred ())
198194 Expect (ldconfigOut ).To (ContainSubstring ("/usr/lib64" ))
199195 })
0 commit comments