x
This commit is contained in:
+41
-9
@@ -1,13 +1,43 @@
|
|||||||
FROM registry.fedoraproject.org/fedora:43
|
FROM registry.fedoraproject.org/fedora:43
|
||||||
|
|
||||||
|
# Proxy configuration ARGs
|
||||||
|
ARG HTTP_PROXY=""
|
||||||
|
ARG HTTPS_PROXY=""
|
||||||
|
ARG SOCKS_PROXY=""
|
||||||
|
|
||||||
|
# Set environment variables if proxies are provided
|
||||||
|
ENV http_proxy=$HTTP_PROXY
|
||||||
|
ENV https_proxy=$HTTPS_PROXY
|
||||||
|
ENV no_proxy="localhost,127.0.0.1,::1"
|
||||||
|
|
||||||
|
# Configure DNF proxy if provided
|
||||||
|
RUN if [ -n "$HTTP_PROXY" ]; then \
|
||||||
|
echo "proxy=$HTTP_PROXY" >> /etc/dnf/dnf.conf; \
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy proxychains configuration
|
# Copy proxychains configuration
|
||||||
COPY proxychains4.conf /etc/proxychains.conf
|
COPY proxychains4.conf /etc/proxychains.conf
|
||||||
|
|
||||||
|
# Update proxychains4.conf if SOCKS_PROXY is provided (format: host:port)
|
||||||
|
RUN if [ -n "$SOCKS_PROXY" ]; then \
|
||||||
|
HOST=$(echo $SOCKS_PROXY | cut -d: -f1); \
|
||||||
|
PORT=$(echo $SOCKS_PROXY | cut -d: -f2); \
|
||||||
|
sed -i "s/socks5.*/socks5 $HOST $PORT/g" /etc/proxychains.conf; \
|
||||||
|
else \
|
||||||
|
# If no proxy, remove the hardcoded one to avoid proxychains errors
|
||||||
|
sed -i "s/^socks5.*/# socks5 127.0.0.1 9050/g" /etc/proxychains.conf; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define a proxy wrapper
|
||||||
|
RUN echo '#!/bin/bash' > /usr/local/bin/maybe_proxy && \
|
||||||
|
echo 'if grep -q "^socks5 [0-9]" /etc/proxychains.conf; then proxychains "$@"; else "$@"; fi' >> /usr/local/bin/maybe_proxy && \
|
||||||
|
chmod +x /usr/local/bin/maybe_proxy
|
||||||
|
|
||||||
# 1. System Base & Build Tools
|
# 1. System Base & Build Tools
|
||||||
RUN dnf -y install --setopt=install_weak_deps=False --nodocs \
|
RUN dnf -y install --setopt=install_weak_deps=False --nodocs \
|
||||||
python3.13 python3.13-devel git rsync libatomic bash ca-certificates curl \
|
python3.13 python3.13-devel git rsync libatomic bash ca-certificates curl \
|
||||||
gcc gcc-c++ binutils make ffmpeg-free \
|
gcc gcc-c++ binutils make ffmpeg-free \
|
||||||
cmake ninja-build aria2c tar xz vim nano proxychains \
|
cmake ninja-build aria2c tar xz vim nano proxychains-ng \
|
||||||
libdrm-devel zlib-devel openssl-devel jq \
|
libdrm-devel zlib-devel openssl-devel jq \
|
||||||
numactl-devel gperftools-libs procps-ng \
|
numactl-devel gperftools-libs procps-ng \
|
||||||
&& dnf clean all && rm -rf /var/cache/dnf/*
|
&& dnf clean all && rm -rf /var/cache/dnf/*
|
||||||
@@ -19,12 +49,12 @@ ARG GFX=gfx120X-all
|
|||||||
RUN set -euo pipefail; \
|
RUN set -euo pipefail; \
|
||||||
BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \
|
BASE="https://therock-nightly-tarball.s3.amazonaws.com"; \
|
||||||
PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \
|
PREFIX="therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}"; \
|
||||||
KEY="$(proxychains curl -s "${BASE}?list-type=2&prefix=${PREFIX}" \
|
KEY="$(maybe_proxy curl -s "${BASE}?list-type=2&prefix=${PREFIX}" \
|
||||||
| tr '<' '\n' \
|
| tr '<' '\n' \
|
||||||
| grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \
|
| grep -o "therock-dist-linux-${GFX}-${ROCM_MAJOR_VER}\..*\.tar\.gz" \
|
||||||
| sort -V | tail -n1)"; \
|
| sort -V | tail -n1)"; \
|
||||||
echo "Downloading Latest Tarball: ${KEY}"; \
|
echo "Downloading Latest Tarball: ${KEY}"; \
|
||||||
proxychains aria2c -x 16 -s 16 -j 16 --file-allocation=none "${BASE}/${KEY}" -o therock.tar.gz; \
|
maybe_proxy aria2c -x 16 -s 16 -j 16 --file-allocation=none "${BASE}/${KEY}" -o therock.tar.gz; \
|
||||||
mkdir -p /opt/rocm; \
|
mkdir -p /opt/rocm; \
|
||||||
tar xzf therock.tar.gz -C /opt/rocm --strip-components=1; \
|
tar xzf therock.tar.gz -C /opt/rocm --strip-components=1; \
|
||||||
rm therock.tar.gz
|
rm therock.tar.gz
|
||||||
@@ -58,10 +88,10 @@ RUN printf 'source /opt/venv/bin/activate\n' > /etc/profile.d/venv.sh
|
|||||||
RUN python -m pip install --upgrade pip wheel packaging "setuptools<80.0.0"
|
RUN python -m pip install --upgrade pip wheel packaging "setuptools<80.0.0"
|
||||||
|
|
||||||
# 5. Install PyTorch (TheRock Nightly)
|
# 5. Install PyTorch (TheRock Nightly)
|
||||||
RUN proxychains python -m pip install \
|
RUN maybe_proxy python -m pip install \
|
||||||
--index-url https://rocm.nightlies.amd.com/v2-staging/gfx120X-all/ \
|
--index-url https://rocm.nightlies.amd.com/v2-staging/gfx120X-all/ \
|
||||||
--pre torch torchaudio torchvision && \
|
--pre torch torchaudio torchvision && \
|
||||||
proxychains python -m pip install pyyaml
|
maybe_proxy python -m pip install pyyaml
|
||||||
|
|
||||||
# Flash-Attention
|
# Flash-Attention
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
@@ -71,8 +101,10 @@ ENV HIP_PATH="/opt/rocm"
|
|||||||
ENV PATH="/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH"
|
ENV PATH="/opt/rocm/bin:/opt/rocm/llvm/bin:$PATH"
|
||||||
ENV LD_LIBRARY_PATH="/opt/rocm/lib:/opt/rocm/lib64:/opt/rocm/llvm/lib"
|
ENV LD_LIBRARY_PATH="/opt/rocm/lib:/opt/rocm/lib64:/opt/rocm/llvm/lib"
|
||||||
|
|
||||||
RUN git config --global http.proxy socks5://192.168.0.11:1080 && \
|
RUN if [ -n "$SOCKS_PROXY" ]; then \
|
||||||
git config --global https.proxy socks5://192.168.0.11:1080 && \
|
git config --global http.proxy "socks5://$SOCKS_PROXY" && \
|
||||||
|
git config --global https.proxy "socks5://$SOCKS_PROXY"; \
|
||||||
|
fi && \
|
||||||
git clone --recursive https://github.com/ROCm/flash-attention.git && \
|
git clone --recursive https://github.com/ROCm/flash-attention.git && \
|
||||||
cd flash-attention && \
|
cd flash-attention && \
|
||||||
git checkout main_perf && \
|
git checkout main_perf && \
|
||||||
@@ -80,7 +112,7 @@ RUN git config --global http.proxy socks5://192.168.0.11:1080 && \
|
|||||||
cd /opt && rm -rf /opt/flash-attention
|
cd /opt && rm -rf /opt/flash-attention
|
||||||
|
|
||||||
# 6. Clone vLLM
|
# 6. Clone vLLM
|
||||||
RUN proxychains git clone https://github.com/vllm-project/vllm.git /opt/vllm
|
RUN maybe_proxy git clone https://github.com/vllm-project/vllm.git /opt/vllm
|
||||||
WORKDIR /opt/vllm
|
WORKDIR /opt/vllm
|
||||||
|
|
||||||
# --- PATCHING ---
|
# --- PATCHING ---
|
||||||
@@ -127,7 +159,7 @@ RUN export HIP_DEVICE_LIB_PATH=$(find /opt/rocm -type d -name bitcode -print -qu
|
|||||||
|
|
||||||
# bitsandbytes
|
# bitsandbytes
|
||||||
WORKDIR /opt
|
WORKDIR /opt
|
||||||
RUN proxychains git clone -b rocm_enabled_multi_backend https://github.com/ROCm/bitsandbytes.git
|
RUN maybe_proxy git clone -b rocm_enabled_multi_backend https://github.com/ROCm/bitsandbytes.git
|
||||||
WORKDIR /opt/bitsandbytes
|
WORKDIR /opt/bitsandbytes
|
||||||
|
|
||||||
ENV HIP_PLATFORM="amd"
|
ENV HIP_PLATFORM="amd"
|
||||||
|
|||||||
+22
-1
@@ -82,6 +82,8 @@ show_usage() {
|
|||||||
echo " -m, --models DIR 指定模型目录路径"
|
echo " -m, --models DIR 指定模型目录路径"
|
||||||
echo " -p, --port PORT 指定服务端口"
|
echo " -p, --port PORT 指定服务端口"
|
||||||
echo " -b, --branch NAME 指定 Git 分支(默认:main)"
|
echo " -b, --branch NAME 指定 Git 分支(默认:main)"
|
||||||
|
echo " --http-proxy URL 指定构建时的 HTTP 代理 (例如: http://192.168.0.10:7890)"
|
||||||
|
echo " --socks-proxy HOST:PORT 指定构建时的 SOCKS 代理 (例如: 192.168.0.10:1080)"
|
||||||
echo " -h, --help 显示此帮助信息"
|
echo " -h, --help 显示此帮助信息"
|
||||||
echo ""
|
echo ""
|
||||||
echo "示例:"
|
echo "示例:"
|
||||||
@@ -98,6 +100,8 @@ FORCE_BUILD=false
|
|||||||
STOP_ONLY=false
|
STOP_ONLY=false
|
||||||
DETACH=true
|
DETACH=true
|
||||||
CUSTOM_CONFIG=""
|
CUSTOM_CONFIG=""
|
||||||
|
HTTP_PROXY_ARG=""
|
||||||
|
SOCKS_PROXY_ARG=""
|
||||||
CUSTOM_MODELS=""
|
CUSTOM_MODELS=""
|
||||||
CUSTOM_PORT=""
|
CUSTOM_PORT=""
|
||||||
|
|
||||||
@@ -107,6 +111,14 @@ while [[ $# -gt 0 ]]; do
|
|||||||
FORCE_BUILD=true
|
FORCE_BUILD=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--http-proxy)
|
||||||
|
HTTP_PROXY_ARG="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--socks-proxy)
|
||||||
|
SOCKS_PROXY_ARG="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-s|--stop)
|
-s|--stop)
|
||||||
STOP_ONLY=true
|
STOP_ONLY=true
|
||||||
shift
|
shift
|
||||||
@@ -265,7 +277,16 @@ build_image() {
|
|||||||
|
|
||||||
BUILD_START=$(date +%s)
|
BUILD_START=$(date +%s)
|
||||||
|
|
||||||
if docker build --network=host --build-arg MAX_JOBS=32 -t "${IMAGE_NAME}:${IMAGE_TAG}" .; then
|
# 准备构建参数
|
||||||
|
BUILD_ARGS="--network=host --build-arg MAX_JOBS=32"
|
||||||
|
if [ -n "$HTTP_PROXY_ARG" ]; then
|
||||||
|
BUILD_ARGS="${BUILD_ARGS} --build-arg HTTP_PROXY=${HTTP_PROXY_ARG} --build-arg HTTPS_PROXY=${HTTP_PROXY_ARG}"
|
||||||
|
fi
|
||||||
|
if [ -n "$SOCKS_PROXY_ARG" ]; then
|
||||||
|
BUILD_ARGS="${BUILD_ARGS} --build-arg SOCKS_PROXY=${SOCKS_PROXY_ARG}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if docker build ${BUILD_ARGS} -t "${IMAGE_NAME}:${IMAGE_TAG}" .; then
|
||||||
BUILD_END=$(date +%s)
|
BUILD_END=$(date +%s)
|
||||||
BUILD_TIME=$((BUILD_END - BUILD_START))
|
BUILD_TIME=$((BUILD_END - BUILD_START))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user