Skip to content

Commit b8ff2d5

Browse files
Fix docker build issue (#3070)
1 parent efd1df0 commit b8ff2d5

File tree

6 files changed

+92
-94
lines changed

6 files changed

+92
-94
lines changed

docker/Dockerfile

+11-3
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ RUN apt-get update &&\
6767

6868
FROM torch-tensorrt-builder-base as torch-tensorrt-builder
6969

70+
RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o envsubst &&\
71+
chmod +x envsubst && mv envsubst /usr/local/bin
72+
7073
COPY . /workspace/torch_tensorrt/src
7174
WORKDIR /workspace/torch_tensorrt/src
72-
RUN cp ./docker/WORKSPACE.docker WORKSPACE
75+
76+
RUN cat ./docker/MODULE.bazel.docker | envsubst > MODULE.bazel
7377

7478
# Symlink the path pyenv is using for python with the /opt directory for package sourcing
7579
RUN mkdir -p "/opt/python3/" &&\
@@ -99,8 +103,12 @@ RUN mkdir -p "/opt/python3/" &&\
99103

100104
COPY --from=torch-tensorrt-builder /workspace/torch_tensorrt/src/dist/ .
101105

102-
RUN cp /opt/torch_tensorrt/docker/WORKSPACE.docker /opt/torch_tensorrt/WORKSPACE &&\
103-
pip install -r /opt/torch_tensorrt/py/requirements.txt &&\
106+
RUN curl -L https://github.com/a8m/envsubst/releases/download/v1.2.0/envsubst-`uname -s`-`uname -m` -o envsubst &&\
107+
chmod +x envsubst && mv envsubst /usr/local/bin
108+
109+
RUN cat ./docker/MODULE.bazel.docker | envsubst > MODULE.bazel
110+
111+
RUN pip install -r /opt/torch_tensorrt/py/requirements.txt &&\
104112
# Install all dependency wheel files and user-specified TensorRT
105113
pip install *.whl &&\
106114
pip install tensorrt==${TENSORRT_VERSION}.* &&\

docker/MODULE.bazel.docker

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
module(
2+
name = "torch_tensorrt",
3+
repo_name = "org_pytorch_tensorrt",
4+
version = "${BUILD_VERSION}"
5+
)
6+
7+
bazel_dep(name = "googletest", version = "1.14.0")
8+
bazel_dep(name = "platforms", version = "0.0.10")
9+
bazel_dep(name = "rules_cc", version = "0.0.9")
10+
bazel_dep(name = "rules_python", version = "0.34.0")
11+
12+
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
13+
python.toolchain(
14+
ignore_root_user_error = True,
15+
python_version = "3.11",
16+
)
17+
18+
bazel_dep(name = "rules_pkg", version = "1.0.1")
19+
git_override(
20+
module_name = "rules_pkg",
21+
commit = "17c57f4",
22+
remote = "https://github.com/narendasan/rules_pkg",
23+
)
24+
25+
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
26+
27+
28+
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
29+
30+
# CUDA should be installed on the system locally
31+
new_local_repository(
32+
name = "cuda",
33+
build_file = "@//third_party/cuda:BUILD",
34+
path = "/usr/local/cuda",
35+
)
36+
37+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
38+
39+
####################################################################################
40+
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
41+
####################################################################################
42+
43+
# NOTE: In the case you are using just the pre-cxx11-abi path or just the cxx11 abi path
44+
# with your local libtorch, just point deps at the same path to satisfy bazel.
45+
46+
# NOTE: NVIDIA's aarch64 PyTorch (python) wheel file uses the CXX11 ABI unlike PyTorch's standard
47+
# x86_64 python distribution. If using NVIDIA's version just point to the root of the package
48+
# for both versions here and do not use --config=pre-cxx11-abi
49+
50+
new_local_repository(
51+
name = "libtorch",
52+
path = "/opt/python3/site-packages/torch/",
53+
build_file = "third_party/libtorch/BUILD"
54+
)
55+
56+
new_local_repository(
57+
name = "libtorch_pre_cxx11_abi",
58+
path = "/opt/python3/site-packages/torch/",
59+
build_file = "third_party/libtorch/BUILD"
60+
)
61+
62+
new_local_repository(
63+
name = "tensorrt",
64+
path = "/usr/",
65+
build_file = "@//third_party/tensorrt/local:BUILD"
66+
)
67+
68+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
69+
70+
pip.parse(
71+
download_only = True,
72+
hub_name = "pypi",
73+
python_version = ${PYTHON_VERSION},
74+
requirements_lock = "//:requirements_dev.txt",
75+
)
76+
77+
use_repo(pip, "pypi")

docker/WORKSPACE.docker

-89
This file was deleted.

docker/dist-build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -x
4+
35
TOP_DIR=$(cd $(dirname $0); pwd)/..
46

57
if [[ -z "${USE_CXX11}" ]]; then

py/requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ packaging
33
pybind11==2.6.2
44
--extra-index-url https://download.pytorch.org/whl/nightly/cu124
55
torch>=2.5.0.dev,<2.6.0
6-
torchvision>=0.19.0.dev,<0.20.0
6+
torchvision>=0.20.0.dev,<0.21.0
77
--extra-index-url https://pypi.ngc.nvidia.com
88
pyyaml
99
tensorrt==10.1.0

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies = [
5252
dynamic = ["version"]
5353

5454
[project.optional-dependencies]
55-
torchvision = ["torchvision >=0.18.dev,<0.19.0"]
55+
torchvision = ["torchvision >=0.20.dev,<0.21.0"]
5656

5757
[project.urls]
5858
Homepage = "https://pytorch.org/tensorrt"

0 commit comments

Comments
 (0)