Skip to content

Commit

Permalink
Merge pull request #534 from rhatdan/makefile
Browse files Browse the repository at this point in the history
Improve Makefiles
  • Loading branch information
rhatdan authored Jun 9, 2024
2 parents 62abb17 + a0d528f commit 45cebdb
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 57 deletions.
5 changes: 5 additions & 0 deletions training/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
MAKEFLAGS += -j2

.PHONY: all
all: deepspeed vllm

default: help

help:
Expand Down
14 changes: 7 additions & 7 deletions training/amd-bootc/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

VENDOR ?= amd
IMAGE_NAME ?= $(VENDOR)-bootc

Expand All @@ -10,13 +9,14 @@ default: bootc
bootc: prepare-files growfs
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
--security-opt label=disable \
$(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \
$(FROM:%=--from=%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--build-arg "INSTRUCTLAB_IMAGE=$(INSTRUCTLAB_IMAGE)" \
--build-arg "VLLM_IMAGE=$(VLLM_IMAGE)" \
--cap-add SYS_ADMIN \
--file Containerfile \
-v ${OUTDIR}:/run/.input:ro \
--security-opt label=disable \
--tag "${BOOTC_IMAGE}" \
--build-arg "INSTRUCTLAB_IMAGE=$(INSTRUCTLAB_IMAGE)" \
--build-arg "VLLM_IMAGE=$(VLLM_IMAGE)" \
$(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \
$(FROM:%=--from=%) \
-v ${OUTDIR}:/run/.input:ro \
${CONTAINER_TOOL_EXTRA_ARGS} .
3 changes: 2 additions & 1 deletion training/cloud/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ init:
cloud: init
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}-cloud:${IMAGE_TAG}" \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--from="${BOOTC_IMAGE}" \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}-cloud:${IMAGE_TAG}" \
examples/cloud-init

.PHONY: push
Expand Down
26 changes: 14 additions & 12 deletions training/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ UMASK=$(shell umask)

AUTH_JSON ?=

SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)

BOOTC_IMAGE_BUILDER ?= quay.io/centos-bootc/bootc-image-builder
IMAGE_BUILDER_CONFIG ?=
IMAGE_BUILDER_EXTRA_ARGS ?=
Expand Down Expand Up @@ -88,23 +90,23 @@ growfs: check-umask
bootc-image-builder:
mkdir -p build/store
podman run \
--rm \
-ti \
-v $(GRAPH_ROOT):/var/lib/containers/storage \
$(ARCH:%=--target-arch %) \
$(AUTH_JSON:%=-v %:/run/containers/0/auth.json) \
$(IMAGE_BUILDER_CONFIG:%=-v %:/config$(suffix $(IMAGE_BUILDER_CONFIG))) \
--privileged \
--pull newer \
-v ./build:/output \
-v ./build/store:/store \
${CONTAINER_TOOL_EXTRA_ARGS} \
$(BOOTC_IMAGE_BUILDER) \
$(ARCH:%=--target-arch %) \
$(IMAGE_BUILDER_CONFIG:%=--config /config$(suffix $(IMAGE_BUILDER_CONFIG))) \
--type $(DISK_TYPE) \
$(IMAGE_BUILDER_CONFIG:%=-v %:/config$(suffix $(IMAGE_BUILDER_CONFIG))) \
${CONTAINER_TOOL_EXTRA_ARGS} \
${IMAGE_BUILDER_EXTRA_ARGS} \
--chown $(DISK_UID):$(DISK_GID) \
--local \
${IMAGE_BUILDER_EXTRA_ARGS} \
--privileged \
--pull newer \
--rm \
--type $(DISK_TYPE) \
-ti \
-v $(GRAPH_ROOT):/var/lib/containers/storage \
-v ./build/store:/store \
-v ./build:/output \
$(BOOTC_IMAGE)

.PHONY: clean
Expand Down
12 changes: 7 additions & 5 deletions training/deepspeed/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
IMAGE_NAME ?= deepspeed-trainer
CONTAINER_TOOL ?= podman
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)

default: image

