-
Install TensorRT using TensorRT official guidance.
Click here for Windows guide
- Download the TensorRT zip file that matches the Windows version you are using.
- Choose where you want to install TensorRT. The zip file will install everything into a subdirectory called
TensorRT-8.x.x.x
. This new subdirectory will be referred to as<installpath>
in the steps below. - Unzip the
TensorRT-8.x.x.x.Windows10.x86_64.cuda-x.x.zip
file to the location that you chose. Where:
8.x.x.x
is your TensorRT versioncuda-x.x
is CUDA version11.6
,11.8
or12.0
- Add the TensorRT library files to your system
PATH
. To do so, copy the DLL files from<installpath>/lib
to your CUDA installation directory, for example,C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y\bin
, wherevX.Y
is your CUDA version. The CUDA installer should have already added the CUDA path to your system PATH.
-
Download and install any recent OpenCV for Windows.
-
Modify TensorRT and OpenCV paths in CMakelists.txt:
# Find and include OpenCV set(OpenCV_DIR "your path to OpenCV") find_package(OpenCV REQUIRED) include_directories(${OpenCV_INCLUDE_DIRS}) # Set TensorRT path if not set in environment variables set(TENSORRT_DIR "your path to TensorRT")
-
Build project by using the following commands or cmake-gui(Windows).
- Windows:
mkdir build cd build cmake .. cmake --build . --config Release
- Linux(not tested):
mkdir build cd build && mkdir out_dir cmake .. make
-
Finally, copy the opencv dll files such as
opencv_world490.dll
andopencv_videoio_ffmpeg490_64.dll
into the<depth_anything_installpath>/build/Release
folder.
- TensorRT 8.6
- CUDA 11.6
- Windows 10