Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

Add Dockerfile with torch installed, enhance image build logic to check for changes (#1811)

chen, suyue694ad39a57fc
diff --git a/.azure-pipelines/docker/Dockerfile.devel b/.azure-pipelines/docker/Dockerfile.devel
index 8fa3e1879..f80c19a8a 100644
--- a/.azure-pipelines/docker/Dockerfile.devel
+++ b/.azure-pipelines/docker/Dockerfile.devel
@@ -48,5 +48,6 @@ ENV UV_NO_PROGRESS=1 \
RUN uv venv --python=3.12 /home/hostuser/.venv
RUN which python && python --version
+RUN uv pip install torch==2.11.0 torchvision==0.26.0 --extra-index-url https://download.pytorch.org/whl/cpu
WORKDIR /home/hostuser
diff --git a/.azure-pipelines/docker/Dockerfile_xpu.devel b/.azure-pipelines/docker/Dockerfile_xpu.devel
index e0d41ad13..3f58171fb 100644
--- a/.azure-pipelines/docker/Dockerfile_xpu.devel
+++ b/.azure-pipelines/docker/Dockerfile_xpu.devel
@@ -48,5 +48,6 @@ ENV UV_NO_PROGRESS=1 \
RUN uv venv --python=3.12 /home/hostuser/.venv
RUN which python && python --version
+RUN uv pip install torch==2.11.0 torchvision==0.26.0 --extra-index-url https://download.pytorch.org/whl/xpu
WORKDIR /home/hostuser
diff --git a/.azure-pipelines/template/docker-template.yml b/.azure-pipelines/template/docker-template.yml
index 4f4d5c06e..693d6f9e2 100644
--- a/.azure-pipelines/template/docker-template.yml
+++ b/.azure-pipelines/template/docker-template.yml
@@ -61,17 +61,28 @@ steps:
- ${{ if eq(parameters.imageSource, 'build') }}:
- script: |
+ set -eo pipefail
+
docker image prune -f
IMAGE="${{ parameters.repoName }}:${{ parameters.repoTag }}"
+ DOCKERFILE="${BUILD_SOURCESDIRECTORY}/.azure-pipelines/docker/${{parameters.dockerFileName}}.devel"
+ CURRENT_HASH=$(md5sum "$DOCKERFILE" | awk '{print $1}')
+ NEED_BUILD=false
if [[ ! $(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep -Fx "$IMAGE") ]]; then
+ NEED_BUILD=true
+ else
+ EXISTING_HASH=$(docker inspect --format='{{index .Config.Labels "dockerfile.hash"}}' "$IMAGE" 2>/dev/null || echo "")
+ if [[ "$CURRENT_HASH" != "$EXISTING_HASH" ]]; then
+ echo "Dockerfile changed (old=$EXISTING_HASH, new=$CURRENT_HASH), rebuilding image..."
+ NEED_BUILD=true
+ fi
+ fi
+ if [[ "$NEED_BUILD" == "true" ]]; then
docker build --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) \
- -f ${BUILD_SOURCESDIRECTORY}/.azure-pipelines/docker/${{parameters.dockerFileName}}.devel -t $IMAGE .
+ --label "dockerfile.hash=$CURRENT_HASH" \
+ -f "$DOCKERFILE" -t $IMAGE .
fi
docker images | grep -i ${{ parameters.repoName }}
- if [[ $? -ne 0 ]]; then
- echo "NO Such Repo"
- exit 1
- fi
displayName: "Build develop docker image"
- ${{ if eq(parameters.imageSource, 'pull') }}: