@@ -19,6 +19,7 @@ package e2e
19
19
20
20
import (
21
21
"context"
22
+ "fmt"
22
23
"path/filepath"
23
24
"strings"
24
25
@@ -85,29 +86,29 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
85
86
It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
86
87
By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
87
88
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 ) )
89
90
Expect (err ).ToNot (HaveOccurred ())
90
91
91
92
Expect (referenceOutput ).To (ContainSubstring ("Test PASSED" ))
92
93
})
93
94
94
95
It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
95
96
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 ) )
97
98
Expect (err ).ToNot (HaveOccurred ())
98
99
Expect (referenceOutput ).To (Equal (out2 ))
99
100
})
100
101
101
102
It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
102
103
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 ) )
104
105
Expect (err ).ToNot (HaveOccurred ())
105
106
Expect (referenceOutput ).To (Equal (out3 ))
106
107
})
107
108
108
109
It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
109
110
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 ) )
111
112
Expect (err ).ToNot (HaveOccurred ())
112
113
Expect (referenceOutput ).To (Equal (out4 ))
113
114
})
@@ -116,46 +117,41 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
116
117
// A deviceQuery sample runs in a container with access to all GPUs
117
118
// The following should all produce the same result.
118
119
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
-
124
120
var referenceOutput string
125
121
126
122
It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
127
123
By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
128
124
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 ) )
130
126
Expect (err ).ToNot (HaveOccurred ())
131
127
Expect (referenceOutput ).To (ContainSubstring ("Result = PASS" ))
132
128
})
133
129
134
130
It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
135
131
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 ) )
137
133
Expect (err ).ToNot (HaveOccurred ())
138
134
Expect (referenceOutput ).To (Equal (out2 ))
139
135
})
140
136
141
137
It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
142
138
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 ) )
144
140
Expect (err ).ToNot (HaveOccurred ())
145
141
Expect (referenceOutput ).To (Equal (out3 ))
146
142
})
147
143
148
144
It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
149
145
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 ) )
151
147
Expect (err ).ToNot (HaveOccurred ())
152
148
Expect (referenceOutput ).To (Equal (out4 ))
153
149
})
154
150
})
155
151
156
152
When ("Testing CUDA Forward compatibility" , Ordered , func () {
157
153
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 ) )
159
155
Expect (err ).ToNot (HaveOccurred ())
160
156
Expect (compatOutput ).ToNot (BeEmpty ())
161
157
@@ -179,21 +175,21 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
179
175
180
176
It ("should work with the nvidia runtime in legacy mode" , func (ctx context.Context ) {
181
177
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 ) )
183
179
Expect (err ).ToNot (HaveOccurred ())
184
180
Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
185
181
})
186
182
187
183
It ("should work with the nvidia runtime in CDI mode" , func (ctx context.Context ) {
188
184
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 ) )
190
186
Expect (err ).ToNot (HaveOccurred ())
191
187
Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
192
188
})
193
189
194
190
It ("should NOT work with nvidia-container-runtime-hook" , func (ctx context.Context ) {
195
191
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 ) )
197
193
Expect (err ).ToNot (HaveOccurred ())
198
194
Expect (ldconfigOut ).To (ContainSubstring ("/usr/lib64" ))
199
195
})
0 commit comments