|
| 1 | +## This is a generated file, do not edit directly. Edit build/docker/templates/intel-gpu-levelzero.Dockerfile.in instead. |
| 2 | +## |
| 3 | +## Copyright 2022 Intel Corporation. All Rights Reserved. |
| 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 | +ARG CMD=gpu_levelzero |
| 18 | +ARG ROCKYLINUX=1 |
| 19 | +## FINAL_BASE_DYN can be used to configure the base image of the final image. |
| 20 | +## The project default is 1) which sets FINAL_BASE_DYN=gcr.io/distroless/cc-debian12 |
| 21 | +## (see build-image.sh). |
| 22 | +## 2) and the default FINAL_BASE is primarily used to build Redhat Certified Openshift Operator container images that must be UBI based. |
| 23 | +## The RedHat build tool does not allow additional image build parameters. |
| 24 | +ARG BUILD_BASE=rockylinux:9 |
| 25 | +ARG FINAL_BASE_DYN=registry.access.redhat.com/ubi9/ubi-minimal:9.3 |
| 26 | +### |
| 27 | +FROM ${BUILD_BASE} as builder |
| 28 | +ARG DIR=/intel-device-plugins-for-kubernetes |
| 29 | +ENV CGO_CFLAGS="-pipe -fno-plt" |
| 30 | +ENV CGO_LDFLAGS="-fstack-protector-strong -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,-z,defs,-s,-w" |
| 31 | +ENV CGOFLAGS="-trimpath -mod=readonly -buildmode=pie" |
| 32 | +ENV GCFLAGS="all=-spectre=all -N -l" |
| 33 | +ENV ASMFLAGS="all=-spectre=all" |
| 34 | +ENV LDFLAGS="all=-linkmode=external -s -w" |
| 35 | +ARG GOLICENSES_VERSION |
| 36 | +ARG CMD |
| 37 | +ARG ROCKYLINUX |
| 38 | +ARG CGO_VERSION=1.23 |
| 39 | +RUN mkdir /runtime |
| 40 | +RUN if [ $ROCKYLINUX -eq 0 ]; then \ |
| 41 | + apt-get update && apt-get install --no-install-recommends -y wget libc6-dev ca-certificates ocl-icd-libopencl1 && \ |
| 42 | + cd /runtime && \ |
| 43 | + wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-level-zero-gpu_1.3.30049.6_amd64.deb && \ |
| 44 | + wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/intel-opencl-icd_24.26.30049.6_amd64.deb && \ |
| 45 | + wget -q https://github.com/intel/compute-runtime/releases/download/24.26.30049.6/libigdgmm12_22.3.20_amd64.deb && \ |
| 46 | + wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero-devel_1.17.6+u22.04_amd64.deb && \ |
| 47 | + wget -q https://github.com/oneapi-src/level-zero/releases/download/v1.17.6/level-zero_1.17.6+u22.04_amd64.deb && \ |
| 48 | + dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && \ |
| 49 | + rm -rf /var/lib/apt/lists/\*; \ |
| 50 | + else \ |
| 51 | + source /etc/os-release && dnf install -y gcc jq wget 'dnf-command(config-manager)' && \ |
| 52 | + dnf config-manager --add-repo https://repositories.intel.com/gpu/rhel/${VERSION_ID}/lts/2350/unified/intel-gpu-${VERSION_ID}.repo && \ |
| 53 | + dnf install -y intel-opencl level-zero level-zero-devel intel-level-zero-gpu intel-gmmlib intel-ocloc && \ |
| 54 | + dnf clean all && \ |
| 55 | + LATEST_GO=$(curl --no-progress-meter https://go.dev/dl/?mode=json | jq ".[] | select(.version | startswith(\"go${CGO_VERSION}\")).version" | tr -d "\"") && \ |
| 56 | + wget -q https://go.dev/dl/$LATEST_GO.linux-amd64.tar.gz -O - | tar -xz -C /usr/local && \ |
| 57 | + cp -a /etc/OpenCL /usr/lib64/libocloc.so /usr/lib64/libze_intel_gpu.* /usr/lib64/libze_loader.* /usr/lib64/libigdgmm.* /runtime/ && \ |
| 58 | + mkdir /runtime/licenses/ && cd /usr/share/licenses/ && cp -a level-zero intel-gmmlib intel-level-zero-gpu intel-ocloc /runtime/licenses/; \ |
| 59 | + fi |
| 60 | +ARG EP=/usr/local/bin/intel_gpu_levelzero |
| 61 | +ARG CMD |
| 62 | +WORKDIR ${DIR} |
| 63 | +COPY . . |
| 64 | +RUN export PATH=$PATH:/usr/local/go/bin/ && cd cmd/${CMD} && \ |
| 65 | + GO111MODULE=on CGO_ENABLED=1 go install $CGOFLAGS --gcflags="$GCFLAGS" --asmflags="$ASMFLAGS" --ldflags="$LDFLAGS" |
| 66 | +RUN [ $ROCKYLINUX -eq 0 ] && install -D /go/bin/${CMD} /install_root${EP} || install -D /root/go/bin/${CMD} /install_root${EP} |
| 67 | +RUN install -D ${DIR}/LICENSE /install_root/licenses/intel-device-plugins-for-kubernetes/LICENSE \ |
| 68 | + && if [ ! -d "licenses/$CMD" ] ; then \ |
| 69 | + GO111MODULE=on go run github.com/google/go-licenses@${GOLICENSES_VERSION} save "./cmd/$CMD" \ |
| 70 | + --save_path /install_root/licenses/$CMD/go-licenses ; \ |
| 71 | + else mkdir -p /install_root/licenses/$CMD/go-licenses/ && cd licenses/$CMD && cp -r * /install_root/licenses/$CMD/go-licenses/ ; fi |
| 72 | +FROM ${FINAL_BASE_DYN} |
| 73 | +ARG CMD |
| 74 | +ARG ROCKYLINUX |
| 75 | +COPY --from=builder /runtime /runtime |
| 76 | +RUN if [ $ROCKYLINUX -eq 0 ]; then \ |
| 77 | + apt-get update && apt-get install --no-install-recommends -y ocl-icd-libopencl1 && \ |
| 78 | + rm /runtime/level-zero-devel_*.deb && \ |
| 79 | + cd /runtime && dpkg --ignore-depends=intel-igc-core,intel-igc-opencl -i *.deb && rm -rf /runtime && \ |
| 80 | + rm "/lib/x86_64-linux-gnu/libze_validation"* && rm "/lib/x86_64-linux-gnu/libze_tracing_layer"*; \ |
| 81 | + else \ |
| 82 | + cp -a /runtime//*.so* /usr/lib64/ && cp -a /runtime/OpenCL /etc/ && cp -a /runtime/licenses/* /usr/share/licenses/; \ |
| 83 | + fi |
| 84 | +COPY --from=builder /install_root / |
| 85 | +ENTRYPOINT ["/usr/local/bin/intel_gpu_levelzero"] |
| 86 | +LABEL vendor='Intel®' |
| 87 | +LABEL version='devel' |
| 88 | +LABEL release='1' |
| 89 | +LABEL name='intel-gpu-levelzero' |
| 90 | +LABEL summary='Intel® GPU levelzero for Kubernetes' |
| 91 | +LABEL description='The GPU levelzero container provides access to Levelzero API for the Intel GPU plugin' |
0 commit comments