Skip to content

Commit 96059e8

Browse files
committed
fixup! USE Matchers
Signed-off-by: Evan Lezar <[email protected]>
1 parent a1f1afc commit 96059e8

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

tests/e2e/nvidia-cdi-refresh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var _ = Describe("nvidia-cdi-refresh", Ordered, ContinueOnFailure, Label("system
134134
var err error
135135
// TODO: We set installCTK to true here to SKIP the mounting of the files from the host.
136136
// The test here does NOT require the host toolkit.
137-
systemdRunner, err = NewNestedContainerRunner(runner, outerContainerImage, false, containerName, localCacheDir)
137+
systemdRunner, err = NewNestedContainerRunner(runner, outerContainerImage, false, containerName, localCacheDir, true)
138138
Expect(err).ToNot(HaveOccurred())
139139
for range 10 {
140140
state, _, err := systemdRunner.Run(getSystemStateScript)

tests/e2e/nvidia-container-cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var _ = Describe("nvidia-container-cli", Ordered, ContinueOnFailure, Label("libn
7878

7979
BeforeAll(func(ctx context.Context) {
8080
var err error
81-
nestedContainerRunner, err = NewNestedContainerRunner(runner, "ubuntu", !installCTK, containerName, localCacheDir)
81+
nestedContainerRunner, err = NewNestedContainerRunner(runner, "ubuntu", !installCTK, containerName, localCacheDir, true)
8282
Expect(err).ToNot(HaveOccurred())
8383

8484
if installCTK {

tests/e2e/nvidia-ctk_containerd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ var _ = Describe("containerd", Ordered, ContinueOnFailure, Label("container-runt
121121

122122
// Create the nested container with the global cache mounted
123123
// TODO: This runner doesn't actually NEED GPU access.
124-
nestedContainerRunner, err = NewNestedContainerRunner(runner, env.image, false, containerName, localCacheDir)
124+
nestedContainerRunner, err = NewNestedContainerRunner(runner, env.image, false, containerName, localCacheDir, false)
125125
Expect(err).ToNot(HaveOccurred())
126126

127127
// Backup original containerd configuration

tests/e2e/runner.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func NewRunner(opts ...runnerOption) Runner {
100100
// NewNestedContainerRunner creates a new nested container runner.
101101
// A nested container runs a container inside another container based on a
102102
// given runner (remote or local).
103-
func NewNestedContainerRunner(runner Runner, baseImage string, mountToolkitFromHost bool, containerName string, cacheDir string) (Runner, error) {
103+
func NewNestedContainerRunner(runner Runner, baseImage string, mountToolkitFromHost bool, containerName string, cacheDir string, requiresGPUs bool) (Runner, error) {
104104
// If a container with the same name exists from a previous test run, remove it first.
105105
// Ignore errors as container might not exist
106106
_, _, err := runner.Run(fmt.Sprintf("docker rm -f %s 2>/dev/null || true", containerName))
@@ -110,6 +110,16 @@ func NewNestedContainerRunner(runner Runner, baseImage string, mountToolkitFromH
110110

111111
var additionalContainerArguments []string
112112

113+
if requiresGPUs {
114+
// If the container requires access to GPUs we explicitly add the nvidia
115+
// runtime and set `NVIDIA_VISIBLE_DEVICES` to trigger jit-cdi spec
116+
// generation.
117+
additionalContainerArguments = append(additionalContainerArguments,
118+
"--runtime=nvidia",
119+
"-e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all",
120+
)
121+
}
122+
113123
if cacheDir != "" {
114124
additionalContainerArguments = append(additionalContainerArguments,
115125
"-v "+cacheDir+":"+cacheDir+":ro",
@@ -302,10 +312,6 @@ func connectOrDie(sshKey, sshUser, host, port string) (*ssh.Client, error) {
302312

303313
// outerContainerTemplate represents a template to start a container with
304314
// a name specified.
305-
// The container is given access to all NVIDIA gpus by explicitly using the
306-
// nvidia runtime and the `runtime.nvidia.com/gpu=all` device to trigger JIT
307-
// CDI spec generation.
308-
// The template also allows for additional arguments to be specified.
309315
type outerContainer struct {
310316
Name string
311317
BaseImage string
@@ -314,8 +320,6 @@ type outerContainer struct {
314320

315321
func (o *outerContainer) Render() (string, error) {
316322
tmpl, err := template.New("startContainer").Parse(`docker run -d --name {{.Name}} --privileged \
317-
-e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all \
318-
-e NVIDIA_DRIVER_CAPABILITIES=all \
319323
{{ range $i, $a := .AdditionalArguments -}}
320324
{{ $a }} \
321325
{{ end -}}

0 commit comments

Comments
 (0)