Skip to content

Commit ea6bdf4

Browse files
committed
fix: Refactor Docker Torch version to auto-sync
- Build issue encountered in Docker arising from mismatched versions in WORKSPACE and Docker folder - Update Dockerfile build process to adapt Torch version from `requirements.txt` - Remove references to Torch version in Docker `WORKSPACE` file; instead use local Torch version - Update documentation to provide clear instructions about inclusion of the C++11 ABI build (disabled by default)
1 parent fce0a01 commit ea6bdf4

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

docker/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ RUN ln -s /usr/bin/python3.8 /usr/bin/python
1212
RUN python get-pip.py
1313
RUN pip3 install wheel
1414

15-
# Install Pytorch
16-
RUN pip3 install torch==2.0.0.dev20230103+cu117 torchvision==0.15.0.dev20230103+cu117 --extra-index-url https://download.pytorch.org/whl/nightly/cu117
17-
1815
# Install CUDNN + TensorRT
1916
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
2017
RUN mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
@@ -64,6 +61,7 @@ COPY . /opt/torch_tensorrt
6461
COPY --from=torch-tensorrt-builder /workspace/torch_tensorrt/src/py/dist/ .
6562

6663
RUN cp /opt/torch_tensorrt/docker/WORKSPACE.docker /opt/torch_tensorrt/WORKSPACE
64+
RUN pip install -r /opt/torch_tensorrt/py/requirements.txt
6765
RUN pip3 install *.whl && rm -fr /workspace/torch_tensorrt/py/dist/* *.whl
6866

6967
# Install native tensorrt python package required by torch_tensorrt whl file

docker/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* `Dockerfile` currently uses the exact library versions (Torch, CUDA, CUDNN, TensorRT) listed in <a href="https://github.com/pytorch/TensorRT#dependencies">dependencies</a> to build Torch-TensorRT.
66

77
* This `Dockerfile` installs `pre-cxx11-abi` versions of Pytorch and builds Torch-TRT using `pre-cxx11-abi` libtorch as well.
8-
Note: To install `cxx11_abi` version of Torch-TensorRT, enable `USE_CXX11=1` flag so that `dist-build.sh` can build it accordingly.
8+
9+
Note: Torch-TRT based on the C++11 ABI is not automatically installed in the build. To install it, modify the `WORKSPACE.docker` file to specify a C++11 ABI path, then enable the `USE_CXX11=1` flag so that `dist-build.sh` can build it accordingly. See the `WORKSPACE` file in the root of the repository for an example.
910

1011
### Dependencies
1112

@@ -38,4 +39,4 @@ bazel test //tests/core/conversion/converters:test_activation --compilation_mode
3839

3940
### Pytorch NGC containers
4041

41-
We also ship Torch-TensorRT in <a href="https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch">Pytorch NGC containers </a>. Release notes for these containers can be found <a href="https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/index.html">here</a>. Check out `release/ngc/23.XX` branch of Torch-TensorRT for source code that gets shipped with `23.XX` version of Pytorch NGC container.
42+
We also ship Torch-TensorRT in <a href="https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch">Pytorch NGC containers </a>. Release notes for these containers can be found <a href="https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/index.html">here</a>. Check out `release/ngc/23.XX` branch of Torch-TensorRT for source code that gets shipped with `23.XX` version of Pytorch NGC container.

docker/WORKSPACE.docker

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,16 @@ new_local_repository(
4848
# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs)
4949
#############################################################################################################
5050

51-
http_archive(
51+
new_local_repository(
5252
name = "libtorch",
53-
build_file = "@//third_party/libtorch:BUILD",
54-
sha256 = "59b8b5e1954a86d50b79c13f06398d385b200da13e37a08ecf31d3c62e5ca127",
55-
strip_prefix = "libtorch",
56-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-cxx11-abi-shared-with-deps-2.0.0.dev20230103%2Bcu117.zip"],
53+
path = "/usr/local/lib/python3.8/dist-packages/torch/",
54+
build_file = "third_party/libtorch/BUILD"
5755
)
5856

59-
http_archive(
57+
new_local_repository(
6058
name = "libtorch_pre_cxx11_abi",
61-
build_file = "@//third_party/libtorch:BUILD",
62-
sha256 = "e260fc7476be89d1650953e8643e9f7363845f5a52de4bab87ac0e619c1f6ad4",
63-
strip_prefix = "libtorch",
64-
urls = ["https://download.pytorch.org/libtorch/nightly/cu117/libtorch-shared-with-deps-2.0.0.dev20230103%2Bcu117.zip"],
59+
path = "/usr/local/lib/python3.8/dist-packages/torch/",
60+
build_file = "third_party/libtorch/BUILD"
6561
)
6662

6763
####################################################################################

0 commit comments

Comments
 (0)