Skip to content

Commit 669f1e5

Browse files
committed
chore(integration): test with nvidia sample CUDA image
1 parent 4878301 commit 669f1e5

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

integration/gpu_test.go

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ func TestDocker_Nvidia(t *testing.T) {
6262
// Assert that we can run nvidia-smi in the inner container.
6363
assertInnerNvidiaSMI(ctx, t, ctID)
6464

65-
// Make sure dnf still works.
66-
out, err := execContainerCmd(ctx, t, ctID, "docker", "exec", "workspace_cvm", "dnf", "list")
65+
// Make sure dnf still works. This checks for a regression due to
66+
// gpuExtraRegex matching `libglib.so` in the outer container.
67+
// This had a dependency on `libpcre.so.3` which would cause dnf to fail.
68+
out, err := execContainerCmd(ctx, t, ctID, "docker", "exec", "workspace_cvm", "dnf")
6769
if !assert.NoError(t, err, "failed to run dnf in the inner container") {
6870
t.Logf("dnf output:\n%s", strings.TrimSpace(out))
6971
}
@@ -113,6 +115,29 @@ func TestDocker_Nvidia(t *testing.T) {
113115
assertInnerFiles(ctx, t, ctID, "/usr/lib/x86_64-linux-gnu/libnv*", ofs...)
114116
assertInnerNvidiaSMI(ctx, t, ctID)
115117
})
118+
119+
t.Run("CUDASample", func(t *testing.T) {
120+
t.Parallel()
121+
122+
ctx, cancel := context.WithCancel(context.Background())
123+
t.Cleanup(cancel)
124+
125+
// Start the envbox container.
126+
ctID := startEnvboxCmd(ctx, t, integrationtest.CUDASampleImage, "root",
127+
"-v", "/usr/lib/x86_64-linux-gnu:/var/coder/usr/lib",
128+
"--env", "CODER_ADD_GPU=true",
129+
"--env", "CODER_USR_LIB_DIR=/var/coder/usr/lib",
130+
"--runtime=nvidia",
131+
"--gpus=all",
132+
)
133+
134+
// Assert that we can run nvidia-smi in the inner container.
135+
assertInnerNvidiaSMI(ctx, t, ctID)
136+
137+
// Assert that /tmp/vectorAdd runs successfully in the inner container.
138+
_, err := execContainerCmd(ctx, t, ctID, "docker", "exec", "workspace_cvm", "/tmp/vectorAdd")
139+
require.NoError(t, err, "failed to run /tmp/vectorAdd in the inner container")
140+
})
116141
}
117142

118143
// dockerRuntimes returns the list of container runtimes available on the host.

integration/integrationtest/docker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ const (
4242
UbuntuImage = "gcr.io/coder-dev-1/sreya/ubuntu-coder"
4343
// Redhat UBI9 image as of 2025-03-05
4444
RedhatImage = "registry.access.redhat.com/ubi9/ubi:9.5"
45+
// CUDASampleImage is a CUDA sample image from NVIDIA's container registry.
46+
// It contains a binary /tmp/vectorAdd which can be run to test the CUDA setup.
47+
CUDASampleImage = "nvcr.io/nvidia/k8s/cuda-sample:vectoradd-cuda10.2"
4548

4649
// RegistryImage is used to assert that we add certs
4750
// correctly to the docker daemon when pulling an image

0 commit comments

Comments
 (0)