Skip to content
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

Add multi-arch support for nvidia-device-plugin #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.23-bullseye as builder
FROM --platform=$BUILDPLATFORM golang:1.23-bullseye AS builder

ARG TARGETOS
ARG TARGETARCH

WORKDIR /go/src/github.com/GoogleCloudPlatform/container-engine-accelerators
COPY . .
RUN go build cmd/nvidia_gpu/nvidia_gpu.go
RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \
Copy link
Contributor

@elfinhe elfinhe Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we double check the conditions here? Is it assuming the build machine is on X86?

Copy link
Author

@ollyplance ollyplance Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the current build machine is x86. These conditions are ensuring that we only install the cross-compiler if the host machine is x86 AND we are building for arm. It may be a good point to ensure that the host machine is nothing other than x86 or arm though, if that is what you were getting at?

apt update && \
apt install -yq --no-install-recommends \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross; \
CC=aarch64-linux-gnu-gcc; \
fi && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dockerfile is used to internally build image for release, also need to double check if the currently louhi pipeline can work successfully after this update.

Copy link
Author

@ollyplance ollyplance Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, currently the Louhi pipeline runs make container. Locally make container performs the exact same as before, only using the dockerx wrapper around docker -- as we are using an amd64 machine to build an amd64 image (thus will not activate this cross-complier install). For actually building the multi-arch build in louhi, I separated out that build into a different make command. I will create a seperate louhi flow to verify that works before proceeding with changing the pipeline.

GOTOOLCHAIN=local GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 CC=${CC} \
go build cmd/nvidia_gpu/nvidia_gpu.go
RUN chmod a+x /go/src/github.com/GoogleCloudPlatform/container-engine-accelerators/nvidia_gpu

FROM gcr.io/distroless/base:latest
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ build:
cd cmd/nvidia_gpu; go build nvidia_gpu.go

container:
docker build --pull -t ${REGISTRY}/${IMAGE}:${TAG} .
docker buildx build --pull -t ${REGISTRY}/${IMAGE}:${TAG} .

push:
gcloud docker -- push ${REGISTRY}/${IMAGE}:${TAG}
Expand All @@ -59,6 +59,9 @@ fastsocket_installer:
nri-device-injector:
docker build --pull -t ${REGISTRY}/${DEVICE_INJECTOR_IMAGE}:${TAG} -f nri_device_injector/Dockerfile .

container-multi-arch:
docker buildx build --pull --platform linux/arm64,linux/amd64 -t ${REGISTRY}/${IMAGE}:${TAG} .

.PHONY: all format test vet presubmit build container push partition-gpu

bin/device-injector-test:
Expand All @@ -70,4 +73,4 @@ device-injector-test: bin/device-injector-test

.PHONY: clean
clean:
@rm -rf bin
@rm -rf bin
Loading