Skip to content

Commit

Permalink
add: arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
K-shir0 committed Mar 27, 2023
1 parent eee7f4a commit c9cf248
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 20 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- master
# TODO(K-shir0): test
- 'feature/*'
release:
types:
- created
Expand All @@ -27,7 +29,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest]
os: [ ubuntu-latest ]
tag:
- ""
- cpu
Expand All @@ -42,49 +44,59 @@ jobs:
target: runtime-env
base_image: ubuntu:20.04
base_runtime_image: ubuntu:20.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-cpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-1.13.1.tgz
use_gpu: false
onnxruntime_version: 1.13.1
platforms: linux/amd64,linux/arm64/v8
- tag: cpu
target: runtime-env
base_image: ubuntu:20.04
base_runtime_image: ubuntu:20.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-cpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-1.13.1.tgz
use_gpu: false
onnxruntime_version: 1.13.1
platforms: linux/amd64,linux/arm64/v8
- tag: cpu-ubuntu20.04
target: runtime-env
base_image: ubuntu:20.04
base_runtime_image: ubuntu:20.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-cpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-1.13.1.tgz
use_gpu: false
onnxruntime_version: 1.13.1
platforms: linux/amd64,linux/arm64/v8
- tag: nvidia
target: runtime-nvidia-env
base_image: ubuntu:20.04
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-gpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-gpu-1.13.1.tgz
use_gpu: true
onnxruntime_version: 1.13.1
platforms: linux/amd64
- tag: nvidia-ubuntu20.04
target: runtime-nvidia-env
base_image: ubuntu:20.04
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-gpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-gpu-1.13.1.tgz
use_gpu: true
onnxruntime_version: 1.13.1
platforms: linux/amd64
# Ubuntu 18.04
- tag: cpu-ubuntu18.04
target: runtime-env
base_image: ubuntu:18.04
base_runtime_image: ubuntu:18.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-cpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-1.13.1.tgz
use_gpu: false
onnxruntime_version: 1.13.1
platforms: linux/amd64,linux/arm64/v8
- tag: nvidia-ubuntu18.04
target: runtime-nvidia-env
base_image: ubuntu:18.04
base_runtime_image: nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu18.04
voicevox_core_asset_prefix: voicevox_core-linux-x64-gpu
onnxruntime_url: https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-gpu-1.13.1.tgz
use_gpu: true
onnxruntime_version: 1.13.1
platforms: linux/amd64

steps:
- uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
Expand Down Expand Up @@ -128,7 +140,6 @@ jobs:
format('{0}:{1}-{2}', env.IMAGE_NAME, matrix.tag, env.VOICEVOX_ENGINE_VERSION)
) || format('{0}:{1}', env.IMAGE_NAME, env.VOICEVOX_ENGINE_VERSION)
) }}
VOICEVOX_CORE_ASSET_NAME: ${{ matrix.voicevox_core_asset_prefix }}-${{ env.VOICEVOX_CORE_VERSION }}
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -138,12 +149,13 @@ jobs:
BASE_RUNTIME_IMAGE=${{ matrix.base_runtime_image }}
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
VOICEVOX_ENGINE_VERSION=${{ env.VOICEVOX_ENGINE_VERSION }}
VOICEVOX_CORE_ASSET_NAME=${{ env.VOICEVOX_CORE_ASSET_NAME }}
VOICEVOX_CORE_VERSION=${{ env.VOICEVOX_CORE_VERSION }}
VOICEVOX_RESOURCE_VERSION=${{ env.VOICEVOX_RESOURCE_VERSION }}
ONNXRUNTIME_URL=${{ matrix.onnxruntime_url }}
USE_GPU=${{ matrix.use_gpu }}
ONNXRUNTIME_VERSION=${{ matrix.onnxruntime_version }}
target: ${{ matrix.target }}
push: true
tags: ${{ env.IMAGE_TAG }}
cache-from: type=registry,ref=${{ env.IMAGE_TAG }}-buildcache
cache-to: type=registry,ref=${{ env.IMAGE_TAG }}-buildcache,mode=max
platforms: ${{ matrix.platforms }}
40 changes: 38 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ RUN <<EOF
EOF

# assert VOICEVOX_CORE_VERSION >= 0.11.0 (ONNX)
ARG VOICEVOX_CORE_ASSET_PREFIX=voicevox_core-linux-x64-cpu
ARG TARGETPLATFORM
ARG USE_GPU=false
ARG VOICEVOX_CORE_VERSION=0.14.2

RUN <<EOF
set -eux

# Processing Switch
if [ "${USE_GPU}" = "true" ]; then
VOICEVOX_CORE_ASSET_ASSET_PROCESSING="gpu"
else
VOICEVOX_CORE_ASSET_ASSET_PROCESSING="cpu"
fi

# TARGETARCH Switch
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then
VOICEVOX_CORE_ASSET_TARGETARCH="x64"
else
VOICEVOX_CORE_ASSET_TARGETARCH="arm64"
fi

VOICEVOX_CORE_ASSET_PREFIX="voicevox_core-linux-${VOICEVOX_CORE_ASSET_TARGETARCH}-${VOICEVOX_CORE_ASSET_ASSET_PROCESSING}"

# Download Core
VOICEVOX_CORE_ASSET_NAME=${VOICEVOX_CORE_ASSET_PREFIX}-${VOICEVOX_CORE_VERSION}
wget -nv --show-progress -c -O "./${VOICEVOX_CORE_ASSET_NAME}.zip" "https://github.com/VOICEVOX/voicevox_core/releases/download/${VOICEVOX_CORE_VERSION}/${VOICEVOX_CORE_ASSET_NAME}.zip"
Expand Down Expand Up @@ -64,10 +82,28 @@ RUN <<EOF
rm -rf /var/lib/apt/lists/*
EOF

ARG ONNXRUNTIME_URL=https://github.com/microsoft/onnxruntime/releases/download/v1.13.1/onnxruntime-linux-x64-1.13.1.tgz
ARG TARGETPLATFORM
ARG USE_GPU=false
ARG ONNXRUNTIME_VERSION=1.13.1
RUN <<EOF
set -eux

# Processing Switch
if [ "${USE_GPU}" = "true" ]; then
ONNXRUNTIME_PROCESSING="gpu-"
else
ONNXRUNTIME_PROCESSING=""
fi

# TARGETARCH Switch
if [ "${TARGETPLATFORM}" = "linux/amd64" ]; then
ONNXRUNTIME_TARGETARCH=x64
else
ONNXRUNTIME_TARGETARCH=aarch64
fi

ONNXRUNTIME_URL="https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/onnxruntime-linux-${ONNXRUNTIME_TARGETARCH}-${ONNXRUNTIME_PROCESSING}${ONNXRUNTIME_VERSION}.tgz"

# Download ONNX Runtime
wget -nv --show-progress -c -O "./onnxruntime.tgz" "${ONNXRUNTIME_URL}"

Expand Down

0 comments on commit c9cf248

Please sign in to comment.