Skip to content

Commit

Permalink
Updated trt inference and added configuration scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
olibartfast committed Jan 26, 2025
1 parent 5f19aae commit 1eef47b
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "object-detection-inference",
// Use the image property instead of dockerFile
"image": "object-detection-inference:tensorrt", // Replace with your image name and tag

"features": {
"ghcr.io/devcontainers/features/nvidia-cuda:1": {}
},

"overrideCommand": true,
"runArgs": [
"--gpus", "all"
],
"postCreateCommand": "bash",
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"kaysonwu.cpptask",
"ms-vscode.cpptools-extension-pack",
"franneck94.c-cpp-runner",
"DamianKoper.gdb-debug"
]
}
} // Or your desired entrypoint command

// OR: Run a specific command. Example: run your app with arguments
// "overrideCommand": true,
// "command": ["./object-detection-inference", "-m", "your_model.engine", "-i", "your_input.mp4"]
}

2 changes: 1 addition & 1 deletion cmake/AddCompileDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ elseif (DEFAULT_BACKEND STREQUAL "LIBTORCH")
# Tell the compiler to use glog instead of the default c10 logging system by defining C10_USE_GLOG
add_definitions(-DC10_USE_GLOG)
elseif (DEFAULT_BACKEND STREQUAL "TENSORRT")
set(TRT_VERSION "8.6.1.6" CACHE STRING "Tensorrt version") # modify accordingly
set(TRT_VERSION "10.7.0.23" CACHE STRING "Tensorrt version") # modify accordingly
set(TENSORRT_DIR $ENV{HOME}/TensorRT-${TRT_VERSION}/)
message(STATUS "TENSORRT_DIR: ${TENSORRT_DIR}")
find_package(CUDA REQUIRED)
Expand Down
1 change: 1 addition & 0 deletions detectors/src/DetectorSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ std::unique_ptr<Detector> DetectorSetup::createDetector(const std::string& detec

auto it = detectorCreators.find(detectorType);
if (it != detectorCreators.end()) {
LOG(INFO) << "Creating detector '" << detectorType << "'";
return it->second();
} else {
LOG(ERROR) << "Unknown detector type '" << detectorType << "' requested. Available types are: ";
Expand Down
10 changes: 8 additions & 2 deletions detectors/src/models/Detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ class Detector {
channels_ = static_cast<int>(first_input[0]);
network_height_ = static_cast<size_t>(first_input[1]);
network_width_ = static_cast<size_t>(first_input[2]);
} else {
LOG(ERROR) << "Input shape does not match expected format (CHW)";
LOG(INFO) << "Sizes: " << channels_ << " " << network_width_ << " " << network_height_;
}
else {
LOG(ERROR) << "Input shape does not match expected format (CHW), Found " << first_input.size() << " inputs: ";
for(auto& s : first_input)
LOG(ERROR) << s;
throw std::runtime_error("Input shape does not match expected format ");

}
} else {
LOG(ERROR) << "No input layers found in model";
Expand Down
12 changes: 12 additions & 0 deletions download_trt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
TRT_MAJOR=10
TRT_MINOR=.7
TRT_PATCH=.0
TRT_BUILD=.23
TRT_VERSION=${TRT_MAJOR}${TRT_MINOR}${TRT_PATCH}${TRT_BUILD}
TRT_CUDA_VERSION=12.6
#wget https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/${TRT_MAJOR}${TRT_MINOR}${TRT_PATCH}/tars/TensorRT-${TRT_VERSION}.Linux.x86_64-gnu.cuda-${TRT_CUDA_VERSION}.tar.gz

tar -xvf TensorRT-${TRT_VERSION}.Linux.x86_64-gnu.cuda-${TRT_CUDA_VERSION}.tar.gz

mv TensorRT-${TRT_VERSION} $HOME/TensorRT-${TRT_VERSION}

0 comments on commit 1eef47b

Please sign in to comment.