Skip to content

Add CUDA 12.8 tests #11689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ cuda-tests: load-basic_alpine load-gpu_cuda-tests $(RUNTIME_BIN)
@$(call sudo,test/gpu:cuda_test,--runtime=$(RUNTIME) -test.v $(ARGS))
.PHONY: cuda-tests

cuda-12-8-tests: load-basic_alpine load-gpu_cuda-tests-12-8 $(RUNTIME_BIN)
@$(call install_runtime,$(RUNTIME),--nvproxy=true --nvproxy-docker=true --nvproxy-allowed-driver-capabilities=all)
@$(call sudo,test/gpu:cuda_12_8_test,--runtime=$(RUNTIME) -test.v $(ARGS))
.PHONY: cuda-tests

portforward-tests: load-basic_redis load-basic_nginx $(RUNTIME_BIN)
@$(call install_runtime,$(RUNTIME),--network=sandbox)
@$(call sudo,test/root:portforward_test,--runtime=$(RUNTIME) -test.v $(ARGS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,22 @@ RUN export DEBIAN_FRONTEND=noninteractive; \
xvfb \
zlib1g zlib1g-dev

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

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

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 && \
ln -s /usr/local/go/bin/go /usr/local/bin/go
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 && \
ln -s /usr/local/go/bin/go /usr/local/bin/go

ADD *.cu *.h *.sh *.py *.cc /
ADD *.cu *.h *.sh *.go *.cc /

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

RUN mkdir /cuda-samples/build && cd /cuda-samples/build && \
cmake ..
Expand Down
66 changes: 66 additions & 0 deletions images/gpu/cuda-tests-12-8/list_features.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2024 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This program lists the features of the CUDA device that are available.
// It is used as part of the list_features.sh script.
// Each line it outputs is a CUDA feature name, prefixed by either
// "PRESENT: " or "ABSENT: ".

#include <cuda.h>
#include <cuda_runtime.h>
#include <stdio.h>

#include "cuda_test_util.h" // NOLINT(build/include)

void printFeature(const char* feature, bool have) {
if (have) {
printf("PRESENT: %s\n", feature);
} else {
printf("ABSENT: %s\n", feature);
}
}

int main(int argc, char *argv[]) {
int cuda_device;
CHECK_CUDA(cudaGetDevice(&cuda_device));
cudaDeviceProp properties;
CHECK_CUDA(cudaGetDeviceProperties(&properties, cuda_device));
bool cdpCapable =
(properties.major == 3 && properties.minor >= 5) || properties.major >= 4;
printFeature("DYNAMIC_PARALLELISM", cdpCapable);
printFeature(
"PERSISTENT_L2_CACHING", properties.persistingL2CacheMaxSize > 0);
// Tensor cores are a thing in Volta (SM8X)
printFeature("TENSOR_CORES", properties.major >= 8);
int isCompressionAvailable;
CHECK_CUDA_RESULT(
cuDeviceGetAttribute(&isCompressionAvailable,
CU_DEVICE_ATTRIBUTE_GENERIC_COMPRESSION_SUPPORTED,
cuda_device));
printFeature("COMPRESSIBLE_MEMORY", isCompressionAvailable != 0);
bool p2pAvailable = false;
int gpuCount = -1;
CHECK_CUDA(cudaGetDeviceCount(&gpuCount));
printf("// Number of GPUs: %d\n", gpuCount);
if (gpuCount >= 2) {
int canAccessAToB = -1;
CHECK_CUDA(cudaDeviceCanAccessPeer(&canAccessAToB, 0, 1));
printf("// CUDA P2P: 0 -> 1: %d\n", canAccessAToB);
int canAccessBToA = -1;
CHECK_CUDA(cudaDeviceCanAccessPeer(&canAccessBToA, 1, 0));
printf("// CUDA P2P: 1 -> 0: %d\n", canAccessBToA);
p2pAvailable = canAccessAToB > 0 && canAccessBToA > 0;
}
printFeature("P2P", p2pAvailable);
}
39 changes: 39 additions & 0 deletions images/gpu/cuda-tests-12-8/list_features.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Copyright 2025 The gVisor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script outputs a list of CUDA features that are present or absent,
# one per line. Each line begins with either "PRESENT: " or "ABSENT: ",
# followed by the feature name.

set -euo pipefail

if [[ "${NVIDIA_DRIVER_CAPABILITIES:-}" != "all" ]]; then
echo "NVIDIA_DRIVER_CAPABILITIES is not set to 'all'." >&2
echo "It is set to: '${NVIDIA_DRIVER_CAPABILITIES:-}'" >&2
echo "Please set it to 'all' and try again." >&2
exit 1
fi

cd /
nvcc list_features.cu -lcuda -o list_features -Wno-deprecated-gpu-targets
./list_features

# Detect GL by using a simple test that uses it as reference.
if xvfb-run make -C /cuda-samples/Samples/0_Introduction/simpleCUDA2GL TARGET_ARCH="$(uname -m)" testrun &>/dev/null; then
echo "PRESENT: GL"
else
echo "ABSENT: GL"
fi
26 changes: 26 additions & 0 deletions images/gpu/cuda-tests-12-8/list_sample_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Copyright 2025 The gVisor Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script outputs a sorted list of CUDA sample tests, one per line.

set -euo pipefail

(
while IFS= read -r makefile_path; do
dirname "$makefile_path"
done < <(find /cuda-samples -type f -name Makefile) \
| grep -vE '^/cuda-samples$' | grep -vE '^/cuda-samples/build$' | grep -vE '^/cuda-samples/build/Samples$'
) | sed 's~/cuda-samples/build/Samples/~~' | grep '/' | sort
56 changes: 0 additions & 56 deletions images/gpu/cuda-tests-12-8/run_cuda_test.py

This file was deleted.

Loading
Loading