Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the libtorch version mismatch issue #3086

Merged
merged 14 commits into from
Aug 16, 2024
7 changes: 6 additions & 1 deletion .github/scripts/install-torch-tensorrt.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set -eou pipefail
set -exou pipefail

TORCH_TORCHVISION=$(grep "^torch" ${PWD}/py/requirements.txt)
INDEX_URL=https://download.pytorch.org/whl/${CHANNEL}/${CU_VERSION}
Expand All @@ -8,6 +8,11 @@ PLATFORM=$(python -c "import sys; print(sys.platform)")
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

lanluo-nvidia marked this conversation as resolved.
Show resolved Hide resolved
# Install Torch-TensorRT
if [[ ${PLATFORM} == win32 ]]; then
pip install ${RUNNER_ARTIFACT_DIR}/torch_tensorrt*.whl
Expand Down
2 changes: 2 additions & 0 deletions packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -exou pipefail

# Install dependencies
python3 -m pip install pyyaml
yum install -y ninja-build gettext
Expand Down
3 changes: 2 additions & 1 deletion packaging/pre_build_script_windows.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set -eou pipefail
set -exou pipefail

pip install -U numpy packaging pyyaml setuptools wheel

Expand All @@ -12,6 +12,7 @@ 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

Expand Down
47 changes: 16 additions & 31 deletions toolchains/ci_workspaces/MODULE.bazel.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz
Expand Down Expand Up @@ -110,17 +89,23 @@ 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_pre_cxx11_abi",
# path = "${TORCH_INSTALL_PATH}",
# build_file = "third_party/libtorch/BUILD"
#
new_local_repository(
lanluo-nvidia marked this conversation as resolved.
Show resolved Hide resolved
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 = "tensorrt",
Expand Down
Loading