diff --git a/README.md b/README.md index 3e74a79688..a386cef4a5 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,12 @@ To build wheel files for different python versions, first build the Dockerfile i command ``` -docker run -it -v$(pwd)/..:/workspace/Torch-TensorRT build_torch_tensorrt_wheel /bin/bash /workspace/Torch-TensorRT/py/build_whl.sh +# build the build_torch_tensorrt_wheel docker image +docker build --no-cache -t build_torch_tensorrt_wheel -f py/ci/Dockerfile.ci . + +# build the wheel files for different python versions +docker run -it -v$(pwd):/workspace/TensorRT build_torch_tensorrt_wheel /bin/bash /workspace/TensorRT/py/ci/build_whl.sh + ``` Python compilation expects using the tarball based compilation strategy from above. diff --git a/py/ci/Dockerfile.ci b/py/ci/Dockerfile.ci index 96f2b90200..28aed1c670 100644 --- a/py/ci/Dockerfile.ci +++ b/py/ci/Dockerfile.ci @@ -1,9 +1,15 @@ FROM pytorch/manylinux-builder:cuda12.1 -ARG trt_version -RUN echo -e "Installing with TensorRT ${trt_version}" +RUN yum install -y ninja-build -RUN yum install -y ninja-build tensorrt-${trt_version}.* +# download TensorRT tarball +RUN 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 + +ENV TENSORRT_DIR=/TensorRT-10.0.1.6 +ENV TENSORRT_VERSION=10.0.1 RUN wget https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 \ && mv bazelisk-linux-amd64 /usr/bin/bazel \ diff --git a/py/ci/build_whl.sh b/py/ci/build_whl.sh index 35090445f0..2303efb83a 100755 --- a/py/ci/build_whl.sh +++ b/py/ci/build_whl.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Example usage: docker run -it -v$(pwd)/..:/workspace/TRTorch build_trtorch_wheel /bin/bash /workspace/TRTorch/py/build_whl.sh +# Example usage: docker run -it -v$(pwd):/workspace/TensorRT build_torch_tensorrt_wheel /bin/bash /workspace/TensorRT/py/ci/build_whl.sh export CXX=g++ export CUDA_HOME=/usr/local/cuda-12.1 -export PROJECT_DIR=/workspace/project +export PROJECT_DIR=/workspace/TensorRT rm -rf /usr/local/cuda @@ -19,6 +19,8 @@ fi build_wheel() { $1/bin/python -m pip install --upgrade pip setuptools + $1/bin/python -m pip install ${TENSORRT_DIR}/python/tensorrt-${TENSORRT_VERSION}-${2}-none-linux_x86_64.whl + $1/bin/python -m pip install -r py/requirements.txt #$1/bin/python -m pip wheel . -w dist export BUILD_VERSION=$(cd ${PROJECT_DIR} && $1/bin/python3 -c "import versions; versions.torch_tensorrt_version_release()") @@ -27,22 +29,23 @@ build_wheel() { patch_wheel() { $2/bin/python -m pip install auditwheel - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$1/torch/lib:$1/tensorrt/:${CUDA_HOME}/lib64:${CUDA_HOME}/lib64/stubs $2/bin/python -m auditwheel repair $(cat ${PROJECT_DIR}/py/ci/soname_excludes.params) --plat manylinux_2_34_x86_64 dist/torch_tensorrt-*-$3-linux_x86_64.whl + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${TENSERRT_DIR}/lib:$1/torch/lib:$1/tensorrt/:${CUDA_HOME}/lib64:${CUDA_HOME}/lib64/stubs $2/bin/python -m auditwheel repair $(cat ${PROJECT_DIR}/py/ci/soname_excludes.params) --plat manylinux_2_34_x86_64 dist/torch_tensorrt-*-$3-linux_x86_64.whl } py38() { - cd /workspace/project + cd ${PROJECT_DIR} PY_BUILD_CODE=cp38-cp38 + PY_SINGLE_BUILD_CODE=cp38 PY_VERSION=3.8 PY_NAME=python${PY_VERSION} PY_DIR=/opt/python/${PY_BUILD_CODE} PY_PKG_DIR=${PY_DIR}/lib/${PY_NAME}/site-packages/ - build_wheel ${PY_DIR} + build_wheel ${PY_DIR} ${PY_SINGLE_BUILD_CODE} patch_wheel ${PY_PKG_DIR} ${PY_DIR} ${PY_BUILD_CODE} } py39() { - cd /workspace/project + cd ${PROJECT_DIR} PY_BUILD_CODE=cp39-cp39 PY_VERSION=3.9 PY_NAME=python${PY_VERSION} @@ -53,7 +56,7 @@ py39() { } py310() { - cd /workspace/project + cd ${PROJECT_DIR} PY_BUILD_CODE=cp310-cp310 PY_VERSION=3.10 PY_NAME=python${PY_VERSION} @@ -64,7 +67,7 @@ py310() { } py311() { - cd /workspace/project + cd ${PROJECT_DIR} PY_BUILD_CODE=cp311-cp311 PY_VERSION=3.11 PY_NAME=python${PY_VERSION} @@ -75,7 +78,7 @@ py311() { } py312() { - cd /workspace/project + cd ${PROJECT_DIR} PY_BUILD_CODE=cp312-cp312 PY_VERSION=3.12 PY_NAME=python${PY_VERSION} @@ -86,8 +89,8 @@ py312() { } libtorchtrt() { - cd /workspace/project - mkdir -p /workspace/project/py/wheelhouse + cd ${PROJECT_DIR} + mkdir -p ${PROJECT_DIR}/py/wheelhouse PY_BUILD_CODE=cp310-cp310 PY_VERSION=3.10 PY_NAME=python${PY_VERSION} @@ -105,8 +108,8 @@ libtorchtrt() { } libtorchtrt_pre_cxx11_abi() { - cd /workspace/project/py - mkdir -p /workspace/project/py/wheelhouse + cd ${PROJECT_DIR}/py + mkdir -p ${PROJECT_DIR}/py/wheelhouse PY_BUILD_CODE=cp310-cp310 PY_VERSION=3.10 PY_NAME=python${PY_VERSION} diff --git a/py/ci/soname_excludes.params b/py/ci/soname_excludes.params index 53f7f48a65..8cc61d0e20 100644 --- a/py/ci/soname_excludes.params +++ b/py/ci/soname_excludes.params @@ -35,4 +35,10 @@ --exclude libcublas.so.12.1.3.1 --exclude libcublasLt.so.12.1.3.1 --exclude libcudart.so.11.8.89 ---exclude libcudart.so.11 \ No newline at end of file +--exclude libcudart.so.11 +--exclude libcudart.so.12 +--exclude libnvinfer.so.10 +--exclude libnvinfer_plugin.so.10 +--exclude libnvinfer-ea523553.so.10.0.1 +--exclude libcudart-9335f6a2.so.12.1.105 +--exclude libnvinfer_plugin-24528888.so.10.0.1 \ No newline at end of file