Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ on:

env:
DOCKER_IMAGE: registry-egc.enflame-tech.com/enflame/ci_sast:v1.0-os
CI_IMAGE: registry-egc.enflame-tech.com/artifacts/vllm_gcu:v0.11.0-TR3.7.107-ubuntu2204
SAST_REPO: EnflameTechnology/sast
SAST_BRANCH: main

jobs:
static-check:
all-ci-check:
runs-on: S60

steps:
Expand Down Expand Up @@ -47,3 +48,28 @@ jobs:
-w /app \
"${{ env.DOCKER_IMAGE }}" \
bash -c 'cd /app && python3 /sast/run.py --all_ci_check'

- name: Install driver
run: |
pwd;ls -l;ls -l ./vllm-gcu;ls -l ./vllm-gcu/tests;sudo bash ./vllm-gcu/tests/install_driver.sh


- name: Run CI build and tests
run: |
sudo docker run --rm \
-v "$(pwd)/:/app" \
--volume=/log:/log \
--volume=/root:/root \
--volume=/lib/modules/:/lib/modules/ \
--volume=/usr/src/:/usr/src/ \
--volume=/dev:/dev \
--privileged \
-v /home/pypi_packages:/home/pypi_packages \
-w /app \
"${{ env.CI_IMAGE }}" \
bash -c 'git config --global --add safe.directory /app/vllm-gcu && sudo bash ./vllm-gcu/.pipeline/build.sh ci_build;sudo bash ./vllm-gcu/tests/install_env.sh'

- name: Clean up
if: always()
run: |
sudo rm -rf vllm-gcu sast
29 changes: 29 additions & 0 deletions .pipeline/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Copyright 2024 Enflame. All Rights Reserved.
#
set -eu -o pipefail
BUILD_ROOT_DIR=$(pwd)
set -x
ARCH=$(uname -m)

function ci_build() {
cd ${project_name}
python3 setup.py bdist_wheel
}

function main() {
$build_job_name
}

export project_name=${project_name:-"vllm-gcu"}
export cpu=${process_num:-"10"}

if [ "$#" -eq 1 ]; then
build_job_name=$1
else
echo "donot support this build job"
exit 1
fi

main "$@"
exit $?
131 changes: 131 additions & 0 deletions tests/install_driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#!/bin/bash
#
# Install Enflame driver from the vllm_gcu Docker image.
# Requires: docker, sudo (for driver .run installer).
#
# Usage:
# bash install_driver.sh # Quiet driver installer output (default)
# bash install_driver.sh --debug # Show full driver installer logs
#
set -e

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'

log_info() { echo -e "${CYAN}[INFO]${NC} $*"; }
log_step() { echo -e "${YELLOW}[STEP]${NC} $*"; }
log_ok() { echo -e "${GREEN}${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }

DEBUG=0
while [[ $# -gt 0 ]]; do
case "$1" in
-d|--debug) DEBUG=1; shift ;;
-h|--help)
echo "Usage: $0 [--debug|-d]"
exit 0
;;
*)
echo -e "${RED}[ERROR]${NC} Unknown option: $1"
echo "Usage: $0 [--debug|-d]"
exit 1
;;
esac
done

run_installer() {
local installer="$1"
if [ "$DEBUG" -eq 1 ]; then
sudo "./${installer}" --no-auto-load --no-dkms
else
local log_file
log_file="$(mktemp /tmp/torch_gcu_driver_XXXXXX.log)"
if sudo "./${installer}" --no-auto-load --no-dkms > "$log_file" 2>&1; then
rm -f "$log_file"
else
echo -e "${RED}[ERROR]${NC} Driver installation failed:"
cat "$log_file"
log_info "Re-run with --debug to stream installer output live."
rm -f "$log_file"
exit 1
fi
fi
}

DOCKER_IMAGE="registry-egc.enflame-tech.com/artifacts/vllm_gcu:v0.11.0-TR3.7.107-ubuntu2204"
CONTAINER_NAME="tmp_container"
TOTAL_STEPS=4
STEP=0

next_step() {
STEP=$((STEP + 1))
echo ""
log_step "[$STEP/$TOTAL_STEPS] $*"
}

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR"/../.. && pwd)"

echo ""
echo "============================================"
echo " Enflame Driver Installer"
echo "============================================"
log_info "Working directory: $REPO_ROOT"
log_info "Docker image: $DOCKER_IMAGE"
if [ "$DEBUG" -eq 1 ]; then
log_info "Debug mode: enabled (installer output visible)"
fi
echo ""

cd "$REPO_ROOT"

# Remove leftover container from a previous failed run
if docker ps -a --format '{{.Names}}' | grep -qx "$CONTAINER_NAME"; then
log_warn "Removing existing container '$CONTAINER_NAME' from a previous run..."
docker rm -f "$CONTAINER_NAME" > /dev/null
log_ok "Old container removed"
fi

next_step "Pull driver files from Docker image"
log_info "Creating temporary container (this may take a while on first run)..."
docker run --name "$CONTAINER_NAME" "$DOCKER_IMAGE"
log_ok "Container created: $CONTAINER_NAME"

