Skip to content

Commit

Permalink
Merge branch 'lluo/tensorrt_test_windows_wf' into lluo/upgrade_tensor…
Browse files Browse the repository at this point in the history
…rt_version
  • Loading branch information
lanluo-nvidia committed Nov 14, 2024
2 parents fade4c5 + dbd740b commit e2afaca
Show file tree
Hide file tree
Showing 6 changed files with 578 additions and 22 deletions.
229 changes: 229 additions & 0 deletions .github/workflows/build-tensorrt-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
name: Build Torch-TensorRT wheel on Windows with Future TensorRT Versions

on:
workflow_call:
inputs:
repository:
description: 'Repository to checkout, defaults to ""'
default: ""
type: string
ref:
description: 'Reference to checkout, defaults to "nightly"'
default: "nightly"
type: string
test-infra-repository:
description: "Test infra repository to use"
default: "pytorch/test-infra"
type: string
test-infra-ref:
description: "Test infra reference to use"
default: ""
type: string
build-matrix:
description: "Build matrix to utilize"
default: ""
type: string
pre-script:
description: "Pre script to run prior to build"
default: ""
type: string
env-script:
description: "Script to setup environment variables for the build"
default: ""
type: string
wheel-build-params:
description: "Additional parameters for bdist_wheel"
default: ""
type: string
post-script:
description: "Post script to run prior to build"
default: ""
type: string
smoke-test-script:
description: "Script for Smoke Test for a specific domain"
default: ""
type: string
package-name:
description: "Name of the actual python package that is imported"
default: ""
type: string
trigger-event:
description: "Trigger Event in caller that determines whether or not to upload"
default: ""
type: string
cache-path:
description: "The path(s) on the runner to cache or restore. The path is relative to repository."
default: ""
type: string
cache-key:
description: "The key created when saving a cache and the key used to search for a cache."
default: ""
type: string
submodules:
description: "Works as stated in actions/checkout, but the default value is recursive"
required: false
type: string
default: recursive
timeout:
description: 'Timeout for the job (in minutes)'
default: 60
type: number

permissions:
id-token: write
contents: read

