Skip to content

Commit

Permalink
run pckage test in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
guocuimi committed Oct 14, 2024
1 parent 260596f commit 84877f0
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 28 deletions.
39 changes: 11 additions & 28 deletions .github/workflows/package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,15 @@ jobs:

- name: Install the package and run pytest
timeout-minutes: 10
shell: bash -l {0}
run: |
# install the wheel package
# sudo apt install python3-venv
# extract cuda version
CUDA_VERSION=$(nvcc --version | grep "Cuda compilation tools" | cut -d ' ' -f 5 | cut -d ',' -f 1)
# Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install PyTorch
pip install torch==${TORCH_VERSION} -i "https://download.pytorch.org/whl/cu${CUDA_VERSION//./}"
# Install the wheel package
pip install dist/*.whl
# Install the test requirements
pip install -r requirements-test.txt
# Run pytest
printf "\n\nRunning pytest\n\n"
cd tests
python3 -m pytest || exit 1
printf "\n\n"
# Deactivate the virtual environment
deactivate
docker pull pytorch/manylinux-builder:cuda${CUDA_VERSION}
docker run --rm -t --gpus=all \
-v "$CI_CACHE_DIR":/ci_cache \
-v "$GITHUB_WORKSPACE":/ScaleLLM \
-e PYTHON_VERSION=${PYTHON_VERSION} \
-e CUDA_VERSION=${CUDA_VERSION} \
-e TORCH_VERSION=${TORCH_VERSION} \
-e PIP_CACHE_DIR=/ci_cache/.pip \
-u $(id -u):$(id -g) \
pytorch/manylinux-builder:cuda${CUDA_VERSION} \
bash /ScaleLLM/scripts/run_pytest.sh
41 changes: 41 additions & 0 deletions scripts/run_pytest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e

ensure_env() {
local var_name="$1"
if [ -z "${!var_name}" ]; then
echo "Error: Environment variable '$var_name' is not set."
exit 1
fi
}

ensure_env PYTHON_VERSION
ensure_env TORCH_VERSION
ensure_env CUDA_VERSION

PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"

export HOME=/tmp/home
mkdir -p $HOME
export PATH="$HOME/.local/bin:$PATH"

# choose python version
PYVER="${PYTHON_VERSION//./}"
export PATH="/opt/python/cp${PYVER}-cp${PYVER}/bin:$PATH"

# install PyTorch
pip install torch==$TORCH_VERSION -i "https://download.pytorch.org/whl/cu${CUDA_VERSION//./}"

cd "$PROJECT_ROOT"

# install dependencies
pip install numpy
pip install -r requirements-test.txt

# install scalellm wheel
pip install dist/*.whl

# run pytest
printf "\n\nRunning pytest\n\n"
# cd tests
python3 -m pytest

0 comments on commit 84877f0

Please sign in to comment.