Skip to content

Commit

Permalink
infra: Testing out GHA based infra
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <naren@narendasan.com>
Signed-off-by: Naren Dasan <narens@nvidia.com>
  • Loading branch information
narendasan committed Aug 7, 2023
1 parent f7b03f4 commit 00b1477
Show file tree
Hide file tree
Showing 16 changed files with 477 additions and 67 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-wheels-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Linux Wheels

on:
pull_request:
push:
branches:
- nightly
- main
- release/*
tags:
# NOTE: Binary build pipelines should only get triggered on release candidate builds
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:

jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-rocm: false
build:
needs: generate-matrix
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
pre-script: packaging/pre_build_script.sh
env-var-script: packaging/env_vars.txt
post-script: ""
smoke-test-script: ""
package-name: torch_tensorrt
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
with:
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: ${{ matrix.pre-script }}
env-var-script: ${{ matrix.env-var-script }}
post-script: ${{ matrix.post-script }}
package-name: ${{ matrix.package-name }}
smoke-test-script: ${{ matrix.smoke-test-script }}
trigger-event: ${{ github.event_name }}
secrets:
AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }}
AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }}
21 changes: 11 additions & 10 deletions .github/workflows/docgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,33 @@ on:

jobs:
build-docs:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container:
image: docker.io/pytorch/manylinux-builder:cuda12.1
steps:
- uses: actions/checkout@v3
with:
ref: ${{github.head_ref}}
- name: Select python
run: |
export PATH=/opt/python/cp311-cp311/bin/:$PATH
- name: Install base deps
run: |
./packaging/pre_build_script.sh
python3 -m pip install pyyaml
VERSION_SUFFIX=cu121 ./packaging/pre_build_script.sh
- name: Get HEAD SHA
id: vars
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Get Bazel version
id: bazel_info
run: echo "version=$(cat .bazelversion)" >> $GITHUB_OUTPUT
- name: Build Python Package
run: |
cp toolchains/ci_workspaces/WORKSPACE.x86_64.cu121.release.rhel WORKSPACE
python -m pip install pip<=23
python -m pip install --pre -e . --extra-index-url https://download.pytorch.org/whl/nightly/cu121
python3 -m pip install pip --upgrade
CUDA_HOME=/usr/local/cuda-12.1 CI_BUILD=1 python3 -m pip install --pre -e . --extra-index-url https://download.pytorch.org/whl/nightly/cu121
- name: Generate New Docs
run: |
cd docsrc
python -m pip install -r requirements.txt
python -c "import torch_tensorrt; print(torch_tensorrt.__version__)"
yum install -y doxygen pandoc
python3 -m pip install -r requirements.txt
python3 -c "import torch_tensorrt; print(torch_tensorrt.__version__)"
make html
cd ..
- uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Cut Nightly

on:
schedule:
- cron: '30 9 * * *'
workflow_dispatch:

jobs:
cut_nightly:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
with:
ref: main
- name: Create nightly commit
shell: bash
run: |
git config --global user.email "torch-tensorrt.github.bot@nvidia.com"
git config --global user.name "Torch-TensorRT Github Bot"
git fetch origin nightly
HEAD_COMMIT_HASH=$(git rev-parse HEAD)
NIGHTLY_DATE=$(date +"%Y-%m-%d")
# shellcheck disable=SC1083
NIGHTLY_RELEASE_COMMIT=$(git commit-tree -p FETCH_HEAD HEAD^{tree} -m "${NIGHTLY_DATE} nightly release (${HEAD_COMMIT_HASH})")
# shellcheck disable=SC1083
git push -f origin "${NIGHTLY_RELEASE_COMMIT}:nightly"
49 changes: 49 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Tests for Torch-TensorRT

on:
pull_request:
push:
branches:
- nightly
- main
- release/*
tags:
# NOTE: Binary build pipelines should only get triggered on release candidate builds
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:

jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-rocm: false

test-torchscript:
needs: generate-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
env:
PYTHON_VERSION: ${{ matrix.python_version }}
PACKAGE_TYPE: wheel
REPOSITORY: pytorch/tensorrt
REF: ""
CU_VERSION: ${{ matrix.desired_cuda }}
name: ${{ matrix.build_name }}
runs-on: ${{ matrix.validation_runner }}
container:
image: ${{ matrix.container_image }}
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }}
# If a build is taking longer than 60 minutes on these runners we need
# to have a conversation
timeout-minutes: 60
steps:
- name: Clean workspace
run: |
printenv
File renamed without changes.
2 changes: 2 additions & 0 deletions packaging/env_vars.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export CI_BUILD="1"
export RELEASE="1"
Empty file added packaging/post_build_script.sh
Empty file.
7 changes: 5 additions & 2 deletions packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash

# Install dependencies
python3 -m pip install pyyaml
TRT_VERSION=$(python3 -c "import versions; versions.tensorrt_version()")
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo
yum check-update
yum install -y ninja-build tensorrt-${TRT_VERSION}.*
yum install -y ninja-build gettext tensorrt-${TRT_VERSION}.*
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /usr/bin/bazel \
&& chmod +x /usr/bin/bazel

cp toolchains/ci_workspaces/WORKSPACE.x86_64.${VERSION_SUFFIX#*+}.release.rhel WORKSPACE
export TORCH_BUILD_NUMBER=$(python -c "import torch, urllib.parse as ul; print(ul.quote_plus(torch.__version__))")

cat toolchains/ci_workspaces/WORKSPACE.x86_64.release.rhel.tmpl | envsubst > WORKSPACE
export CI_BUILD=1
22 changes: 17 additions & 5 deletions py/ci/build_whl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ export CXX=g++
export CUDA_HOME=/usr/local/cuda-12.1
export PROJECT_DIR=/workspace/project

cp -r $CUDA_HOME /usr/local/cuda
rm -rf /usr/local/cuda

if [[ $CUDA_HOME == "/usr/local/cuda-12.1" ]]; then
cp -r /usr/local/cuda-11.8 /usr/local/cuda
cp -r /usr/local/cuda-12.0/ /usr/local/cuda/
rsync -a /usr/local/cuda-12.1/ /usr/local/cuda/
export CUDA_HOME=/usr/local/cuda
else
ln -s $CUDA_HOME /usr/local/cuda
fi

build_wheel() {
$1/bin/python -m pip install --upgrade pip
$1/bin/python -m pip wheel . --config-setting="--build-option=--release" --config-setting="--build-option=--ci" -w dist
$1/bin/python -m pip install --upgrade pip setuptools
$1/bin/python -m pip install -r py/requirements.txt
#$1/bin/python -m pip wheel . -w dist
export BUILD_VERSION=$(cd ${PROJECT_DIR} && $1/bin/python3 -c "import versions; versions.torch_tensorrt_version_release()")
CI_BUILD=1 RELEASE=1 $1/bin/python setup.py bdist_wheel
}

patch_wheel() {
Expand Down Expand Up @@ -86,7 +98,7 @@ libtorchtrt() {
${PY_DIR}/bin/python -m pip install setuptools wheel auditwheel
bazel build //:libtorchtrt --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress
CUDA_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.cuda_version()")
TORCHTRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.torch_tensorrt_version()")
TORCHTRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.torch_tensorrt_version_release()")
TRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.tensorrt_version()")
CUDNN_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.cudnn_version()")
TORCH_VERSION=$(${PY_DIR}/bin/python -c "from torch import __version__;print(__version__.split('+')[0])")
Expand All @@ -106,7 +118,7 @@ libtorchtrt_pre_cxx11_abi() {
${PY_DIR}/bin/python -m pip install setuptools wheel auditwheel
bazel build //:libtorchtrt --config pre_cxx11_abi --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress
CUDA_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.cuda_version()")
TORCHTRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.torch_tensorrt_version()")
TORCHTRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.torch_tensorrt_version_release()")
TRT_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.tensorrt_version()")
CUDNN_VERSION=$(cd ${PROJECT_DIR} && ${PY_DIR}/bin/python3 -c "import versions; versions.cudnn_version()")
TORCH_VERSION=$(${PY_DIR}/bin/python -c "from torch import __version__;print(__version__.split('+')[0])")
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ requires = [
"typing-extensions>=4.7.0",
"future>=0.18.3",
"tensorrt>=8.6,<8.7",
#"torch >=2.0.0,<2.1.0",
"torch==2.1.0.dev20230703+cu121",
"torch >=2.1.0.dev,<2.2.0",
#"torch==2.1.0.dev20230731",
"pybind11==2.6.2",
"numpy",
]
Expand Down Expand Up @@ -42,8 +42,8 @@ readme = {file = "py/README.md", content-type = "text/markdown"}
requires-python = ">=3.8"
keywords = ["pytorch", "torch", "tensorrt", "trt", "ai", "artificial intelligence", "ml", "machine learning", "dl", "deep learning", "compiler", "dynamo", "torchscript", "inference"]
dependencies = [
#"torch>=2.0.0,<2.1.0",
"torch==2.1.0.dev20230703+cu121",
"torch >=2.1.0.dev,<2.2.0",
#"torch==2.1.0.dev20230731",
"tensorrt>=8.6,<8.7",
"packaging>=23",
"numpy",
Expand Down
Loading

0 comments on commit 00b1477

Please sign in to comment.