Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
lanluo-nvidia committed Jun 17, 2024
1 parent 947ab53 commit bc8d6cf
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 3 deletions.
76 changes: 76 additions & 0 deletions .github/scripts/build-linux-release-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

set -x

CURRENT_DIR=`pwd`

ls

python -m pip list | grep torch

python -m pip list | grep tensorrt

if [[ "${PYTHON_VERSION}" == "3.8" ]]; then
PY_BUILD_CODE=cp38-cp38
elif [[ "${PYTHON_VERSION}" == "3.9" ]]; then
PY_BUILD_CODE=cp39-cp39
elif [[ "${PYTHON_VERSION}" == "3.10" ]]; then
PY_BUILD_CODE=cp310-cp310
elif [[ "${PYTHON_VERSION}" == "3.11" ]]; then
PY_BUILD_CODE=cp38-cp38
else
echo "python version: ${PYTHON_VERSION} is not supported"
exit
fi

python -m pip install auditwheel

# download TensorRT tarball
wget -q https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.0.1/tars/TensorRT-10.0.1.6.Linux.x86_64-gnu.cuda-12.4.tar.gz \
&& gunzip TensorRT-10.0.1.6.Linux.x86_64-gnu.cuda-12.4.tar.gz \
&& tar -xvf TensorRT-10.0.1.6.Linux.x86_64-gnu.cuda-12.4.tar \
&& rm TensorRT-10.0.1.6.Linux.x86_64-gnu.cuda-12.4.tar

TENSERRT_DIR=${CURRENT_DIR}/TensorRT-10.0.1.6

SITE_PKG_DIR=`python -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])'`

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${TENSERRT_DIR}/lib:${SITE_PKG_DIR}/torch/lib:${SITE_PKG_DIR}/tensorrt/:${CUDA_HOME}/lib64:${CUDA_HOME}/lib64/stubs \

python -m auditwheel repair \
$(cat py/ci/soname_excludes.params) \
--plat manylinux_2_34_x86_64 \
/opt/torch-tensorrt-builds/torch_tensorrt-*-${PY_BUILD_CODE}-linux_x86_64.whl

cp wheelhouse/torch_tensorrt*x86_64.whl dist/

CUDA_VERSION=$(python -c "import versions; versions.cuda_version()")
TORCHTRT_VERSION=$(python -c "import versions; versions.torch_tensorrt_version_release()")
TRT_VERSION=$(python -c "import versions; versions.tensorrt_version()")
TORCH_VERSION=$(python -c "from torch import __version__;print(__version__.split('+')[0])")

libtorchtrt() {
pre_cxx11_abi=${1}
PROJECT_DIR=${CURRENT_DIR}
cd ${PROJECT_DIR}
# mkdir -p ${PROJECT_DIR}/py/wheelhouse

PY_NAME=python${PYTHON_VERSION}
PY_DIR=/opt/python/${PY_BUILD_CODE}

python -m pip install -r ${PROJECT_DIR}/py/requirements.txt
if [[ '${pre_cxx11_abi}' == 'true' ]]; then
bazel build //:libtorchtrt --config pre_cxx11_abi --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress
cp ${PROJECT_DIR}/bazel-bin/libtorchtrt.tar.gz \
${PROJECT_DIR}/dist/libtorchtrt-${TORCHTRT_VERSION}-pre-cxx11-abi-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz
else
bazel build //:libtorchtrt --platforms //toolchains:ci_rhel_x86_64_linux -c opt --noshow_progress
cp ${PROJECT_DIR}/bazel-bin/libtorchtrt.tar.gz \
${PROJECT_DIR}/dist/libtorchtrt-${TORCHTRT_VERSION}-tensorrt${TRT_VERSION}-cuda${CUDA_VERSION}-libtorch${TORCH_VERSION}-x86_64-linux.tar.gz
fi
}

# build pre_cxx11_abi
libtorchtrt true
# build cxx11_abi
libtorchtrt false
6 changes: 3 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Lint Code

# on:
# pull_request:
# types: [opened, synchronize, ready_for_review, review_requested, reopened]
on:
pull_request:
types: [opened, synchronize, ready_for_review, review_requested, reopened]

jobs:
cpp-linting:
Expand Down
200 changes: 200 additions & 0 deletions .github/workflows/linux-release-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Release artifacts on Linux

