|
| 1 | +# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. |
| 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 | +FROM nvcr.io/nvidia/cuda:12.6.2-base-ubuntu22.04 AS builder |
| 16 | + |
| 17 | +ARG SAMPLE_NAME=nbody |
| 18 | +ENV SAMPLE_NAME=${SAMPLE_NAME} |
| 19 | + |
| 20 | +ARG DEBIAN_FRONTEND=noninteractive |
| 21 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 22 | + cuda-nvcc-12-6 \ |
| 23 | + build-essential \ |
| 24 | + g++ \ |
| 25 | + curl \ |
| 26 | + freeglut3-dev \ |
| 27 | + libgl1-mesa-dev \ |
| 28 | + libglu1-mesa-dev \ |
| 29 | + && \ |
| 30 | + rm -rf /var/lib/apt/lists/* |
| 31 | + |
| 32 | +WORKDIR /build |
| 33 | + |
| 34 | +ARG TARGETARCH |
| 35 | + |
| 36 | +ARG CUDA_SAMPLES_VERSION=v12.0 |
| 37 | +RUN curl -L https://codeload.github.com/NVIDIA/cuda-samples/tar.gz/refs/tags/${CUDA_SAMPLES_VERSION} | \ |
| 38 | + tar -xzvf - --strip-components=1 --wildcards */${SAMPLE_NAME}/* --wildcards */Common/* && \ |
| 39 | + cd $(find /build/Samples -iname "${SAMPLE_NAME}") && \ |
| 40 | + make build && \ |
| 41 | + cp $(find /build/bin -iname "${SAMPLE_NAME}") /build/${SAMPLE_NAME} |
| 42 | + |
| 43 | +FROM nvcr.io/nvidia/cuda:12.6.2-base-ubuntu22.04 |
| 44 | +ARG SAMPLE_NAME |
| 45 | +LABEL io.k8s.display-name="NVIDIA CUDA ${SAMPLE_NAME} sample" |
| 46 | +LABEL name="NVIDIA CUDA ${SAMPLE_NAME} sample" |
| 47 | +LABEL vendor="NVIDIA" |
| 48 | +LABEL version="1.0.0" |
| 49 | +LABEL release="N/A" |
| 50 | +LABEL summary="NVIDIA container to validate GPU support" |
| 51 | +LABEL description="See summary" |
| 52 | + |
| 53 | +# The nbody sample requires libGL, libGLU, and libglut |
| 54 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 55 | + freeglut3 \ |
| 56 | + libgl1 \ |
| 57 | + libglu1 \ |
| 58 | + && \ |
| 59 | + rm -rf /var/lib/apt/lists/* || : |
| 60 | + |
| 61 | +COPY ./LICENSE ./licenses/LICENSE |
| 62 | + |
| 63 | +RUN mkdir -p /cuda-samples |
| 64 | +COPY --from=builder /build/${SAMPLE_NAME} /cuda-samples/${SAMPLE_NAME} |
| 65 | + |
| 66 | +RUN ln -s /cuda-samples/${SAMPLE_NAME} /cuda-samples/sample |
| 67 | +ENTRYPOINT ["/cuda-samples/sample"] |
0 commit comments