Skip to content

Commit

Permalink
enable building on arm macs
Browse files Browse the repository at this point in the history
  • Loading branch information
lreiher committed Aug 14, 2023
1 parent 902a90d commit 4c4dc1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ MAKEFLAGS += --no-print-directory
MAKEFILE_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))

# build architecture
DEFAULT_ARCH := $(shell dpkg --print-architecture)
DEFAULT_ARCH := $(shell dpkg --print-architecture 2> /dev/null || uname -m)
ARCH := $(if $(ARCH),$(ARCH),$(DEFAULT_ARCH))

# defaults
DEFAULT_TF_VERSION := 2.13.0
TF_VERSIONS := 2.13.0 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.3 2.9.2 2.9.1 2.9.0 2.8.4 2.8.3 2.8.2 2.8.1 2.8.0 2.7.4 2.7.3 2.7.2 2.7.1 2.7.0 2.6.5 2.6.4 2.6.3 2.6.2 2.6.1 2.6.0 2.5.3 2.5.2 2.5.1 2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.3 2.2.2 2.2.1 2.2.0 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0
DEFAULT_JOBS := $(shell nproc)
DEFAULT_JOBS := $(shell nproc 2> /dev/null || sysctl -n hw.ncpu)
DEFAULT_GPU := 1
ifeq ($(ARCH), arm64)
DEFAULT_TF_CUDA_COMPUTE_CAPABILITIES := 5.3,6.2,7.2,8.7
Expand Down
4 changes: 2 additions & 2 deletions scripts/.common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ set -e
set -o pipefail

DEFAULT_TF_VERSION="2.13.0"
DEFAULT_JOBS=$(nproc)
DEFAULT_JOBS=$(nproc 2> /dev/null || sysctl -n hw.ncpu)
DEFAULT_GPU=1
DEFAULT_ARCH=$(dpkg --print-architecture)
DEFAULT_ARCH=$(dpkg --print-architecture 2> /dev/null || uname -m)

TF_VERSION=${TF_VERSION:-${DEFAULT_TF_VERSION}}
JOBS=${JOBS:-${DEFAULT_JOBS}}
Expand Down
10 changes: 7 additions & 3 deletions scripts/1-build-official-devel-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ source $(dirname "$0")/.common.sh

CPU_GPU_POSTFIX=${GPU_POSTFIX:--cpu}
BUILD_DIR=${DOWNLOAD_DOCKERFILE_DIR}
BSD_SED_ARG=""
if [ "$(uname -s)" = "Darwin" ]; then
BSD_SED_ARG=".bak"
fi

if [ "$ARCH" = "amd64" ]; then
DOCKERFILE=${DOWNLOAD_DOCKERFILE_DIR}/dockerfiles/devel${CPU_GPU_POSTFIX}.Dockerfile
Expand All @@ -32,16 +36,16 @@ elif [ "$ARCH" = "arm64" ]; then
else
DOCKERFILE=${DOWNLOAD_DOCKERFILE_DIR}/dockerfiles/arm64v8/devel-cpu-arm64v8.Dockerfile
if [ "$TF_VERSION" = "2.8.4" ]; then
sed -i "s/ubuntu:\${UBUNTU_VERSION}/nvcr.io\/nvidia\/l4t-tensorflow:r34.1.1-tf2.8-py3/" $DOCKERFILE
sed -i $BSD_SED_ARG "s/ubuntu:\${UBUNTU_VERSION}/nvcr.io\/nvidia\/l4t-tensorflow:r34.1.1-tf2.8-py3/" $DOCKERFILE
else
sed -i "s/ubuntu:\${UBUNTU_VERSION}/nvcr.io\/nvidia\/l4t-tensorflow:r35.1.0-tf2.9-py3/" $DOCKERFILE
sed -i $BSD_SED_ARG "s/ubuntu:\${UBUNTU_VERSION}/nvcr.io\/nvidia\/l4t-tensorflow:r35.1.0-tf2.9-py3/" $DOCKERFILE
fi
fi
fi

# replace sklearn (deprecated) with scikit-learn
# https://pypi.org/project/sklearn/
sed -i "s/sklearn/scikit-learn/" $DOCKERFILE
sed -i $BSD_SED_ARG "s/sklearn/scikit-learn/" $DOCKERFILE

echo "Building ${IMAGE_DEVEL_ARCH} ... "
docker build -t ${IMAGE_DEVEL_ARCH} -f ${DOCKERFILE} ${BUILD_DIR} | tee ${LOG_FILE}

0 comments on commit 4c4dc1e

Please sign in to comment.