Skip to content

Commit

Permalink
Fix CUDA_VERSION env var conflict (#2807)
Browse files Browse the repository at this point in the history
CUDA_VERSION may be set in the container to the dot separated CUDA
version number.  This conflicts with the docker build arg CUDA_VERSION
used to select which CUDA version to use.  Rename the latter to
USE_CUDA_VERSION to avoid the conflict.

Co-authored-by: Sean Bowman <[email protected]>
  • Loading branch information
rsbowman-striveworks and rsbowman-striveworks committed Nov 22, 2023
1 parent e792be6 commit 2e1d7c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ RUN python -m pip install -U pip setuptools
# This is only useful for cuda env
RUN export USE_CUDA=1

ARG CUDA_VERSION=""
ARG USE_CUDA_VERSION=""

RUN git clone --depth 1 --recursive https://github.com/pytorch/serve.git

Expand All @@ -71,8 +71,8 @@ WORKDIR "serve"
RUN \
if echo "$BASE_IMAGE" | grep -q "cuda:"; then \
# Install CUDA version specific binary when CUDA version is specified as a build arg
if [ "$CUDA_VERSION" ]; then \
python ./ts_scripts/install_dependencies.py --cuda $CUDA_VERSION; \
if [ "USE_CUDA_VERSION" ]; then \
python ./ts_scripts/install_dependencies.py --cuda $USE_CUDA_VERSION; \
# Install the binary with the latest CPU image on a CUDA base image
else \
python ./ts_scripts/install_dependencies.py; \
Expand Down
8 changes: 4 additions & 4 deletions docker/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ fi

if [ "${BUILD_TYPE}" == "production" ]
then
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" -t "${DOCKER_TAG}" --target production-image .
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" -t "${DOCKER_TAG}" --target production-image .
elif [ "${BUILD_TYPE}" == "ci" ]
then
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" -t "${DOCKER_TAG}" --target ci-image .
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" -t "${DOCKER_TAG}" --target ci-image .
else
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg BUILD_WITH_IPEX="${BUILD_WITH_IPEX}" -t "${DOCKER_TAG}" --target dev-image .
fi
DOCKER_BUILDKIT=1 docker build --file Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg USE_CUDA_VERSION="${CUDA_VERSION}" --build-arg PYTHON_VERSION="${PYTHON_VERSION}" --build-arg BUILD_NIGHTLY="${BUILD_NIGHTLY}" --build-arg BRANCH_NAME="${BRANCH_NAME}" --build-arg BUILD_WITH_IPEX="${BUILD_WITH_IPEX}" -t "${DOCKER_TAG}" --target dev-image .
fi

0 comments on commit 2e1d7c6

Please sign in to comment.