From 8fcd338585d361108d441a30663d19f5ad73a5b4 Mon Sep 17 00:00:00 2001 From: Wenxin Zhang Date: Fri, 17 May 2024 11:58:40 +0800 Subject: [PATCH] add dockerfile Signed-off-by: Wenxin Zhang --- .github/workflows/docker/hpu.dockerfile | 25 +++++++++++++++++++ .github/workflows/model_test_hpu.yml | 12 ++------- .../scripts/models/generate_report.sh | 1 + .../workflows/scripts/models/model_test.sh | 3 --- Docker/hpu.dockerfile | 25 +++++++++++++++++++ 5 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/docker/hpu.dockerfile create mode 100644 Docker/hpu.dockerfile diff --git a/.github/workflows/docker/hpu.dockerfile b/.github/workflows/docker/hpu.dockerfile new file mode 100644 index 00000000..e6a35d54 --- /dev/null +++ b/.github/workflows/docker/hpu.dockerfile @@ -0,0 +1,25 @@ +FROM vault.habana.ai/gaudi-docker/1.13.0/ubuntu22.04/habanalabs/pytorch-installer-2.1.0:latest as hpu + +ENV LANG=en_US.UTF-8 +ENV PYTHONPATH=/root:/usr/lib/habanalabs/ +ARG REPO=https://github.com/intel/genaieval.git +ARG REPO_PATH="" +ARG BRANCH=main + +RUN apt-get update && \ + apt-get install git-lfs && \ + git-lfs install + +# Download code +SHELL ["/bin/bash", "--login", "-c"] +RUN mkdir -p /genaieval +COPY ${REPO_PATH} /genaieval +RUN if [ "$REPO_PATH" == "" ]; then rm -rf /genaieval/* && rm -rf /genaieval/.* ; git clone --single-branch --branch=${BRANCH} ${REPO} /genaieval ; fi + +# Build From Source +RUN cd /genaieval && \ + python setup.py install && \ + pip install --upgrade-strategy eager optimum[habana] && \ + pip list + +WORKDIR /genaieval/ \ No newline at end of file diff --git a/.github/workflows/model_test_hpu.yml b/.github/workflows/model_test_hpu.yml index 6791891b..82a10f79 100644 --- a/.github/workflows/model_test_hpu.yml +++ b/.github/workflows/model_test_hpu.yml @@ -61,7 +61,7 @@ jobs: # We need this because GitHub needs to clone the branch to pipeline - name: Docker Build run: | - docker build -f ${{ github.workspace }}/.github/workflows/docker/common.dockerfile --build-arg http_proxy="${{ env.HTTP_PROXY_IMAGE_BUILD }}" --build-arg https_proxy="${{ env.HTTPS_PROXY_IMAGE_BUILD }}" -t ${{ env.DOCKER_NAME }}:${{ env.DOCKER_TAG }} . + docker build --target hpu --build-arg REPO_PATH="." -f ${{ github.workspace }}/Docker/hpu.dockerfile -t ${{ env.DOCKER_NAME }}:${{ env.DOCKER_TAG }} . - name: Docker Run run: | @@ -69,15 +69,7 @@ jobs: docker stop ${{ env.CONTAINER_NAME }} docker rm -vf ${{ env.CONTAINER_NAME }} || true fi - docker run -dit --disable-content-trust --privileged --name=${{ env.CONTAINER_NAME }} -v /dev/shm:/dev/shm \ - -v ${{ github.workspace }}:/GenAIEval \ - -e http_proxy="${{ env.HTTP_PROXY_IMAGE_BUILD }}" -e https_proxy="${{ env.HTTPS_PROXY_IMAGE_BUILD }}" \ - ${{ env.DOCKER_NAME }}:${{ env.DOCKER_TAG }} - - - name: Binary build - run: | - docker exec ${{ env.CONTAINER_NAME }} \ - bash -c "cd /GenAIEval && pip install -r requirements.txt && python setup.py install" + docker run -tid --runtime=habana --name=${{ env.CONTAINER_NAME }} -v ${{ github.workspace }}:/GenAIEval -v /dev/shm:/dev/shm ${{ env.DOCKER_NAME }}:${{ env.DOCKER_TAG }} - name: Evaluation run: | diff --git a/.github/workflows/scripts/models/generate_report.sh b/.github/workflows/scripts/models/generate_report.sh index 56c014cc..8a9dbc38 100644 --- a/.github/workflows/scripts/models/generate_report.sh +++ b/.github/workflows/scripts/models/generate_report.sh @@ -74,6 +74,7 @@ function generate_results { Tasks Model Datasets + VS Accuracy eof diff --git a/.github/workflows/scripts/models/model_test.sh b/.github/workflows/scripts/models/model_test.sh index 1a4a44bb..7d460ac2 100644 --- a/.github/workflows/scripts/models/model_test.sh +++ b/.github/workflows/scripts/models/model_test.sh @@ -73,9 +73,6 @@ function prepare() { else echo "Not found requirements.txt file." fi - if [[ ${device} == "hpu" ]]; then - pip install --upgrade-strategy eager optimum[habana] - fi } function run_benchmark() { diff --git a/Docker/hpu.dockerfile b/Docker/hpu.dockerfile new file mode 100644 index 00000000..58c4ce1b --- /dev/null +++ b/Docker/hpu.dockerfile @@ -0,0 +1,25 @@ +FROM vault.habana.ai/gaudi-docker/1.13.0/ubuntu22.04/habanalabs/pytorch-installer-2.1.0:latest as hpu + +ENV LANG=en_US.UTF-8 +ENV PYTHONPATH=/root:/usr/lib/habanalabs/ +ARG REPO=https://github.com/opea-project/GenAIEval.git +ARG REPO_PATH="" +ARG BRANCH=main + +RUN apt-get update && \ + apt-get install git-lfs && \ + git-lfs install + +# Download code +SHELL ["/bin/bash", "--login", "-c"] +RUN mkdir -p /GenAIEval +COPY ${REPO_PATH} /GenAIEval +RUN if [ "$REPO_PATH" == "" ]; then rm -rf /GenAIEval/* && rm -rf /GenAIEval/.* ; git clone --single-branch --branch=${BRANCH} ${REPO} /GenAIEval ; fi + +# Build From Source +RUN cd /GenAIEval && \ + python setup.py install && \ + pip install --upgrade-strategy eager optimum[habana] && \ + pip list + +WORKDIR /GenAIEval/ \ No newline at end of file