37
37
import sys
38
38
from inspect import getsourcefile
39
39
40
+ import distro
40
41
import requests
41
42
42
43
#
@@ -117,7 +118,17 @@ def fail_if(p, msg):
117
118
def target_platform ():
118
119
if FLAGS .target_platform is not None :
119
120
return FLAGS .target_platform
120
- return platform .system ().lower ()
121
+ platform_string = platform .system ().lower ()
122
+ if platform_string == "linux" :
123
+ # Need to inspect the /etc/os-release file to get
124
+ # the distribution of linux
125
+ id_like_list = distro .like ().split ()
126
+ if "debian" in id_like_list :
127
+ return "linux"
128
+ else :
129
+ return "rhel"
130
+ else :
131
+ return platform_string
121
132
122
133
123
134
def target_machine ():
@@ -649,7 +660,8 @@ def onnxruntime_cmake_args(images, library_paths):
649
660
]
650
661
651
662
# TRITON_ENABLE_GPU is already set for all backends in backend_cmake_args()
652
- if FLAGS .enable_gpu :
663
+ # TODO: TPRD-334 TensorRT extension is not currently supported by our manylinux build
664
+ if FLAGS .enable_gpu and target_platform () != "rhel" :
653
665
cargs .append (
654
666
cmake_backend_enable (
655
667
"onnxruntime" , "TRITON_ENABLE_ONNXRUNTIME_TENSORRT" , True
@@ -680,8 +692,11 @@ def onnxruntime_cmake_args(images, library_paths):
680
692
)
681
693
)
682
694
683
- if (target_machine () != "aarch64" ) and (
684
- TRITON_VERSION_MAP [FLAGS .version ][3 ] is not None
695
+ # TODO: TPRD-333 OpenVino extension is not currently supported by our manylinux build
696
+ if (
697
+ (target_machine () != "aarch64" )
698
+ and (target_platform () != "rhel" )
699
+ and (TRITON_VERSION_MAP [FLAGS .version ][3 ] is not None )
685
700
):
686
701
cargs .append (
687
702
cmake_backend_enable (
@@ -697,7 +712,7 @@ def onnxruntime_cmake_args(images, library_paths):
697
712
)
698
713
)
699
714
700
- if target_platform () == "igpu" :
715
+ if ( target_platform () == "igpu" ) or ( target_platform () == "rhel" ) :
701
716
cargs .append (
702
717
cmake_backend_arg (
703
718
"onnxruntime" ,
@@ -833,8 +848,31 @@ def install_dcgm_libraries(dcgm_version, target_machine):
833
848
)
834
849
return ""
835
850
else :
836
- if target_machine == "aarch64" :
837
- return """
851
+ # RHEL has the same install instructions for both aarch64 and x86
852
+ if target_platform () == "rhel" :
853
+ if target_machine == "aarch64" :
854
+ return """
855
+ ENV DCGM_VERSION {}
856
+ # Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
857
+ RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/sbsa/cuda-rhel8.repo \\
858
+ && dnf clean expire-cache \\
859
+ && dnf install -y datacenter-gpu-manager-{}
860
+ """ .format (
861
+ dcgm_version , dcgm_version
862
+ )
863
+ else :
864
+ return """
865
+ ENV DCGM_VERSION {}
866
+ # Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
867
+ RUN dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo \\
868
+ && dnf clean expire-cache \\
869
+ && dnf install -y datacenter-gpu-manager-{}
870
+ """ .format (
871
+ dcgm_version , dcgm_version
872
+ )
873
+ else :
874
+ if target_machine == "aarch64" :
875
+ return """
838
876
ENV DCGM_VERSION {}
839
877
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
840
878
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -844,10 +882,10 @@ def install_dcgm_libraries(dcgm_version, target_machine):
844
882
&& apt-get update \\
845
883
&& apt-get install -y datacenter-gpu-manager=1:{}
846
884
""" .format (
847
- dcgm_version , dcgm_version
848
- )
849
- else :
850
- return """
885
+ dcgm_version , dcgm_version
886
+ )
887
+ else :
888
+ return """
851
889
ENV DCGM_VERSION {}
852
890
# Install DCGM. Steps from https://developer.nvidia.com/dcgm#Downloads
853
891
RUN curl -o /tmp/cuda-keyring.deb \\
@@ -857,8 +895,106 @@ def install_dcgm_libraries(dcgm_version, target_machine):
857
895
&& apt-get update \\
858
896
&& apt-get install -y datacenter-gpu-manager=1:{}
859
897
""" .format (
860
- dcgm_version , dcgm_version
861
- )
898
+ dcgm_version , dcgm_version
899
+ )
900
+
901
+
902
+ def create_dockerfile_buildbase_rhel (ddir , dockerfile_name , argmap ):
903
+ df = """
904
+ ARG TRITON_VERSION={}
905
+ ARG TRITON_CONTAINER_VERSION={}
906
+ ARG BASE_IMAGE={}
907
+ """ .format (
908
+ argmap ["TRITON_VERSION" ],
909
+ argmap ["TRITON_CONTAINER_VERSION" ],
910
+ argmap ["BASE_IMAGE" ],
911
+ )
912
+
913
+ df += """
914
+ FROM ${BASE_IMAGE}
915
+
916
+ ARG TRITON_VERSION
917
+ ARG TRITON_CONTAINER_VERSION
918
+ """
919
+ df += """
920
+ # Install docker docker buildx
921
+ RUN yum install -y ca-certificates curl gnupg yum-utils \\
922
+ && yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo \\
923
+ && yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
924
+ # && yum install -y docker.io docker-buildx-plugin
925
+
926
+ # libcurl4-openSSL-dev is needed for GCS
927
+ # python3-dev is needed by Torchvision
928
+ # python3-pip and libarchive-dev is needed by python backend
929
+ # libxml2-dev is needed for Azure Storage
930
+ # scons is needed for armnn_tflite backend build dep
931
+ RUN yum install -y \\
932
+ ca-certificates \\
933
+ autoconf \\
934
+ automake \\
935
+ git \\
936
+ gperf \\
937
+ re2-devel \\
938
+ openssl-devel \\
939
+ libtool \\
940
+ libcurl-devel \\
941
+ libb64-devel \\
942
+ gperftools-devel \\
943
+ patchelf \\
944
+ python3.11-devel \\
945
+ python3-pip \\
946
+ python3-setuptools \\
947
+ rapidjson-devel \\
948
+ python3-scons \\
949
+ pkg-config \\
950
+ unzip \\
951
+ wget \\
952
+ zlib-devel \\
953
+ libarchive-devel \\
954
+ libxml2-devel \\
955
+ numactl-devel \\
956
+ wget
957
+
958
+ RUN pip3 install --upgrade pip \\
959
+ && pip3 install --upgrade \\
960
+ wheel \\
961
+ setuptools \\
962
+ docker \\
963
+ virtualenv
964
+
965
+ # Install boost version >= 1.78 for boost::span
966
+ # Current libboost-dev apt packages are < 1.78, so install from tar.gz
967
+ RUN wget -O /tmp/boost.tar.gz \\
968
+ https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz \\
969
+ && (cd /tmp && tar xzf boost.tar.gz) \\
970
+ && mv /tmp/boost_1_80_0/boost /usr/include/boost
971
+
972
+ # Server build requires recent version of CMake (FetchContent required)
973
+ # Might not need this if the installed version of cmake is high enough for our build.
974
+ # RUN apt update -q=2 \\
975
+ # && apt install -y gpg wget \\
976
+ # && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \\
977
+ # && . /etc/os-release \\
978
+ # && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \\
979
+ # && apt-get update -q=2 \\
980
+ # && apt-get install -y --no-install-recommends cmake=3.27.7* cmake-data=3.27.7*
981
+ """
982
+ if FLAGS .enable_gpu :
983
+ df += install_dcgm_libraries (argmap ["DCGM_VERSION" ], target_machine ())
984
+ df += """
985
+ ENV TRITON_SERVER_VERSION ${TRITON_VERSION}
986
+ ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION}
987
+ """
988
+
989
+ df += """
990
+ WORKDIR /workspace
991
+ RUN rm -fr *
992
+ COPY . .
993
+ ENTRYPOINT []
994
+ """
995
+
996
+ with open (os .path .join (ddir , dockerfile_name ), "w" ) as dfile :
997
+ dfile .write (df )
862
998
863
999
864
1000
def create_dockerfile_buildbase (ddir , dockerfile_name , argmap ):
@@ -1161,7 +1297,29 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
1161
1297
fi \\
1162
1298
&& [ `id -u $TRITON_SERVER_USER` -eq 1000 ] \\
1163
1299
&& [ `id -g $TRITON_SERVER_USER` -eq 1000 ]
1300
+ """ .format (
1301
+ gpu_enabled = gpu_enabled
1302
+ )
1164
1303
1304
+ # This
1305
+ if target_platform () == "rhel" :
1306
+ df += """
1307
+ # Common dpeendencies.
1308
+ RUN yum install -y \\
1309
+ git \\
1310
+ gperf \\
1311
+ re2-devel \\
1312
+ openssl-devel \\
1313
+ libtool \\
1314
+ libcurl-devel \\
1315
+ libb64-devel \\
1316
+ gperftools-devel \\
1317
+ patchelf \\
1318
+ wget \\
1319
+ numactl-devel
1320
+ """
1321
+ else :
1322
+ df += """
1165
1323
# Ensure apt-get won't prompt for selecting options
1166
1324
ENV DEBIAN_FRONTEND=noninteractive
1167
1325
@@ -1184,12 +1342,14 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach
1184
1342
wget \\
1185
1343
{backend_dependencies} \\
1186
1344
&& rm -rf /var/lib/apt/lists/*
1345
+ """ .format (
1346
+ backend_dependencies = backend_dependencies
1347
+ )
1187
1348
1349
+ df += """
1188
1350
# Set TCMALLOC_RELEASE_RATE for users setting LD_PRELOAD with tcmalloc
1189
1351
ENV TCMALLOC_RELEASE_RATE 200
1190
- """ .format (
1191
- gpu_enabled = gpu_enabled , backend_dependencies = backend_dependencies
1192
- )
1352
+ """
1193
1353
1194
1354
if "fastertransformer" in backends :
1195
1355
be = "fastertransformer"
@@ -1433,9 +1593,14 @@ def create_build_dockerfiles(
1433
1593
)
1434
1594
dockerfileargmap ["GPU_BASE_IMAGE" ] = gpu_base_image
1435
1595
1436
- create_dockerfile_buildbase (
1437
- FLAGS .build_dir , "Dockerfile.buildbase" , dockerfileargmap
1438
- )
1596
+ if target_platform () == "rhel" :
1597
+ create_dockerfile_buildbase_rhel (
1598
+ FLAGS .build_dir , "Dockerfile.buildbase" , dockerfileargmap
1599
+ )
1600
+ else :
1601
+ create_dockerfile_buildbase (
1602
+ FLAGS .build_dir , "Dockerfile.buildbase" , dockerfileargmap
1603
+ )
1439
1604
1440
1605
if target_platform () == "windows" :
1441
1606
create_dockerfile_windows (
@@ -1651,6 +1816,17 @@ def core_build(
1651
1816
os .path .join (repo_install_dir , "lib" , "tritonserver.lib" ),
1652
1817
os .path .join (install_dir , "bin" ),
1653
1818
)
1819
+ elif target_platform () == "rhel" :
1820
+ cmake_script .mkdir (os .path .join (install_dir , "bin" ))
1821
+ cmake_script .cp (
1822
+ os .path .join (repo_install_dir , "bin" , "tritonserver" ),
1823
+ os .path .join (install_dir , "bin" ),
1824
+ )
1825
+ cmake_script .mkdir (os .path .join (install_dir , "lib64" ))
1826
+ cmake_script .cp (
1827
+ os .path .join (repo_install_dir , "lib64" , "libtritonserver.so" ),
1828
+ os .path .join (install_dir , "lib64" ),
1829
+ )
1654
1830
else :
1655
1831
cmake_script .mkdir (os .path .join (install_dir , "bin" ))
1656
1832
cmake_script .cp (
@@ -2128,7 +2304,7 @@ def enable_all():
2128
2304
"--target-platform" ,
2129
2305
required = False ,
2130
2306
default = None ,
2131
- help = 'Target platform for build, can be "linux", "windows" or "igpu". If not specified, build targets the current platform.' ,
2307
+ help = 'Target platform for build, can be "linux", "rhel", " windows" or "igpu". If not specified, build targets the current platform.' ,
2132
2308
)
2133
2309
parser .add_argument (
2134
2310
"--target-machine" ,
0 commit comments