-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build torch and apex in a base image
- Loading branch information
1 parent
8917d33
commit ae78afb
Showing
7 changed files
with
138 additions
and
53 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
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 @@ | ||
name: Build Base Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
torch_version: | ||
description: "PyTorch version" | ||
required: true | ||
type: string | ||
cuda_version: | ||
description: "CUDA version" | ||
required: true | ||
type: string | ||
|
||
run-name: ${{ github.workflow }} -- ${{ inputs.torch_version }} -- ${{ inputs.cuda_version }} | ||
|
||
env: | ||
TORCH_VERSION: ${{ inputs.torch_version }} | ||
CUDA_VERSION: ${{ inputs.cuda_version }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
# strategy: | ||
# matrix: | ||
# cuda_version: [11.8.0, 12.1.0] | ||
permissions: write-all | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Login to ghcr | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build | ||
run: | | ||
docker/build_base.sh ${{ env.TORCH_VERSION }} ${{ env.CUDA_VERSION }} |
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
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,43 @@ | ||
# base image with torch and apex | ||
# relatively lighter than the full-fledged ngc pytorch images | ||
# ARG TORCH_VERSION=2.3.0 | ||
ARG CUDA_VERSION=12.1.0 | ||
FROM nvidia/cuda:$CUDA_VERSION-devel-ubuntu22.04 | ||
|
||
ARG TORCH_VERSION==2.3.0 | ||
|
||
|
||
RUN apt-get update && apt-get install -y \ | ||
libprotobuf-dev \ | ||
libprotobuf-c-dev \ | ||
g++ \ | ||
gcc \ | ||
git \ | ||
locales \ | ||
python3-dev \ | ||
python3-pip | ||
|
||
|
||
RUN pip3 install --upgrade pip | ||
RUN pip3 install packaging | ||
|
||
# Install torch | ||
RUN CU=$(echo "${CUDA_VERSION%.*}" | sed 's/\.//g'); pip3 install torch==$TORCH_VERSION --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;8.7;9.0+PTX" | ||
RUN export MAX_JOBS=$(nproc); 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" \ | ||
./ | ||
|
||
# Install flash-attention | ||
RUN pip install flash-attn --no-build-isolation |
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
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 base image with torch version X and CUDA version 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 | ||
|
||
TORCH_VERSION="$1" | ||
CUDA_VERSION="$2" | ||
[ -z "$CUDA_VERSION" ] && CUDA_VERSION="12.1.0" | ||
|
||
IMAGE="ghcr.io/eole-nlp/eole-base" | ||
TAG="torch$TORCH_VERSION-ubuntu22.04-cuda$CUDA_VERSION" | ||
|
||
echo "Building $IMAGE:$TAG with TORCH_VERSION=$TORCH_VERSION,CUDA_VERSION=$CUDA_VERSION" | ||
|
||
docker build -t $IMAGE:$TAG --progress=plain -f docker/Dockerfile-base --build-arg TORCH_VERSION=$TORCH_VERSION --build-arg CUDA_VERSION=$CUDA_VERSION --no-cache . | ||
docker push $IMAGE:$TAG |
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 |
---|---|---|
|
@@ -3,4 +3,5 @@ rapidfuzz | |
scipy | ||
bitsandbytes>=0.41.2 | ||
spacy | ||
gradio | ||
gradio | ||
autoawq |