-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimized for smaller images and better cache utilization
- Loading branch information
1 parent
9d744f4
commit f3e4115
Showing
6 changed files
with
168 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
VERSION ?= $(shell git rev-parse --short HEAD) | ||
IMAGE_REGISTRY ?= docker.io | ||
IMAGE_REPO ?= $(IMAGE_REGISTRY)/diambra | ||
NVIDIA_REGISTRY ?= $(IMAGE_REGISTRY) | ||
UBUNTU_REGISTRY ?= $(IMAGE_REGISTRY) | ||
CONTAINER_RUNTIME ?= docker | ||
CUDA_10_BASE_TAG ?= 10.0-cudnn7-runtime-ubuntu18.04 | ||
CUDA_11_BASE_TAG ?= 11.0.3-cudnn8-runtime-ubuntu20.04 | ||
UBUNTU_BASE_TAG ?= 20.04 | ||
|
||
# Only used in info ouput | ||
ROM_PATH ?= ../diambraArena-roms/ | ||
|
||
|
||
# Images to build base image from | ||
UBUNTU_BASE_IMAGE := $(UBUNTU_REGISTRY)/library/ubuntu:$(UBUNTU_BASE_TAG) | ||
CUDA_10_BASE_IMAGE := $(NVIDIA_REGISTRY)/nvidia/cuda:$(CUDA_10_BASE_TAG) | ||
CUDA_11_BASE_IMAGE := $(NVIDIA_REGISTRY)/nvidia/cuda:$(CUDA_11_BASE_TAG) | ||
|
||
# Base image names | ||
BASE_IMAGE := $(IMAGE_REPO)/base:$(VERSION) | ||
BASE_IMAGE_CUDA_10 := $(IMAGE_REPO)/base-cuda10:$(VERSION) | ||
BASE_IMAGE_CUDA_11 := $(IMAGE_REPO)/base-cuda11:$(VERSION) | ||
|
||
# Final image names | ||
IMAGE := $(IMAGE_REPO)/diambra-arena:$(VERSION) | ||
IMAGE_CUDA_10 := $(IMAGE_REPO)/diambra-arena-cuda10:$(VERSION) | ||
IMAGE_CUDA_11 := $(IMAGE_REPO)/diambra-arena-cuda11:$(VERSION) | ||
|
||
|
||
DIAMBRA_CRED_PATH := ${HOME}/.diambraCred | ||
CONTAINER_ARGS := \ | ||
-v $(ROM_PATH):/opt/diambraArena/roms:ro \\\n\ | ||
-v ${HOME}/.diambraCred:/root/.diambraCred \\\n | ||
|
||
CONTAINER_ARGS_X := $(CONTAINER_ARGS) \ | ||
-v /tmp/.X11-unix:/tmp/.X11-unix \\\n \ | ||
-h $(shell hostname) -e DISPLAY=${DISPLAY} \\\n | ||
|
||
|
||
define INFO | ||
Available images: | ||
|
||
# CPU only | ||
## Headless | ||
$(CONTAINER_RUNTIME) run $(CONTAINER_ARGS) $(IMAGE) python examples/diambraArenaGist.py | ||
|
||
## with X | ||
$(CONTAINER_RUNTIME) run $(CONTAINER_ARGS_X) $(IMAGE) python examples/diambraArenaGist.py | ||
|
||
# NVIDIA CUDA | ||
## Headless | ||
$(CONTAINER_RUNTIME) run $(CONTAINER_ARGS) $(IMAGE_CUDA_11) python examples/diambraArenaGist.py | ||
|
||
## Cuda | ||
$(CONTAINER_RUNTIME) run $(CONTAINER_ARGS_X) $(IMAGE_CUDA_11) python examples/diambraArenaGist.py | ||
|
||
endef | ||
|
||
define build_image | ||
$(CONTAINER_RUNTIME) build -f $(1) -t $(2) --build-arg BASE_IMAGE=$(3) $(4) . | ||
endef | ||
|
||
.PHONY: all | ||
all: images | ||
|
||
export INFO | ||
info: | ||
@echo "$$INFO" | ||
|
||
.PHONY: options | ||
options: | ||
grep '^[A-Z_ ]*?' $(lastword $(MAKEFILE_LIST)) | ||
|
||
.PHONY: images | ||
images: image image-cuda-10 image-cuda-11 | ||
|
||
.PHONY: push-images | ||
push-images: images | ||
$(CONTAINER_RUNTIME) push $(BASE_IMAGE) | ||
$(CONTAINER_RUNTIME) push $(BASE_IMAGE_CUDA_10) | ||
$(CONTAINER_RUNTIME) push $(BASE_IMAGE_CUDA_11) | ||
$(CONTAINER_RUNTIME) push $(IMAGE) | ||
$(CONTAINER_RUNTIME) push $(IMAGE_CUDA_10) | ||
$(CONTAINER_RUNTIME) push $(IMAGE_CUDA_11) | ||
|
||
# Base Images | ||
.PHONY: image-base | ||
image-base: | ||
$(call build_image,docker/Dockerfile.base,$(BASE_IMAGE),$(UBUNTU_BASE_IMAGE)) | ||
|
||
.PHONY: image-base-cuda-10 | ||
image-base-cuda-10: image-base | ||
$(call build_image,docker/Dockerfile.base,$(BASE_IMAGE_CUDA_10),$(CUDA_10_BASE_IMAGE),--build-arg BOOST_VERSION=1.65) | ||
|
||
.PHONY: image-base-cuda-11 | ||
image-base-cuda-11: image-base | ||
$(call build_image,docker/Dockerfile.base,$(BASE_IMAGE_CUDA_11),$(CUDA_11_BASE_IMAGE)) | ||
|
||
# Final Images | ||
.PHONY: image | ||
image: image-base | ||
$(call build_image,docker/Dockerfile,$(IMAGE),$(BASE_IMAGE)) | ||
|
||
.PHONY: image-cuda-10 | ||
image-cuda-10: image-base-cuda-10 | ||
$(call build_image,docker/Dockerfile,$(IMAGE_CUDA_10),$(BASE_IMAGE_CUDA_10)) | ||
|
||
.PHONY: image-cuda-11 | ||
image-cuda-11: image-base-cuda-11 | ||
$(call build_image,docker/Dockerfile,$(IMAGE_CUDA_11),$(BASE_IMAGE_CUDA_11)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ARG BASE_IMAGE=diambra/base:latest | ||
FROM $BASE_IMAGE | ||
|
||
WORKDIR /opt/diambraArena/ | ||
COPY . /opt/diambraArena/repo/ | ||
RUN pip install repo/ | ||
|
||
ENV DIAMBRAROMSPATH="/opt/diambraArena/roms/" | ||
ENV DOCKER_EXEC=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Create DIAMBRA Arena base image (diambra:diambra-arena-base) | ||
ARG BASE_IMAGE=ubuntu:20.04 | ||
FROM $BASE_IMAGE | ||
|
||
ARG BOOST_VERSION=1.71.0 | ||
|
||
# Maintainer | ||
LABEL maintainer="DIAMBRA Team <info@diambra.ai>" | ||
|
||
RUN printf 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";\n' > /etc/apt/apt.conf.d/99norecommend && \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get -qy install -qy gnupg2 curl wget ca-certificates build-essential \ | ||
libfreetype6-dev libhdf5-serial-dev libzmq3-dev pkg-config software-properties-common unzip \ | ||
python3-pip python3-tk python3-setuptools libopencv-dev libboost-filesystem${BOOST_VERSION} xvfb \ | ||
libsdl2-2.0-0 libsdl2-ttf-2.0-0 libqt5core5a libqt5widgets5 libqt5gui5 lshw && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* && \ | ||
ln -s python3 /usr/bin/python && \ | ||
ln -sf pip3 /usr/bin/pip && \ | ||
pip install --upgrade pip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# DiambraArena Container Images | ||
- to build all images, run `make images` | ||
- to push images, run `make push-images` | ||
|
||
You can use a custom registries to pull base images and push final images to. To | ||
see available options, run `make options`. | ||
|
||
Run `make info` to see how to run the images. | ||
|
||
|
||
## Image Hierarchy | ||
```` | ||
[ubuntu] [nvidia/cuda] | ||
\ / | ||
\ / | ||
<Dockerfile.base> | ||
/ \ | ||
[base] [base-cuda] | ||
\ / | ||
<Dockerfile> | ||
/ \ | ||
/ \ | ||
[arena] [arena-cuda] | ||
[] Image | ||
<> Dockerfile | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.