diff --git a/.github/scripts/install-torch-tensorrt.sh b/.github/scripts/install-torch-tensorrt.sh index 9a6b2a8b8b..4d9c868089 100644 --- a/.github/scripts/install-torch-tensorrt.sh +++ b/.github/scripts/install-torch-tensorrt.sh @@ -1,15 +1,24 @@ -set -eou pipefail +set -euxo pipefail TORCH_TORCHVISION=$(grep "^torch" ${PWD}/py/requirements.txt) INDEX_URL=https://download.pytorch.org/whl/${CHANNEL}/${CU_VERSION} PLATFORM=$(python -c "import sys; print(sys.platform)") +echo "PLATFORM=${PLATFORM}" # Install all the dependencies required for Torch-TensorRT pip install --pre ${TORCH_TORCHVISION} --index-url ${INDEX_URL} pip install --pre -r ${PWD}/tests/py/requirements.txt --use-deprecated legacy-resolver +export CUDA_HOME="$(echo ${CUDA_PATH} | sed -e 's#\\#\/#g')" +export TORCH_INSTALL_PATH="$(python -c "import torch, os; print(os.path.dirname(torch.__file__))" | sed -e 's#\\#\/#g')" + +cat ${PWD}/toolchains/ci_workspaces/MODULE.bazel.tmpl | envsubst > ${PWD}/MODULE.bazel + +cat ${PWD}/MODULE.bazel + # Install Torch-TensorRT if [[ ${PLATFORM} == win32 ]]; then + ls -lart ${RUNNER_ARTIFACT_DIR} pip install ${RUNNER_ARTIFACT_DIR}/torch_tensorrt*.whl else pip install /opt/torch-tensorrt-builds/torch_tensorrt*.whl diff --git a/.github/workflows/build-test-windows.yml b/.github/workflows/build-test-windows.yml index d1cda1b6f4..dbb29fc682 100644 --- a/.github/workflows/build-test-windows.yml +++ b/.github/workflows/build-test-windows.yml @@ -63,37 +63,6 @@ jobs: package-name: ${{ matrix.package-name }} trigger-event: ${{ github.event_name }} - tests-py-torchscript-fe: - name: Test torchscript frontend [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-torchscript-fe - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/modules - python hub.py - popd - pushd . - cd tests/py/ts - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_api_test_results.xml api/ - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_models_test_results.xml models/ - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/ts_integrations_test_results.xml integrations/ - popd - tests-py-dynamo-converters: name: Test dynamo converters [Python] needs: [generate-matrix, build] @@ -119,135 +88,6 @@ jobs: python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dynamo_converters_test_results.xml -n 10 conversion/ popd - tests-py-dynamo-fe: - name: Test dynamo frontend [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-fe - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/dyn_models_export.xml --ir dynamo models/ - popd - - tests-py-dynamo-serde: - name: Test dynamo export serde [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-serde - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/export_serde_test_results.xml --ir dynamo models/test_export_serde.py - popd - - tests-py-torch-compile-be: - name: Test torch compile backend [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-torch-compile-be - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest -n 10 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_be_test_results.xml backend/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_complete_be_e2e_test_results.xml --ir torch_compile models/test_models.py - python -m pytest --junitxml=${RUNNER_TEST_RESULTS_DIR}/torch_compile_dyn_models_export.xml --ir torch_compile models/test_dyn_models.py - popd - - tests-py-dynamo-core: - name: Test dynamo core [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-dynamo-core - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/dynamo - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_runtime_test_results.xml runtime/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_partitioning_test_results.xml partitioning/ - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_dynamo_core_lowering_test_results.xml lowering/ - popd - - tests-py-core: - name: Test core [Python] - needs: [generate-matrix, build] - strategy: - fail-fast: false - matrix: - include: - - repository: pytorch/tensorrt - package-name: torch_tensorrt - uses: ./.github/workflows/windows-test.yml - with: - job-name: tests-py-core - repository: ${{ matrix.repository }} - ref: "" - test-infra-repository: pytorch/test-infra - test-infra-ref: main - build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: packaging/driver_upgrade.bat - script: | - export USE_HOST_DEPS=1 - pushd . - cd tests/py/core - python -m pytest -n 4 --junitxml=${RUNNER_TEST_RESULTS_DIR}/tests_py_core_test_results.xml . - popd - 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 diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 20d83056f6..10187ecee3 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -48,8 +48,8 @@ "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", "https://bcr.bazel.build/modules/rules_java/7.1.0/MODULE.bazel": "30d9135a2b6561c761bd67bd4990da591e6bdc128790ce3e7afd6a3558b2fb64", - "https://bcr.bazel.build/modules/rules_java/7.6.1/MODULE.bazel": "2f14b7e8a1aa2f67ae92bc69d1ec0fa8d9f827c4e17ff5e5f02e91caa3b2d0fe", - "https://bcr.bazel.build/modules/rules_java/7.6.1/source.json": "8f3f3076554e1558e8e468b2232991c510ecbcbed9e6f8c06ac31c93bcf38362", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/MODULE.bazel": "33f6f999e03183f7d088c9be518a63467dfd0be94a11d0055fe2d210f89aa909", "https://bcr.bazel.build/modules/rules_jvm_external/5.1/source.json": "5abb45cc9beb27b77aec6a65a11855ef2b55d95dfdc358e9f312b78ae0ba32d5", @@ -73,8 +73,8 @@ "https://bcr.bazel.build/modules/upb/0.0.0-20230516-61a97ef/source.json": "b2150404947339e8b947c6b16baa39fa75657f4ddec5e37272c7b11c7ab533bc", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", - "https://bcr.bazel.build/modules/zlib/1.3/MODULE.bazel": "6a9c02f19a24dcedb05572b2381446e27c272cd383aed11d41d99da9e3167a72", - "https://bcr.bazel.build/modules/zlib/1.3/source.json": "b6b43d0737af846022636e6e255fd4a96fee0d34f08f3830e6e0bac51465c37c" + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" }, "selectedYankedVersions": {}, "moduleExtensions": { diff --git a/packaging/pre_build_script.sh b/packaging/pre_build_script.sh index 957dcbac4c..59be2533e7 100755 --- a/packaging/pre_build_script.sh +++ b/packaging/pre_build_script.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -x + # Install dependencies python3 -m pip install pyyaml yum install -y ninja-build gettext @@ -11,4 +13,7 @@ export TORCH_BUILD_NUMBER=$(python -c "import torch, urllib.parse as ul; print(u export TORCH_INSTALL_PATH=$(python -c "import torch, os; print(os.path.dirname(torch.__file__))") cat toolchains/ci_workspaces/MODULE.bazel.tmpl | envsubst > MODULE.bazel + +cat MODULE.bazel + export CI_BUILD=1 diff --git a/packaging/pre_build_script_windows.sh b/packaging/pre_build_script_windows.sh index b4c15e3152..e2352e821a 100644 --- a/packaging/pre_build_script_windows.sh +++ b/packaging/pre_build_script_windows.sh @@ -1,4 +1,4 @@ -set -eou pipefail +set -exou pipefail pip install -U numpy packaging pyyaml setuptools wheel @@ -12,7 +12,10 @@ choco install bazelisk -y #unzip -o TensorRT.zip -d C:/ export CUDA_HOME="$(echo ${CUDA_PATH} | sed -e 's#\\#\/#g')" +export TORCH_INSTALL_PATH="$(python -c "import torch, os; print(os.path.dirname(torch.__file__))" | sed -e 's#\\#\/#g')" cat toolchains/ci_workspaces/MODULE.bazel.tmpl | envsubst > MODULE.bazel +cat MODULE.bazel + echo "RELEASE=1" >> ${GITHUB_ENV} diff --git a/py/torch_tensorrt/__init__.py b/py/torch_tensorrt/__init__.py index 442afb0bc0..6eced27816 100644 --- a/py/torch_tensorrt/__init__.py +++ b/py/torch_tensorrt/__init__.py @@ -100,6 +100,7 @@ def _register_with_torch() -> None: ) linked_file_full_path = os.path.join(trtorch_dir, linked_file) linked_file_runtime_full_path = os.path.join(trtorch_dir, linked_file_runtime) + print(f"lan added {linked_file_full_path=}") if os.path.isfile(linked_file_full_path): assert ENABLED_FEATURES.torchscript_frontend diff --git a/setup.py b/setup.py index 06b163c51c..09edaa3d11 100644 --- a/setup.py +++ b/setup.py @@ -218,7 +218,7 @@ def build_libtorchtrt_pre_cxx11_abi( cmd.append("--platforms=//toolchains:ci_rhel_x86_64_linux") print("CI based build") - print("building libtorchtrt") + print(f"lan added building libtorchtrt {cmd=}") status_code = subprocess.run(cmd).returncode if status_code != 0: @@ -250,6 +250,7 @@ def copy_libtorchtrt(multilinux=False, rt_only=False): dir_path + "/../bazel-bin/cpp/lib/torchtrt.dll.if.lib", dir_path + "/torch_tensorrt/lib/torchtrt.lib", ) + print(f"lan added {dir_path=}") elif multilinux: copyfile( dir_path + "/build/libtrtorch_build/libtrtorch.so", diff --git a/toolchains/ci_workspaces/MODULE.bazel.tmpl b/toolchains/ci_workspaces/MODULE.bazel.tmpl index fe2438d098..445bd86110 100644 --- a/toolchains/ci_workspaces/MODULE.bazel.tmpl +++ b/toolchains/ci_workspaces/MODULE.bazel.tmpl @@ -53,27 +53,6 @@ http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "ht # Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs) ############################################################################################################# -http_archive( - name = "libtorch", - build_file = "@//third_party/libtorch:BUILD", - strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/${CHANNEL}/${CU_VERSION}/libtorch-cxx11-abi-shared-with-deps-latest.zip"], -) - -http_archive( - name = "libtorch_pre_cxx11_abi", - build_file = "@//third_party/libtorch:BUILD", - strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/${CHANNEL}/${CU_VERSION}/libtorch-shared-with-deps-latest.zip"], -) - -http_archive( - name = "libtorch_win", - build_file = "@//third_party/libtorch:BUILD", - strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/${CHANNEL}/${CU_VERSION}/libtorch-win-shared-with-deps-latest.zip"], -) - # Download these tarballs manually from the NVIDIA website # Either place them in the distdir directory in third_party and use the --distdir flag # or modify the urls to "file:////.tar.gz @@ -110,17 +89,24 @@ http_archive( # x86_64 python distribution. If using NVIDIA's version just point to the root of the package # for both versions here and do not use --config=pre-cxx11-abi -#new_local_repository( -# name = "libtorch", -# path = "${TORCH_INSTALL_PATH}", -# build_file = "third_party/libtorch/BUILD" -#) +new_local_repository( + name = "libtorch_win", + path = "${TORCH_INSTALL_PATH}", + build_file = "third_party/libtorch/BUILD" +) + +new_local_repository( + name = "libtorch", + path = "${TORCH_INSTALL_PATH}", + build_file = "third_party/libtorch/BUILD" +) + +new_local_repository( + name = "libtorch_pre_cxx11_abi", + path = "${TORCH_INSTALL_PATH}", + build_file = "third_party/libtorch/BUILD" +) -#new_local_repository( -# name = "libtorch_pre_cxx11_abi", -# path = "${TORCH_INSTALL_PATH}", -# build_file = "third_party/libtorch/BUILD" -# #new_local_repository( # name = "tensorrt",