on:
workflow_call:
inputs:
job-name:
description: "Name of task"
default: ""
type: string
repository:
description: 'Repository to checkout, defaults to ""'
default: ""
type: string
ref:
description: 'Reference to checkout, defaults to "nightly"'
default: "nightly"
type: string
pre-script:
description: "Pre script to run prior to build"
default: ""
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: "release/2.3"
type: string
build-matrix:
description: "Build matrix to utilize"
default: ""
type: string
architecture:
description: Architecture to build for x86_64 for default Linux, or aarch64 for Linux aarch64 builds
required: false
type: string
default: x86_64
setup-miniconda:
description: Works as stated in actions/checkout, but the default value is recursive
required: false
type: boolean
default: true
# script:
# description: 'Script to utilize'
# default: "python setup.py bdist_wheel"
# type: string
continue-on-error:
description: "Prevents a job from failing when a step fails. Set to true to allow a job to pass when exec script step fails."
default: false
type: boolean
upload-artifact:
description: 'Name to give artifacts uploaded from ${RUNNER_ARTIFACT_DIR}'
default: ''
type: string

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 }}
# SCRIPT: ${{ inputs.script }}
# RUNNER_TEST_RESULTS_DIR: /tmp/test_results
ARCH: ${{ inputs.architecture }}
name: ${{ inputs.job-name }}-${{ matrix.desired_cuda }}
runs-on: ${{ matrix.validation_runner }}
container:
image: ${{ matrix.container_image }}
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }}
if: ${{ env.CU_VERSION == '12.1' }}
# 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: |
set -euxo pipefail
echo "::group::Cleanup debug output"
rm -rfv "${GITHUB_WORKSPACE}"
mkdir -p "${GITHUB_WORKSPACE}"
echo "::endgroup::"
- 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
- name: Setup SSH
uses: ./test-infra/.github/actions/setup-ssh
with:
github-secret: ${{ github.token }}
- uses: ./test-infra/.github/actions/set-channel
- uses: ./test-infra/.github/actions/setup-binary-builds
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
setup-miniconda: ${{ inputs.setup-miniconda }}
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
- 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 }}
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: /opt/torch-tensorrt-builds/
# - name: Install torch and torch-tensorrt
# if: ${{ inputs.pre-script != '' }}
# uses: ./test-infra/.github/actions/run-script-with-cache
# with:
# repository: ${{ inputs.repository }}
# script: .github/scripts/install-torch-tensorrt.sh
- name: Pack script
continue-on-error: ${{ inputs.continue-on-error }}
working-directory: ${{ inputs.repository }}
env:
ALL_SECRETS: ${{ toJSON(secrets) }}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
{
echo "${SCRIPT}";
} > "user_script"
cat .github/scripts/build-linux-release-artifacts.sh user_script > exec_script
- name: Run Script
uses: ./test-infra/.github/actions/run-script-with-cache
with:
repository: ${{ inputs.repository }}
script: exec_script
# - name: Surface failing tests
# if: always()
# uses: pmeier/[email protected]
# with:
# path: ${{ env.RUNNER_TEST_RESULTS_DIR }}
# fail-on-empty: false

# - name: Prepare artifacts for upload
# working-directory: ${{ inputs.repository }}
# id: check-artifacts
# env:
# UPLOAD_ARTIFACT_NAME: ${{ inputs.upload-artifact }}
# run: |
# if [ -d "dist" ] && [ -n "$(ls -A dist)" ]; then
# mv -v dist/* "${RUNNER_ARTIFACT_DIR}/"
# fi

# # if [[ -n "${UPLOAD_ARTIFACT_NAME}" ]]; then
# # # If the default execution path is followed then we should get a wheel in the dist/ folder
# # # attempt to just grab whatever is in there and scoop it all up
# # if find "dist/" -name "*.whl" >/dev/null 2>/dev/null; then
# # mv -v dist/*.whl "${RUNNER_ARTIFACT_DIR}/"
# # fi
# # # Set to fail upload step if there are no files for upload and expected files for upload
# # echo 'if-no-files-found=error' >> "${GITHUB_OUTPUT}"
# # fi

# # upload_docs=0
# # # Check if there are things in the documentation folder to uplaod
# # if find "${RUNNER_DOCS_DIR}" -mindepth 1 -maxdepth 1 | read -r; then
# # # TODO: Add a check here to test if on ec2 because if we're not on ec2 then this
# # # upload will probably not work correctly
# # upload_docs=1
# # fi
# # echo "upload-docs=${upload_docs}" >> "${GITHUB_OUTPUT}"

# - name: Upload artifacts to GitHub (if any)
# uses: actions/upload-artifact@v3
# if: ${{ inputs.upload-artifact != '' }}
# with:
# name: ${{ inputs.upload-artifact }}
# path: ${{ runner.temp }}/artifacts/
# if-no-files-found: ${{ steps.check-artifacts.outputs.if-no-files-found }}

# - name: Upload documentation to S3 (if any)
# uses: seemethere/upload-artifact-s3@v5
# if: ${{ steps.check-artifacts.outputs.upload-docs == 1 && github.event.pull_request.number != '' }}
# with:
# retention-days: 14
# s3-bucket: doc-previews
# if-no-files-found: error
# path: ${{ env.RUNNER_DOCS_DIR }}
# # ${{ env.repository }} is $OWNER/$REPO
# s3-prefix: ${{ env.REPOSITORY }}/${{ github.event.pull_request.number }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
72 changes: 72 additions & 0 deletions .github/workflows/linux-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release Linux wheels and tarball

on:
pull_request:

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

build:
needs: generate-matrix
permissions:
id-token: write
contents: read
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: packaging/post_build_release_script.sh
smoke-test-script: packaging/smoke_test_script.sh
package-name: torch_tensorrt
# env:
# CU_VERSION: ${{ build-matrix.desired_cuda }}
# PYTHON_VERSION: ${{ build-matrix.python_version }}
name: Build torch-tensorrt whl package
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.3
with:
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: release/2.3
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 }}

build-other-release-artifacts:
name: Build other release artifacts
needs: [generate-matrix, build]
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/tensorrt
if: ${{ env.CHANNEL == 'release'}}
uses: pytorch/tensorrt/.github/workflows/linuex-release-artifacts.yml@release/2.3
with:
job-name: build-other-release-artifiacts
repository: "pytorch/tensorrt"
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: ${{ matrix.pre-script }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
Loading

0 comments on commit bc8d6cf

Please sign in to comment.