11/*
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.
43 *
54 * Licensed under the Apache License, Version 2.0 (the "License");
65 * you may not use this file except in compliance with the License.
@@ -39,38 +38,36 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
3938 BeforeAll (func (ctx context.Context ) {
4039 hostOutput , _ , err = runner .Run ("nvidia-smi -L" )
4140 Expect (err ).ToNot (HaveOccurred ())
41+
42+ _ , _ , err := runner .Run ("docker pull ubuntu" )
43+ Expect (err ).ToNot (HaveOccurred ())
4244 })
4345
4446 It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
45- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
4647 containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all ubuntu nvidia-smi -L" )
4748 Expect (err ).ToNot (HaveOccurred ())
4849 Expect (containerOutput ).To (Equal (hostOutput ))
4950 })
5051
5152 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" )
5353 containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all ubuntu nvidia-smi -L" )
5454 Expect (err ).ToNot (HaveOccurred ())
5555 Expect (containerOutput ).To (Equal (hostOutput ))
5656 })
5757
5858 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" )
6059 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" )
6160 Expect (err ).ToNot (HaveOccurred ())
6261 Expect (containerOutput ).To (Equal (hostOutput ))
6362 })
6463
6564 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" )
6765 containerOutput , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all ubuntu nvidia-smi -L" )
6866 Expect (err ).ToNot (HaveOccurred ())
6967 Expect (containerOutput ).To (Equal (hostOutput ))
7068 })
7169
7270 It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
73- By ("Running docker run with --gpus all" )
7471 containerOutput , _ , err := runner .Run ("docker run --rm -i --gpus all ubuntu nvidia-smi -L" )
7572 Expect (err ).ToNot (HaveOccurred ())
7673 Expect (containerOutput ).To (Equal (hostOutput ))
@@ -82,8 +79,12 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
8279 When ("Running the cuda-vectorAdd sample" , Ordered , func () {
8380 var referenceOutput string
8481
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+
8587 It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
86- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
8788 var err error
8889 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" )
8990 Expect (err ).ToNot (HaveOccurred ())
@@ -92,21 +93,18 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
9293 })
9394
9495 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" )
9696 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" )
9797 Expect (err ).ToNot (HaveOccurred ())
9898 Expect (referenceOutput ).To (Equal (out2 ))
9999 })
100100
101101 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" )
103102 out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
104103 Expect (err ).ToNot (HaveOccurred ())
105104 Expect (referenceOutput ).To (Equal (out3 ))
106105 })
107106
108107 It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
109- By ("Running docker run with --gpus all" )
110108 out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda12.5.0" )
111109 Expect (err ).ToNot (HaveOccurred ())
112110 Expect (referenceOutput ).To (Equal (out4 ))
@@ -116,37 +114,33 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
116114 // A deviceQuery sample runs in a container with access to all GPUs
117115 // The following should all produce the same result.
118116 When ("Running the cuda-deviceQuery sample" , Ordered , func () {
117+ var referenceOutput string
118+
119119 BeforeAll (func (ctx context.Context ) {
120120 _ , _ , err := runner .Run ("docker pull nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
121121 Expect (err ).ToNot (HaveOccurred ())
122122 })
123123
124- var referenceOutput string
125-
126124 It ("should support NVIDIA_VISIBLE_DEVICES" , func (ctx context.Context ) {
127- By ("Running docker run with --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all" )
128125 var err error
129126 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" )
130127 Expect (err ).ToNot (HaveOccurred ())
131128 Expect (referenceOutput ).To (ContainSubstring ("Result = PASS" ))
132129 })
133130
134131 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" )
136132 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" )
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 ) {
142- By ("Running docker run with --runtime=nvidia --gpus all" )
143138 out3 , _ , err := runner .Run ("docker run --rm -i --runtime=nvidia --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
144139 Expect (err ).ToNot (HaveOccurred ())
145140 Expect (referenceOutput ).To (Equal (out3 ))
146141 })
147142
148143 It ("should support the --gpus flag using the nvidia-container-runtime-hook" , func (ctx context.Context ) {
149- By ("Running docker run with --gpus all" )
150144 out4 , _ , err := runner .Run ("docker run --rm -i --gpus all nvcr.io/nvidia/k8s/cuda-sample:devicequery-cuda12.5.0" )
151145 Expect (err ).ToNot (HaveOccurred ())
152146 Expect (referenceOutput ).To (Equal (out4 ))
@@ -155,6 +149,9 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
155149
156150 When ("Testing CUDA Forward compatibility" , Ordered , func () {
157151 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+
158155 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.*.*\" " )
159156 Expect (err ).ToNot (HaveOccurred ())
160157 Expect (compatOutput ).ToNot (BeEmpty ())
@@ -178,21 +175,18 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
178175 })
179176
180177 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" )
182178 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\" " )
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 ) {
188- By ("Running docker run with -e NVIDIA_DISABLE_REQUIRE=true --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all" )
189184 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\" " )
190185 Expect (err ).ToNot (HaveOccurred ())
191186 Expect (ldconfigOut ).To (ContainSubstring ("/usr/local/cuda/compat" ))
192187 })
193188
194189 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" )
196190 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\" " )
197191 Expect (err ).ToNot (HaveOccurred ())
198192 Expect (ldconfigOut ).To (ContainSubstring ("/usr/lib64" ))
0 commit comments