Skip to content

Commit 40988f1

Browse files
zkoopmansgvisor-bot
authored andcommitted
Add CUDA 12.8 tests
Add tests using the Cuda Samples repo for CUDA 12.8 PiperOrigin-RevId: 756917719
1 parent f585db6 commit 40988f1

File tree

12 files changed

+1308
-105
lines changed

12 files changed

+1308
-105
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ cuda-tests: load-basic_alpine load-gpu_cuda-tests $(RUNTIME_BIN)
343343
@$(call sudo,test/gpu:cuda_test,--runtime=$(RUNTIME) -test.v $(ARGS))
344344
.PHONY: cuda-tests
345345

346+
cuda-12-8-tests: load-basic_alpine load-gpu_cuda-tests-12-8 $(RUNTIME_BIN)
347+
@$(call install_runtime,$(RUNTIME),--nvproxy=true --nvproxy-docker=true --nvproxy-allowed-driver-capabilities=all)
348+
@$(call sudo,test/gpu:cuda_12_8_test,--runtime=$(RUNTIME) -test.v $(ARGS))
349+
.PHONY: cuda-tests
350+
346351
portforward-tests: load-basic_redis load-basic_nginx $(RUNTIME_BIN)
347352
@$(call install_runtime,$(RUNTIME),--network=sandbox)
348353
@$(call sudo,test/root:portforward_test,--runtime=$(RUNTIME) -test.v $(ARGS))

images/gpu/cuda-tests-12-8/Dockerfile renamed to images/gpu/cuda-tests-12-8/Dockerfile.x86_64

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
2828
xvfb \
2929
zlib1g zlib1g-dev
3030

31-
RUN git clone \
32-
https://github.com/NVIDIA/cuda-samples.git /cuda-samples && cd /cuda-samples && \
33-
git checkout 7b60178984e96bc09d066077d5455df71fee2a9f && cd /
31+
RUN git clone --depth=1 --branch=v12.8 --single-branch \
32+
https://github.com/NVIDIA/cuda-samples.git /cuda-samples && cd /cuda-samples
3433

3534
RUN apt install -y wget && apt -y purge golang*
3635

37-
RUN wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz && \
38-
ln -s /usr/local/go/bin/go /usr/local/bin/go
36+
RUN wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz && \
37+
tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz && \
38+
ln -s /usr/local/go/bin/go /usr/local/bin/go
3939

40-
ADD *.cu *.h *.sh *.py *.cc /
40+
ADD *.cu *.h *.sh *.go *.cc /
4141

42-
RUN chmod 555 /*.sh && gcc -o /unsupported_ioctl /unsupported_ioctl.cc
42+
RUN chmod 555 /*.sh && gcc -o /unsupported_ioctl /unsupported_ioctl.cc && \
43+
go install \
44+
github.com/TheZoraiz/ascii-image-converter@d05a757c5e02ab23e97b6f6fca4e1fbeb10ab559 && \
45+
mv "$HOME/go/bin/ascii-image-converter" /usr/bin/ && \
46+
go build -o /run_sample /run_sample.go
4347

4448
RUN mkdir /cuda-samples/build && cd /cuda-samples/build && \
4549
cmake ..
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright 2024 The gVisor Authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// This program lists the features of the CUDA device that are available.
16+
// It is used as part of the list_features.sh script.
17+
// Each line it outputs is a CUDA feature name, prefixed by either
18+
// "PRESENT: " or "ABSENT: ".
19+
20+
#include <cuda.h>
21+
#include <cuda_runtime.h>
22+
#include <stdio.h>
23+
24+
#include "cuda_test_util.h" // NOLINT(build/include)
25+
26+
void printFeature(const char* feature, bool have) {
27+
if (have) {
28+
printf("PRESENT: %s\n", feature);
29+
} else {
30+
printf("ABSENT: %s\n", feature);
31+
}
32+
}
33+
34+
int main(int argc, char *argv[]) {
35+
int cuda_device;
36+
CHECK_CUDA(cudaGetDevice(&cuda_device));
37+
cudaDeviceProp properties;
38+
CHECK_CUDA(cudaGetDeviceProperties(&properties, cuda_device));
39+
bool cdpCapable =
40+
(properties.major == 3 && properties.minor >= 5) || properties.major >= 4;
41+
printFeature("DYNAMIC_PARALLELISM", cdpCapable);
42+
printFeature(
43+
"PERSISTENT_L2_CACHING", properties.persistingL2CacheMaxSize > 0);
44+
// Tensor cores are a thing in Volta (SM8X)
45+
printFeature("TENSOR_CORES", properties.major >= 8);
46+
int isCompressionAvailable;
47+
CHECK_CUDA_RESULT(
48+
cuDeviceGetAttribute(&isCompressionAvailable,
49+
CU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED,
50+
cuda_device));
51+
printFeature("COMPRESSIBLE_MEMORY", isCompressionAvailable != 0);
52+
bool p2pAvailable = false;
53+
int gpuCount = -1;
54+
CHECK_CUDA(cudaGetDeviceCount(&gpuCount));
55+
printf("// Number of GPUs: %d\n", gpuCount);
56+
if (gpuCount >= 2) {
57+
int canAccessAToB = -1;
58+
CHECK_CUDA(cudaDeviceCanAccessPeer(&canAccessAToB, 0, 1));
59+
printf("// CUDA P2P: 0 -> 1: %d\n", canAccessAToB);
60+
int canAccessBToA = -1;
61+
CHECK_CUDA(cudaDeviceCanAccessPeer(&canAccessBToA, 1, 0));
62+
printf("// CUDA P2P: 1 -> 0: %d\n", canAccessBToA);
63+
p2pAvailable = canAccessAToB > 0 && canAccessBToA > 0;
64+
}
65+
printFeature("P2P", p2pAvailable);
66+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The gVisor Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This script outputs a list of CUDA features that are present or absent,
18+
# one per line. Each line begins with either "PRESENT: " or "ABSENT: ",
19+
# followed by the feature name.
20+
21+
set -euo pipefail
22+
23+
if [[ "${NVIDIA_DRIVER_CAPABILITIES:-}" != "all" ]]; then
24+
echo "NVIDIA_DRIVER_CAPABILITIES is not set to 'all'." >&2
25+
echo "It is set to: '${NVIDIA_DRIVER_CAPABILITIES:-}'" >&2
26+
echo "Please set it to 'all' and try again." >&2
27+
exit 1
28+
fi
29+
30+
cd /
31+
nvcc list_features.cu -lcuda -o list_features -Wno-deprecated-gpu-targets
32+
./list_features
33+
34+
# Detect GL by using a simple test that uses it as reference.
35+
if xvfb-run make -C /cuda-samples/Samples/0_Introduction/simpleCUDA2GL TARGET_ARCH="$(uname -m)" testrun &>/dev/null; then
36+
echo "PRESENT: GL"
37+
else
38+
echo "ABSENT: GL"
39+
fi
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The gVisor Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This script outputs a sorted list of CUDA sample tests, one per line.
18+
19+
set -euo pipefail
20+
21+
(
22+
while IFS= read -r makefile_path; do
23+
dirname "$makefile_path"
24+
done < <(find /cuda-samples -type f -name Makefile) \
25+
| grep -vE '^/cuda-samples$' | grep -vE '^/cuda-samples/build$' | grep -vE '^/cuda-samples/build/Samples$'
26+
) | sed 's~/cuda-samples/build/Samples/~~' | grep '/' | sort

images/gpu/cuda-tests-12-8/run_cuda_test.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)