mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-24 06:42:52 +08:00
Merge pull request #6462 from shibingli/main
Add ARG HTTP_PROXY in Dockerfile to support HTTP proxy during image building Former-commit-id: 8741e5b3e87a392a3c9d50455e4916c3a938fb24
This commit is contained in:
commit
d195329185
@ -17,16 +17,28 @@ ARG INSTALL_LIGER_KERNEL=false
|
|||||||
ARG INSTALL_HQQ=false
|
ARG INSTALL_HQQ=false
|
||||||
ARG INSTALL_EETQ=false
|
ARG INSTALL_EETQ=false
|
||||||
ARG PIP_INDEX=https://pypi.org/simple
|
ARG PIP_INDEX=https://pypi.org/simple
|
||||||
|
ARG HTTP_PROXY=
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Set http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
echo "Configuring proxy..."; \
|
||||||
|
export http_proxy=$HTTP_PROXY; \
|
||||||
|
export https_proxy=$HTTP_PROXY; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Install the requirements
|
# Install the requirements
|
||||||
COPY requirements.txt /app
|
COPY requirements.txt /app
|
||||||
RUN pip config set global.index-url "$PIP_INDEX" && \
|
RUN pip config set global.index-url "$PIP_INDEX" && \
|
||||||
pip config set global.extra-index-url "$PIP_INDEX" && \
|
pip config set global.extra-index-url "$PIP_INDEX" && \
|
||||||
python -m pip install --upgrade pip && \
|
python -m pip install --upgrade pip && \
|
||||||
python -m pip install -r requirements.txt
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
python -m pip install --proxy=$HTTP_PROXY -r requirements.txt; \
|
||||||
|
else \
|
||||||
|
python -m pip install -r requirements.txt; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy the rest of the application into the image
|
# Copy the rest of the application into the image
|
||||||
COPY . /app
|
COPY . /app
|
||||||
@ -51,13 +63,30 @@ RUN EXTRA_PACKAGES="metrics"; \
|
|||||||
if [ "$INSTALL_EETQ" == "true" ]; then \
|
if [ "$INSTALL_EETQ" == "true" ]; then \
|
||||||
EXTRA_PACKAGES="${EXTRA_PACKAGES},eetq"; \
|
EXTRA_PACKAGES="${EXTRA_PACKAGES},eetq"; \
|
||||||
fi; \
|
fi; \
|
||||||
pip install -e ".[$EXTRA_PACKAGES]"
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
pip install --proxy=$HTTP_PROXY -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
else \
|
||||||
|
pip install -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Rebuild flash attention
|
# Rebuild flash attention
|
||||||
RUN pip uninstall -y transformer-engine flash-attn && \
|
RUN pip uninstall -y transformer-engine flash-attn && \
|
||||||
if [ "$INSTALL_FLASHATTN" == "true" ]; then \
|
if [ "$INSTALL_FLASHATTN" == "true" ]; then \
|
||||||
pip uninstall -y ninja && pip install ninja && \
|
pip uninstall -y ninja && \
|
||||||
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
pip install --proxy=$HTTP_PROXY ninja && \
|
||||||
|
pip install --proxy=$HTTP_PROXY --no-cache-dir flash-attn --no-build-isolation; \
|
||||||
|
else \
|
||||||
|
pip install ninja && \
|
||||||
pip install --no-cache-dir flash-attn --no-build-isolation; \
|
pip install --no-cache-dir flash-attn --no-build-isolation; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Unset http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
unset http_proxy; \
|
||||||
|
unset https_proxy; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up volumes
|
# Set up volumes
|
||||||
|
@ -12,16 +12,28 @@ ENV DEBIAN_FRONTEND=noninteractive
|
|||||||
ARG INSTALL_DEEPSPEED=false
|
ARG INSTALL_DEEPSPEED=false
|
||||||
ARG PIP_INDEX=https://pypi.org/simple
|
ARG PIP_INDEX=https://pypi.org/simple
|
||||||
ARG TORCH_INDEX=https://download.pytorch.org/whl/cpu
|
ARG TORCH_INDEX=https://download.pytorch.org/whl/cpu
|
||||||
|
ARG HTTP_PROXY=
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Set http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
echo "Configuring proxy..."; \
|
||||||
|
export http_proxy=$HTTP_PROXY; \
|
||||||
|
export https_proxy=$HTTP_PROXY; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Install the requirements
|
# Install the requirements
|
||||||
COPY requirements.txt /app
|
COPY requirements.txt /app
|
||||||
RUN pip config set global.index-url "$PIP_INDEX" && \
|
RUN pip config set global.index-url "$PIP_INDEX" && \
|
||||||
pip config set global.extra-index-url "$TORCH_INDEX" && \
|
pip config set global.extra-index-url "$TORCH_INDEX" && \
|
||||||
python -m pip install --upgrade pip && \
|
python -m pip install --upgrade pip && \
|
||||||
python -m pip install -r requirements.txt
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
python -m pip install --proxy=$HTTP_PROXY -r requirements.txt; \
|
||||||
|
else \
|
||||||
|
python -m pip install -r requirements.txt; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy the rest of the application into the image
|
# Copy the rest of the application into the image
|
||||||
COPY . /app
|
COPY . /app
|
||||||
@ -31,7 +43,17 @@ RUN EXTRA_PACKAGES="torch-npu,metrics"; \
|
|||||||
if [ "$INSTALL_DEEPSPEED" == "true" ]; then \
|
if [ "$INSTALL_DEEPSPEED" == "true" ]; then \
|
||||||
EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \
|
EXTRA_PACKAGES="${EXTRA_PACKAGES},deepspeed"; \
|
||||||
fi; \
|
fi; \
|
||||||
pip install -e ".[$EXTRA_PACKAGES]"
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
pip install --proxy=$HTTP_PROXY -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
else \
|
||||||
|
pip install -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Unset http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
unset http_proxy; \
|
||||||
|
unset https_proxy; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Set up volumes
|
# Set up volumes
|
||||||
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]
|
VOLUME [ "/root/.cache/huggingface", "/root/.cache/modelscope", "/app/data", "/app/output" ]
|
||||||
|
@ -13,16 +13,28 @@ ARG INSTALL_FLASHATTN=false
|
|||||||
ARG INSTALL_LIGER_KERNEL=false
|
ARG INSTALL_LIGER_KERNEL=false
|
||||||
ARG INSTALL_HQQ=false
|
ARG INSTALL_HQQ=false
|
||||||
ARG PIP_INDEX=https://pypi.org/simple
|
ARG PIP_INDEX=https://pypi.org/simple
|
||||||
|
ARG HTTP_PROXY=
|
||||||
|
|
||||||
# Set the working directory
|
# Set the working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Set http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
echo "Configuring proxy..."; \
|
||||||
|
export http_proxy=$HTTP_PROXY; \
|
||||||
|
export https_proxy=$HTTP_PROXY; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Install the requirements
|
# Install the requirements
|
||||||
COPY requirements.txt /app
|
COPY requirements.txt /app
|
||||||
RUN pip config set global.index-url "$PIP_INDEX" && \
|
RUN pip config set global.index-url "$PIP_INDEX" && \
|
||||||
pip config set global.extra-index-url "$PIP_INDEX" && \
|
pip config set global.extra-index-url "$PIP_INDEX" && \
|
||||||
python -m pip install --upgrade pip && \
|
python -m pip install --upgrade pip && \
|
||||||
python -m pip install -r requirements.txt
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
python -m pip install --proxy=$HTTP_PROXY -r requirements.txt; \
|
||||||
|
else \
|
||||||
|
python -m pip install -r requirements.txt; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy the rest of the application into the image
|
# Copy the rest of the application into the image
|
||||||
COPY . /app
|
COPY . /app
|
||||||
@ -44,13 +56,29 @@ RUN EXTRA_PACKAGES="metrics"; \
|
|||||||
if [ "$INSTALL_HQQ" == "true" ]; then \
|
if [ "$INSTALL_HQQ" == "true" ]; then \
|
||||||
EXTRA_PACKAGES="${EXTRA_PACKAGES},hqq"; \
|
EXTRA_PACKAGES="${EXTRA_PACKAGES},hqq"; \
|
||||||
fi; \
|
fi; \
|
||||||
pip install -e ".[$EXTRA_PACKAGES]"
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
pip install --proxy=$HTTP_PROXY -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
else \
|
||||||
|
pip install -e ".[$EXTRA_PACKAGES]"; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Rebuild flash attention
|
# Rebuild flash attention
|
||||||
RUN pip uninstall -y transformer-engine flash-attn && \
|
RUN pip uninstall -y transformer-engine flash-attn && \
|
||||||
if [ "$INSTALL_FLASHATTN" == "true" ]; then \
|
if [ "$INSTALL_FLASHATTN" == "true" ]; then \
|
||||||
pip uninstall -y ninja && pip install ninja && \
|
pip uninstall -y ninja && \
|
||||||
|
if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
pip install --proxy=$HTTP_PROXY ninja && \
|
||||||
|
pip install --proxy=$HTTP_PROXY --no-cache-dir flash-attn --no-build-isolation; \
|
||||||
|
else \
|
||||||
|
pip install ninja && \
|
||||||
pip install --no-cache-dir flash-attn --no-build-isolation; \
|
pip install --no-cache-dir flash-attn --no-build-isolation; \
|
||||||
|
fi; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Unset http proxy
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
unset http_proxy; \
|
||||||
|
unset https_proxy; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up volumes
|
# Set up volumes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user