[CI/build] Removes source compilation from runtime image (#26966)
Signed-off-by: bbartels <benjamin@bartels.dev>
This commit is contained in:
+30
-14
@@ -1,12 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Script to install DeepGEMM from source
|
||||
# This script can be used both in Docker builds and by users locally
|
||||
|
||||
# Script to build and/or install DeepGEMM from source
|
||||
# Default: build and install immediately
|
||||
# Optional: build wheels to a directory for later installation (useful in multi-stage builds)
|
||||
set -e
|
||||
|
||||
# Default values
|
||||
DEEPGEMM_GIT_REPO="https://github.com/deepseek-ai/DeepGEMM.git"
|
||||
DEEPGEMM_GIT_REF="594953acce41793ae00a1233eb516044d604bcb6"
|
||||
WHEEL_DIR=""
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
@@ -27,11 +28,20 @@ while [[ $# -gt 0 ]]; do
|
||||
CUDA_VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
--wheel-dir)
|
||||
if [[ -z "$2" || "$2" =~ ^- ]]; then
|
||||
echo "Error: --wheel-dir requires a directory path." >&2
|
||||
exit 1
|
||||
fi
|
||||
WHEEL_DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo "Options:"
|
||||
echo " --ref REF Git reference to checkout (default: $DEEPGEMM_GIT_REF)"
|
||||
echo " --cuda-version VER CUDA version (auto-detected if not provided)"
|
||||
echo " --wheel-dir PATH If set, build wheel into PATH but do not install"
|
||||
echo " -h, --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
@@ -57,16 +67,15 @@ fi
|
||||
CUDA_MAJOR="${CUDA_VERSION%%.*}"
|
||||
CUDA_MINOR="${CUDA_VERSION#${CUDA_MAJOR}.}"
|
||||
CUDA_MINOR="${CUDA_MINOR%%.*}"
|
||||
|
||||
echo "CUDA version: $CUDA_VERSION (major: $CUDA_MAJOR, minor: $CUDA_MINOR)"
|
||||
|
||||
# Check CUDA version requirement
|
||||
if [ "$CUDA_MAJOR" -lt 12 ] || { [ "$CUDA_MAJOR" -eq 12 ] && [ "$CUDA_MINOR" -lt 8 ]; }; then
|
||||
echo "Skipping DeepGEMM installation (requires CUDA 12.8+ but got ${CUDA_VERSION})"
|
||||
echo "Skipping DeepGEMM build/installation (requires CUDA 12.8+ but got ${CUDA_VERSION})"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Installing DeepGEMM from source..."
|
||||
echo "Preparing DeepGEMM build..."
|
||||
echo "Repository: $DEEPGEMM_GIT_REPO"
|
||||
echo "Reference: $DEEPGEMM_GIT_REF"
|
||||
|
||||
@@ -76,23 +85,31 @@ trap 'rm -rf "$INSTALL_DIR"' EXIT
|
||||
|
||||
# Clone the repository
|
||||
git clone --recursive --shallow-submodules "$DEEPGEMM_GIT_REPO" "$INSTALL_DIR/deepgemm"
|
||||
|
||||
echo "🏗️ Building DeepGEMM"
|
||||
pushd "$INSTALL_DIR/deepgemm"
|
||||
|
||||
# Checkout the specific reference
|
||||
git checkout "$DEEPGEMM_GIT_REF"
|
||||
|
||||
# Build DeepGEMM
|
||||
# Clean previous build artifacts
|
||||
# (Based on https://github.com/deepseek-ai/DeepGEMM/blob/main/install.sh)
|
||||
rm -rf build dist
|
||||
rm -rf *.egg-info
|
||||
rm -rf build dist *.egg-info
|
||||
|
||||
# Build wheel
|
||||
echo "🏗️ Building DeepGEMM wheel..."
|
||||
python3 setup.py bdist_wheel
|
||||
|
||||
# Install the wheel
|
||||
# If --wheel-dir was specified, copy wheels there and exit
|
||||
if [ -n "$WHEEL_DIR" ]; then
|
||||
mkdir -p "$WHEEL_DIR"
|
||||
cp dist/*.whl "$WHEEL_DIR"/
|
||||
echo "✅ Wheel built and copied to $WHEEL_DIR"
|
||||
popd
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Default behaviour: install built wheel
|
||||
if command -v uv >/dev/null 2>&1; then
|
||||
echo "Installing DeepGEMM wheel using uv..."
|
||||
# Use --system in Docker contexts, respect user's environment otherwise
|
||||
if [ -n "$VLLM_DOCKER_BUILD_CONTEXT" ]; then
|
||||
uv pip install --system dist/*.whl
|
||||
else
|
||||
@@ -104,5 +121,4 @@ else
|
||||
fi
|
||||
|
||||
popd
|
||||
|
||||
echo "✅ DeepGEMM installation completed successfully"
|
||||
|
||||
Reference in New Issue
Block a user