summarylogtreecommitdiffstats
path: root/020-tensorrt-fix-python.patch
blob: b68764f57e9a5d39614f6bc884c2ce0568a81349 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -40,7 +40,7 @@ set(CMAKE_CXX_STANDARD ${CPP_STANDARD})
 
 if (NOT MSVC)
     # This allows us to use TRT libs shipped with standalone wheels.
-    set(CMAKE_SHARED_LINKER_FLAGS -Wl,-rpath=$ORIGIN:$ORIGIN/../${TENSORRT_MODULE}_libs)
+    #set(CMAKE_SHARED_LINKER_FLAGS -Wl,-rpath=$ORIGIN:$ORIGIN/../${TENSORRT_MODULE}_libs)
 endif()
 
 # -------- PATHS --------
@@ -91,7 +91,7 @@ if (MSVC)
     find_path(PY_LIB_DIR ${PYTHON_LIB_NAME}.lib HINTS ${WIN_EXTERNALS}/${PYTHON} ${EXT_PATH}/${PYTHON} PATH_SUFFIXES lib)
     message(STATUS "PY_LIB_DIR: ${PY_LIB_DIR}")
 else()
-    find_path(PY_INCLUDE Python.h HINTS ${EXT_PATH}/${PYTHON} /usr/include/${PYTHON} PATH_SUFFIXES include)
+    find_path(PY_INCLUDE Python.h HINTS /usr/lib PATH_SUFFIXES ${PYTHON})
 endif()
 
 message(STATUS "PY_INCLUDE: ${PY_INCLUDE}")
@@ -111,7 +111,7 @@ message(STATUS "PY_CONFIG_INCLUDE: ${PY_CONFIG_INCLUDE}")
 # -------- GLOBAL COMPILE OPTIONS --------
 
 include_directories(${TENSORRT_ROOT}/include ${PROJECT_SOURCE_DIR}/include ${CUDA_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/docstrings ${ONNX_INC_DIR} ${PYBIND11_DIR})
-link_directories(${TENSORRT_BUILD})
+link_directories(${TENSORRT_BUILD} $ENV{TRT_NONOSS_ROOT}/lib)
 
 if (MSVC)
     message(STATUS "include_dirs: ${MSVC_COMPILER_DIR}/include ${MSVC_COMPILER_DIR}/../ucrt/include ${NV_WDKSDK_INC}/um ${NV_WDKSDK_INC}/shared")
--- a/python/build.sh
+++ b/python/build.sh
@@ -35,15 +35,17 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \
          -DEXT_PATH=${EXT_PATH} \
          -DCUDA_INCLUDE_DIRS=${CUDA_ROOT}/include \
          -DTENSORRT_ROOT=${ROOT_PATH} \
-         -DTENSORRT_MODULE=${TENSORRT_MODULE} \
-         -DTENSORRT_LIBPATH=${TRT_LIBPATH}
-make -j12
+         -DTENSORRT_MODULE=tensorrt \
+         -DTENSORRT_LIBPATH=${TRT_LIBPATH} \
+         -DCMAKE_SKIP_RPATH=YES \
+         -G 'Unix Makefiles'
+cmake --build .
 
 # Generate wheel
-TRT_MAJOR=$(awk '/^\#define NV_TENSORRT_MAJOR/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
-TRT_MINOR=$(awk '/^\#define NV_TENSORRT_MINOR/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
-TRT_PATCH=$(awk '/^\#define NV_TENSORRT_PATCH/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
-TRT_BUILD=$(awk '/^\#define NV_TENSORRT_BUILD/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
+TRT_MAJOR=$(awk '/^#define NV_TENSORRT_MAJOR/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
+TRT_MINOR=$(awk '/^#define NV_TENSORRT_MINOR/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
+TRT_PATCH=$(awk '/^#define NV_TENSORRT_PATCH/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
+TRT_BUILD=$(awk '/^#define NV_TENSORRT_BUILD/ {print $3}' ${ROOT_PATH}/include/NvInferVersion.h)
 TRT_VERSION=${TRT_MAJOR}.${TRT_MINOR}.${TRT_PATCH}.${TRT_BUILD}
 TRT_MAJMINPATCH=${TRT_MAJOR}.${TRT_MINOR}.${TRT_PATCH}
 
@@ -51,10 +53,10 @@ echo "Generating python ${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION} bindings
 
 expand_vars_cp () {
     test -f ${1} || (echo "ERROR: File: ${1} does not exist!" && exit 1); \
-    sed -e "s|\#\#TENSORRT_VERSION\#\#|${TRT_VERSION}|g" \
-        -e "s|\#\#TENSORRT_MAJMINPATCH\#\#|${TRT_MAJMINPATCH}|g" \
-        -e "s|\#\#TENSORRT_PYTHON_VERSION\#\#|${TRT_MAJMINPATCH}|g" \
-        -e "s|\#\#TENSORRT_MODULE\#\#|${TENSORRT_MODULE}|g" \
+    sed -e "s|##TENSORRT_VERSION##|${TRT_VERSION}|g" \
+        -e "s|##TENSORRT_MAJMINPATCH##|${TRT_MAJMINPATCH}|g" \
+        -e "s|##TENSORRT_PYTHON_VERSION##|${TRT_MAJMINPATCH}|g" \
+        -e "s|##TENSORRT_MODULE##|${TENSORRT_MODULE}|g" \
         ${1} > ${2}
 }
 
@@ -66,6 +68,6 @@ popd
 cp tensorrt/tensorrt.so bindings_wheel/tensorrt/tensorrt.so
 
 pushd ${WHEEL_OUTPUT_DIR}/bindings_wheel
-python3 setup.py -q bdist_wheel --python-tag=cp${PYTHON_MAJOR_VERSION}${PYTHON_MINOR_VERSION} --plat-name=linux_${TARGET}
+python -m build --wheel --no-isolation
 
 popd