Expand All @@ -8,8 +9,9 @@ image:
@mkdir -p ../build
rm -rf ../build/deepspeed-trainer
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
--file Containerfile \
--layers=false \
--squash-all \
--tag oci:../build/deepspeed-trainer .
$(ARCH:%=--platform linux/%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--file Containerfile \
--layers=false \
--squash-all \
--tag oci:../build/deepspeed-trainer
14 changes: 13 additions & 1 deletion training/instructlab/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
default: instructlab
MAKEFLAGS += -j2

help:
@echo "Build a instructlab container image for specified vendor "
@echo
@echo " - make amd"
@echo " - make intel"
@echo " - make nvidia"

default: help

.PHONY: all
all: nvidia intel amd

INSTRUCTLAB_GIT_REPO ?= https://github.com/instructlab/instructlab.git
INSTRUCTLAB_GIT_BRANCH ?= main
Expand Down
13 changes: 7 additions & 6 deletions training/intel-bootc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ default: bootc
bootc: growfs prepare-files
${CONTAINER_TOOL} build \
$(ARCH:%=--platform linux/%) \
--security-opt label=disable \
--cap-add SYS_ADMIN \
--file Containerfile \
--tag "${BOOTC_IMAGE}" \
-v ${OUTDIR}:/run/.input:ro \
$(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \
$(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \
$(FROM:%=--build-arg BASEIMAGE=%) \
$(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \
$(KERNEL_VERSION:%=--build-arg KERNEL_VERSION=%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--build-arg "INSTRUCTLAB_IMAGE=$(INSTRUCTLAB_IMAGE)" \
--build-arg "VLLM_IMAGE=$(VLLM_IMAGE)" \
--cap-add SYS_ADMIN \
--file Containerfile \
--security-opt label=disable \
--tag "${BOOTC_IMAGE}" \
-v ${OUTDIR}:/run/.input:ro \
${CONTAINER_TOOL_EXTRA_ARGS} .
9 changes: 5 additions & 4 deletions training/model/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ MODEL_PATH ?= /usr/share/ai-model
.PHONY: image
image:
"${CONTAINER_TOOL}" build \
--file Containerfile \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
$(FROM:%=--build-arg BASEIMAGE=%) \
$(MODEL_REPO:%=--build-arg MODEL_REPO=%) \
$(MODEL_PATH:%=--build-arg MODEL_PATH=%) \
${CONTAINER_TOOL_EXTRA_ARGS}
$(MODEL_REPO:%=--build-arg MODEL_REPO=%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--file Containerfile \
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
${CONTAINER_TOOL_EXTRA_ARGS} .
34 changes: 18 additions & 16 deletions training/nvidia-bootc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,37 @@ default: bootc
dtk:
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
$(KERNEL_VERSION:%=--build-arg KERNEL_VERSION=%) \
$(ENABLE_RT:%=--build-arg ENABLE_RC=%) \
$(FROM:%=--from=%) \
$(KERNEL_VERSION:%=--build-arg KERNEL_VERSION=%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--file Containerfile.builder \
--tag "${DRIVER_TOOLKIT_IMAGE}" \
$(FROM:%=--from=%) \
${CONTAINER_TOOL_EXTRA_ARGS} .

.PHONY: bootc
bootc: dtk check-sshkey prepare-files growfs
"${CONTAINER_TOOL}" build \
--security-opt label=disable \
--cap-add SYS_ADMIN \
$(ARCH:%=--platform linux/%) \
--file Containerfile \
-v ${OUTDIR}:/run/.input:ro \
--tag "${BOOTC_IMAGE}" \
$(CUDA_VERSION:%=--build-arg CUDA_VERSION=%) \
$(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \
$(DRIVER_VERSION:%=--label driver-version=%) \
$(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \
$(FROM:%=--build-arg BASEIMAGE=%) \
$(KERNEL_VERSION:%=--build-arg KERNEL_VERSION=%) \
$(OS_VERSION_MAJOR:%=--build-arg OS_VERSION_MAJOR=%) \
$(FROM:%=--build-arg BASEIMAGE=%) \
$(EXTRA_RPM_PACKAGES:%=--build-arg EXTRA_RPM_PACKAGES=%) \
--build-arg DRIVER_TOOLKIT_IMAGE=${DRIVER_TOOLKIT_IMAGE} \
$(DRIVER_VERSION:%=--label driver-version=%) \
$(DRIVER_VERSION:%=--build-arg DRIVER_VERSION=%) \
$(CUDA_VERSION:%=--build-arg CUDA_VERSION=%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--build-arg "INSTRUCTLAB_IMAGE=$(INSTRUCTLAB_IMAGE)" \
--build-arg "INSTRUCTLAB_IMAGE_ID=$(INSTRUCTLAB_IMAGE_ID)" \
--build-arg "VLLM_IMAGE=$(VLLM_IMAGE)" \
--build-arg "VLLM_IMAGE_ID=$(VLLM_IMAGE_ID)" \
--build-arg "SSHPUBKEY=$(SSH_PUBKEY)" \
--build-arg "TRAIN_IMAGE=$(TRAIN_IMAGE)" \
--build-arg "TRAIN_IMAGE_ID=$(TRAIN_IMAGE_ID)" \
--build-arg "SSHPUBKEY=$(SSH_PUBKEY)" \
--build-arg "VLLM_IMAGE=$(VLLM_IMAGE)" \
--build-arg "VLLM_IMAGE_ID=$(VLLM_IMAGE_ID)" \
--build-arg DRIVER_TOOLKIT_IMAGE=${DRIVER_TOOLKIT_IMAGE} \
--cap-add SYS_ADMIN \
--file Containerfile \
--security-opt label=disable \
--tag "${BOOTC_IMAGE}" \
-v ${OUTDIR}:/run/.input:ro \
${CONTAINER_TOOL_EXTRA_ARGS} .
13 changes: 8 additions & 5 deletions training/vllm/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONTAINER_TOOL ?= podman
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct)

default: image

Expand All @@ -7,8 +8,10 @@ image:
@mkdir -p ../build
rm -rf ../build/vllm
"${CONTAINER_TOOL}" build \
$(ARCH:%=--platform linux/%) \
--file Containerfile \
--layers=false \
--squash-all \
--tag oci:../build/vllm .
$(ARCH:%=--platform linux/%) \
$(SOURCE_DATE_EPOCH:%=--timestamp=%) \
--file Containerfile \
--layers=false \
--squash-all \
--tag oci:../build/vllm \
${CONTAINER_TOOL_EXTRA_ARGS} .

0 comments on commit 45cebdb

Please sign in to comment.