1
1
/*
2
- * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
- * SPDX-License-Identifier: Apache-2.0
2
+ * Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved.
4
3
*
5
4
* Licensed under the Apache License, Version 2.0 (the "License");
6
5
* you may not use this file except in compliance with the License.
@@ -39,38 +38,36 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
39
38
BeforeAll (func (ctx context.Context ) {
40
39
hostOutput , _ , err = runner .Run ("nvidia-smi -L" )
41
40
Expect (err ).ToNot (HaveOccurred ())
41
+
42
+ _ , _ , err := runner .Run ("docker pull ubuntu" )
43
+ Expect (err ).ToNot (HaveOccurred ())
42
44
})
43
45
44
46
It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
45
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
46
47
containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all ubuntu nvidia-smi -L" )
47
48
Expect (err ).ToNot (HaveOccurred ())
48
49
Expect (containerOutput ).To (Equal (hostOutput ))
49
50
})
50
51
51
52
It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
52
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
53
53
containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all ubuntu nvidia-smi -L" )
54
54
Expect (err ).ToNot (HaveOccurred ())
55
55
Expect (containerOutput ).To (Equal (hostOutput ))
56
56
})
57
57
58
58
It ("should support automatic CDI spec generation with the --gpus flag" , func (ctx context.Context ) {
59
- By ("Running docker run with --gpus=all --runtime=nvidia --gpus all" )
60
59
containerOutput , _ , err := runner .Run ("docker run --rm -i --gpus=all --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all ubuntu nvidia-smi -L" )
61
60
Expect (err ).ToNot (HaveOccurred ())
62
61
Expect (containerOutput ).To (Equal (hostOutput ))
63
62
})
64
63
65
64
It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
66
- By ("Running docker run with --runtime=nvidia --gpus all" )
67
65
containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all ubuntu nvidia-smi -L" )
68
66
Expect (err ).ToNot (HaveOccurred ())
69
67
Expect (containerOutput ).To (Equal (hostOutput ))
70
68
})
71
69
72
70
It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
73
- By ("Running docker run with --gpus all" )
74
71
containerOutput , _ , err := runner .Run ("docker run --rm -i --gpus all ubuntu nvidia-smi -L" )
75
72
Expect (err ).ToNot (HaveOccurred ())
76
73
Expect (containerOutput ).To (Equal (hostOutput ))
@@ -82,8 +79,12 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
82
79
When ("Running the cuda-vectorAdd sample" , Ordered , func () {
83
80
var referenceOutput string
84
81
82
+ BeforeAll (func (ctx context.Context ) {
83
+ _ , _ , err := runner .Run ("docker pull nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
84
+ Expect (err ).ToNot (HaveOccurred ())
85
+ })
86
+
85
87
It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
86
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
87
88
var err error
88
89
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
90
Expect (err ).ToNot (HaveOccurred ())
@@ -92,21 +93,18 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
92
93
})
93
94
94
95
It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
95
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
96
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
97
Expect (err ).ToNot (HaveOccurred ())
98
98
Expect (referenceOutput ).To (Equal (out2 ))
99
99
})
100
100
101
101
It ("should support the --gpus flag using the nvidia-container-runtime" , func (ctx context.Context ) {
102
- By ("Running docker run with --runtime=nvidia --gpus all" )
103
102
out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
104
103
Expect (err ).ToNot (HaveOccurred ())
105
104
Expect (referenceOutput ).To (Equal (out3 ))
106
105
})
107
106
108
107
It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
109
- By ("Running docker run with --gpus all" )
110
108
out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
111
109
Expect (err ).ToNot (HaveOccurred ())
112
110
Expect (referenceOutput ).To (Equal (out4 ))
@@ -116,37 +114,33 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
116
114
// A deviceQuery sample runs in a container with access to all GPUs
117
115
// The following should all produce the same result.
118
116
When ("Running the cuda-deviceQuery sample" , Ordered , func () {
117
+ var referenceOutput string
118
+
119
119
BeforeAll (func (ctx context.Context ) {
120
120
_ , _ , err := runner .Run ("docker pull nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
121
121
Expect (err ).ToNot (HaveOccurred ())
122
122
})
123
123
124
- var referenceOutput string
125
-
126
124
It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
127
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
128
125
var err error
129
126
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" )
130
127
Expect (err ).ToNot (HaveOccurred ())
131
128
Expect (referenceOutput ).To (ContainSubstring ("Result = PASS" ))
132
129
})
133
130
134
131
It ("should support automatic CDI spec generation" , func (ctx context.Context ) {
135
- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
136
132
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" )
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
- By ("Running docker run with --runtime=nvidia --gpus all" )
143
138
out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
144
139
Expect (err ).ToNot (HaveOccurred ())
145
140
Expect (referenceOutput ).To (Equal (out3 ))
146
141
})
147
142
148
143
It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
149
- By ("Running docker run with --gpus all" )
150
144
out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
151
145
Expect (err ).ToNot (HaveOccurred ())
152
146
Expect (referenceOutput ).To (Equal (out4 ))
@@ -155,6 +149,9 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
155
149
156
150
When ("Testing CUDA Forward compatibility" , Ordered , func () {
157
151
BeforeAll (func (ctx context.Context ) {
152
+ _ , _ , err := runner .Run ("docker pull nvcr.io/nvidia/cuda:12.8.0-base-ubi8" )
153
+ Expect (err ).ToNot (HaveOccurred ())
154
+
158
155
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.*.*\" " )
159
156
Expect (err ).ToNot (HaveOccurred ())
160
157
Expect (compatOutput ).ToNot (BeEmpty ())
@@ -178,21 +175,18 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
178
175
})
179
176
180
177
It ("should work with the nvidia runtime in legacy mode" , func (ctx context.Context ) {
181
- By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
182
178
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\" " )
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
- By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
189
184
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\" " )
190
185
Expect (err ).ToNot (HaveOccurred ())
191
186
Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
192
187
})
193
188
194
189
It ("should NOT work with nvidia-container-runtime-hook" , func (ctx context.Context ) {
195
- By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --gpus all" )
196
190
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\" " )
197
191
Expect (err ).ToNot (HaveOccurred ())
198
192
Expect (ldconfigOut ).To (ContainSubstring ("/usr/lib64" ))
0 commit comments