-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first version of dockerfile and workflow
- Loading branch information
1 parent
a147137
commit 0067255
Showing
3 changed files
with
107 additions
and
0 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,40 @@ | ||
name: Build Docker Images | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
onmt_version: | ||
description: "OpenNMT version" | ||
required: true | ||
type: string | ||
# to facilitate initial tests in PR | ||
push: | ||
branches: | ||
- "docker" | ||
|
||
run-name: ${{ format('{0}:{1}', github.workflow, inputs.onmt_version) }} | ||
|
||
env: | ||
ONMT_VERSION: ${{ inputs.onmt_version || 'test' }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
cuda_version: [11.8.0, 12.1.0] | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: Checkout opennmt repo | ||
uses: actions/checkout@v4 | ||
- name: Build | ||
run: | | ||
docker/build.sh ${{ env.ONMT_VERSION }} ${{ matrix.cuda_version}} | ||
- name: Login to ghcr | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} |
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,39 @@ | ||
ARG CUDA_VERSION=11.8.0 | ||
FROM nvidia/cuda:$CUDA_VERSION-devel-ubuntu22.04 | ||
|
||
RUN apt-get update && apt-get install -y locales gcc g++ python3-dev | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
python3-pip \ | ||
python3-dev \ | ||
libprotobuf-dev \ | ||
libprotobuf-c-dev | ||
|
||
RUN pip3 install --upgrade pip | ||
RUN pip3 install packaging | ||
|
||
# Install torch | ||
RUN CU=$(echo "${CUDA_VERSION%.*}" | sed 's/\.//g'); pip3 install torch --index-url "https://download.pytorch.org/whl/cu$CU" | ||
|
||
# Install apex | ||
RUN mkdir /setup | ||
WORKDIR /setup | ||
RUN git clone https://github.com/nvidia/apex | ||
WORKDIR /setup/apex | ||
RUN pip3 install ninja | ||
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;6.2;7.0;7.5;8.6" | ||
RUN pip3 install -v --no-build-isolation \ | ||
--config-settings --global-option="--cpp_ext" \ | ||
--config-settings --global-option="--cuda_ext" \ | ||
--config-settings --global-option="--deprecated_fused_adam" \ | ||
--global-option="--xentropy" \ | ||
--global-option="--fast_multihead_attn" \ | ||
./ | ||
|
||
COPY . /opennmt-py | ||
WORKDIR /opennmt-py | ||
RUN pip install -e . | ||
|
||
WORKDIR / | ||
|
||
ENTRYPOINT /bin/bash |
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 @@ | ||
#!/bin/bash | ||
# | ||
# Build and push version X of OpenNMT-py with CUDA Y: | ||
# ./build.sh X Y | ||
|
||
set -e | ||
|
||
# allow user to run this script from anywhere | ||
# from https://stackoverflow.com/a/246128 | ||
# one-liner which will give you the full directory name | ||
# of the script no matter where it is being called from | ||
unset CDPATH | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
ROOT_DIR=$DIR/.. | ||
cd $ROOT_DIR | ||
|
||
ONMT_VERSION="$1" | ||
CUDA_VERSION="$2" | ||
[ -z "$CUDA_VERSION" ] && CUDA_VERSION="11.8.0" | ||
|
||
IMAGE="ghcr.io/opennmt/opennmt-py" | ||
TAG="$ONMT_VERSION-ubuntu22.04-cuda${CUDA_VERSION%.*}" | ||
|
||
echo "Building $IMAGE:$TAG with CUDA_VERSION=$CUDA_VERSION" | ||
|
||
docker build -t $IMAGE:$TAG --progress=plain -f docker/Dockerfile --build-arg CUDA_VERSION=$CUDA_VERSION . | ||
docker push $IMAGE:$TAG |