next_step "Copy driver package to host"
mkdir -p tmp
log_info "Copying /enflame from container to ./tmp/ ..."
docker cp "$CONTAINER_NAME:/enflame" tmp/
log_ok "Driver files copied to $REPO_ROOT/tmp/enflame"

next_step "Install driver (requires sudo)"
DRIVER_DIR="$REPO_ROOT/tmp/enflame/driver"
cd "$DRIVER_DIR"
log_info "Driver directory: $DRIVER_DIR"
log_info "Available installer(s):"
ls -lh enflame-x86_64*.run 2>/dev/null || ls -lh
echo ""
log_warn "You may be prompted for your sudo password."
INSTALLER=(enflame-x86_64*.run)
if [ ! -f "${INSTALLER[0]}" ]; then
echo -e "${RED}[ERROR]${NC} No enflame-x86_64*.run installer found in $DRIVER_DIR"
exit 1
fi
log_info "Running: sudo ./${INSTALLER[0]} --no-auto-load --no-dkms"
run_installer "${INSTALLER[0]}"
log_ok "Driver installed successfully"

next_step "Clean up temporary files"
cd "$REPO_ROOT"
log_info "Removing ./tmp and container $CONTAINER_NAME ..."
rm -rf tmp
docker rm "$CONTAINER_NAME" > /dev/null
log_ok "Cleanup complete"

echo ""
echo "============================================"
echo -e " ${GREEN}Driver installation finished.${NC}"
echo "============================================"
echo ""
116 changes: 116 additions & 0 deletions tests/install_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash
#
# Install vllm_gcu Python environment: dependencies and wheel package.
# Requires: python3, sudo (for system-wide pip install).
#
# Usage:
# bash install_env.sh # Quiet pip output (default)
# bash install_env.sh --debug # Show full pip install logs
#
set -e

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'

log_info() { echo -e "${CYAN}[INFO]${NC} $*"; }
log_step() { echo -e "${YELLOW}[STEP]${NC} $*"; }
log_ok() { echo -e "${GREEN}${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }

DEBUG=0
while [[ $# -gt 0 ]]; do
case "$1" in
-d|--debug) DEBUG=1; shift ;;
-h|--help)
echo "Usage: $0 [--debug|-d]"
exit 0
;;
*)
echo -e "${RED}[ERROR]${NC} Unknown option: $1"
echo "Usage: $0 [--debug|-d]"
exit 1
;;
esac
done

run_pip() {
if [ "$DEBUG" -eq 1 ]; then
sudo python3 -m pip "$@"
else
local log_file
log_file="$(mktemp /tmp/vllm_gcu_pip_XXXXXX.log)"
if sudo python3 -m pip "$@" > "$log_file" 2>&1; then
rm -f "$log_file"
else
echo -e "${RED}[ERROR]${NC} pip install failed:"
cat "$log_file"
log_info "Re-run with --debug to stream pip output live."
rm -f "$log_file"
exit 1
fi
fi
}

TOTAL_STEPS=2
STEP=0

next_step() {
STEP=$((STEP + 1))
echo ""
log_step "[$STEP/$TOTAL_STEPS] $*"
}

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR"/.. && pwd)"

echo ""
echo "============================================"
echo " vllm_gcu Environment Installer"
echo "============================================"
log_info "Working directory: $REPO_ROOT"
log_info "Python: $(python3 --version 2>&1 || echo 'not found')"
if [ "$DEBUG" -eq 1 ]; then
log_info "Debug mode: enabled (pip output visible)"
fi
echo ""

cd "$REPO_ROOT"

REQUIREMENTS="$REPO_ROOT/requirements.txt"
if [ ! -f "$REQUIREMENTS" ]; then
echo -e "${RED}[ERROR]${NC} requirements.txt not found: $REQUIREMENTS"
exit 1
fi

WHEELS=(dist/vllm_gcu*.whl)
if [ ! -f "${WHEELS[0]}" ]; then
echo -e "${RED}[ERROR]${NC} No vllm_gcu wheel found in $REPO_ROOT/dist/"
log_info "Build the wheel first, e.g.: bash .pipeline/build.sh"
exit 1
fi

next_step "Install Python dependencies"
log_info "Installing from: $REQUIREMENTS"
log_warn "You may be prompted for your sudo password."
run_pip install -r "$REQUIREMENTS"
log_ok "Dependencies installed"

next_step "Install vllm_gcu wheel"
log_info "Wheel package(s):"
ls -lh "${WHEELS[@]}"
echo ""
log_warn "You may be prompted for your sudo password again."
cd /home/pypi_packages
run_pip install vllm-0.11.0-cp38-abi3-manylinux1_x86_64.whl
cd -
run_pip install "${WHEELS[@]}"
log_ok "vllm_gcu installed: $(python3 -c 'import vllm_gcu; print(vllm_gcu.__file__)' 2>/dev/null || echo '(import check skipped)')"

echo ""
echo "============================================"
echo -e " ${GREEN}Environment installation finished.${NC}"
echo "============================================"
echo ""
Loading