jobs:
build:
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.build-matrix) }}
env:
PYTHON_VERSION: ${{ matrix.python_version }}
PACKAGE_TYPE: wheel
REPOSITORY: ${{ inputs.repository }}
REF: ${{ inputs.ref }}
CU_VERSION: ${{ matrix.desired_cuda }}
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
ARCH: win_amd64
TENSORRT_STRIP_PREFIX: ${{ matrix.tensorrt.strip_prefix }}
TENSORRT_VERSION: ${{ matrix.tensorrt.version }}
TENSORRT_URLS: ${{ matrix.tensorrt.urls }}
TENSORRT_SHA256: ${{ matrix.tensorrt.sha256 }}
UPLOAD_ARTIFACT_NAME: pytorch_tensorrt_${{ matrix.tensorrt.version }}_${{ matrix.python_version }}_${{ matrix.desired_cuda }}_win_amd64
name: build_tensorrt${{ matrix.tensorrt.version }}_py${{matrix.python_version}}_${{matrix.desired_cuda}}
runs-on: ${{ matrix.validation_runner }}
defaults:
run:
shell: bash -l {0}
# If a build is taking longer than 60 minutes on these runners we need
# to have a conversation
timeout-minutes: 120
steps:
- uses: actions/checkout@v3
with:
# Support the use case where we need to checkout someone's fork
repository: ${{ inputs.test-infra-repository }}
ref: ${{ inputs.test-infra-ref }}
path: test-infra
- uses: ./test-infra/.github/actions/setup-ssh
name: Setup SSH
with:
github-secret: ${{ secrets.GITHUB_TOKEN }}
activate-with-label: false
instructions: "SSH with rdesktop using ssh -L 3389:localhost:3389 %%username%%@%%hostname%%"
- name: Add Conda scripts to GitHub path
run: |
echo "C:/Jenkins/Miniconda3/Scripts" >> $GITHUB_PATH
- uses: ./test-infra/.github/actions/set-channel
- name: Set PYTORCH_VERSION
if: ${{ env.CHANNEL == 'test' }}
run: |
# When building RC, set the version to be the current candidate version,
# otherwise, leave it alone so nightly will pick up the latest
echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
- uses: ./test-infra/.github/actions/setup-binary-builds
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
submodules: ${{ inputs.submodules }}
setup-miniconda: false
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
- name: Install XPU support package
if: ${{ matrix.gpu_arch_type == 'xpu' }}
run: |
cmd //c .\\test-infra\\.github\\scripts\\install_xpu.bat
- name: Install torch dependency
run: |
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} ${PIP_INSTALL_TORCH}
- name: Run Pre-Script with Caching
if: ${{ inputs.pre-script != '' }}
uses: ./test-infra/.github/actions/run-script-with-cache
with:
cache-path: ${{ inputs.cache-path }}
cache-key: ${{ inputs.cache-key }}
repository: ${{ inputs.repository }}
script: ${{ inputs.pre-script }}
is_windows: 'enabled'
- name: Build clean
working-directory: ${{ inputs.repository }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
run: |
source "${BUILD_ENV_FILE}"
if [[ -z "${ENV_SCRIPT}" ]]; then
${CONDA_RUN} python setup.py clean
else
if [[ ! -f ${ENV_SCRIPT} ]]; then
echo "::error::Specified env-script file (${ENV_SCRIPT}) not found"
exit 1
else
${CONDA_RUN} ${ENV_SCRIPT} python setup.py clean
fi
fi
- name: Build the wheel (bdist_wheel)
working-directory: ${{ inputs.repository }}
env:
ENV_SCRIPT: ${{ inputs.env-script }}
BUILD_PARAMS: ${{ inputs.wheel-build-params }}
run: |
source "${BUILD_ENV_FILE}"
if [[ "$CU_VERSION" == "cpu" ]]; then
# CUDA and CPU are ABI compatible on the CPU-only parts, so strip
# in this case
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
else
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//')"
fi
if [[ -z "${ENV_SCRIPT}" ]]; then
${CONDA_RUN} python setup.py bdist_wheel
else
${CONDA_RUN} ${ENV_SCRIPT} python setup.py bdist_wheel ${BUILD_PARAMS}
fi
- name: Run post-script
working-directory: ${{ inputs.repository }}
env:
POST_SCRIPT: ${{ inputs.post-script }}
ENV_SCRIPT: ${{ inputs.env-script }}
if: ${{ inputs.post-script != '' }}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
${CONDA_RUN} ${ENV_SCRIPT} ${POST_SCRIPT}
- name: Smoke Test
env:
ENV_SCRIPT: ${{ inputs.env-script }}
PACKAGE_NAME: ${{ inputs.package-name }}
SMOKE_TEST_SCRIPT: ${{ inputs.smoke-test-script }}
run: |
source "${BUILD_ENV_FILE}"
WHEEL_NAME=$(ls "${{ inputs.repository }}/dist/")
echo "$WHEEL_NAME"
${CONDA_RUN} pip install "${{ inputs.repository }}/dist/$WHEEL_NAME"
if [[ ! -f "${{ inputs.repository }}"/${SMOKE_TEST_SCRIPT} ]]; then
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} not found"
${CONDA_RUN} "${{ inputs.repository }}/${ENV_SCRIPT}" python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
else
echo "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT} found"
${CONDA_RUN} "${{ inputs.repository }}/${ENV_SCRIPT}" python "${{ inputs.repository }}/${SMOKE_TEST_SCRIPT}"
fi
# NB: Only upload to GitHub after passing smoke tests
- name: Upload wheel to GitHub
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: ${{ env.UPLOAD_ARTIFACT_NAME }}
path: ${{ inputs.repository }}/dist/
- uses: ./test-infra/.github/actions/teardown-windows
if: always()
name: Teardown Windows

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ inputs.repository }}-${{ github.event_name == 'workflow_dispatch' }}-${{ inputs.job-name }}
cancel-in-progress: true
Loading

0 comments on commit e2afaca

Please sign in to comment.