Skip to content

Commit cbc7e67

Browse files
Merge pull request #21 from NVIDIA-ISAAC-ROS/release-3.2
Isaac ROS 3.2
2 parents e312e5a + 7629f3e commit cbc7e67

File tree

19 files changed

+252
-360
lines changed

19 files changed

+252
-360
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ This package is powered by [NVIDIA Isaac Transport for ROS (NITROS)](https://dev
5555

5656
### Performance
5757

58-
| Sample Graph<br/><br/> | Input Size<br/><br/> | AGX Orin<br/><br/> | Orin NX<br/><br/> | x86_64 w/ RTX 4060 Ti<br/><br/> |
59-
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
60-
| [Depth Segmentation Node](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/benchmarks/isaac_ros_bi3d_benchmark/scripts/isaac_ros_bi3d_node.py)<br/><br/><br/><br/> | 576p<br/><br/><br/><br/> | [45.9 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-agx_orin.json)<br/><br/><br/>76 ms @ 30Hz<br/><br/> | [28.8 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-orin_nx.json)<br/><br/><br/>92 ms @ 30Hz<br/><br/> | [87.9 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-nuc_4060ti.json)<br/><br/><br/>35 ms @ 30Hz<br/><br/> |
58+
| Sample Graph<br/><br/> | Input Size<br/><br/> | AGX Orin<br/><br/> | Orin NX<br/><br/> | x86_64 w/ RTX 4090<br/><br/> |
59+
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
60+
| [Depth Segmentation Node](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/benchmarks/isaac_ros_bi3d_benchmark/scripts/isaac_ros_bi3d_node.py)<br/><br/><br/><br/> | 576p<br/><br/><br/><br/> | [45.8 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-agx_orin.json)<br/><br/><br/>79 ms @ 30Hz<br/><br/> | [28.2 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-orin_nx.json)<br/><br/><br/>99 ms @ 30Hz<br/><br/> | [105 fps](https://github.com/NVIDIA-ISAAC-ROS/isaac_ros_benchmark/blob/main/results/isaac_ros_bi3d_node-x86-4090.json)<br/><br/><br/>25 ms @ 30Hz<br/><br/> |
6161

6262
---
6363

@@ -78,4 +78,4 @@ Please visit the [Isaac ROS Documentation](https://nvidia-isaac-ros.github.io/re
7878

7979
### Latest
8080

81-
Update 2024-09-26: Update for ZED compatibility
81+
Update 2024-12-10: Update to be compatible with JetPack 6.1

gxf_isaac_bi3d/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,10 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
8181
# Install the binary file
8282
install(TARGETS ${PROJECT_NAME} DESTINATION share/${PROJECT_NAME}/gxf/lib)
8383

84+
85+
# Embed versioning information into installed files
86+
ament_index_get_resource(ISAAC_ROS_COMMON_CMAKE_PATH isaac_ros_common_cmake_path isaac_ros_common)
87+
include("${ISAAC_ROS_COMMON_CMAKE_PATH}/isaac_ros_common-version-info.cmake")
88+
generate_version_info(${PROJECT_NAME})
89+
8490
ament_auto_package(INSTALL_TO_SHARE)

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/Errors.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
// Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
15-
//
16-
// SPDX-License-Identifier: Apache-2.0
1+
/*
2+
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
* property and proprietary rights in and to this material, related
6+
* documentation and any modifications thereto. Any use, reproduction,
7+
* disclosure or distribution of this material and related documentation
8+
* without an express license agreement from NVIDIA CORPORATION or
9+
* its affiliates is strictly prohibited.
10+
*
11+
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
12+
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
13+
*/
1714

1815
#pragma once
1916

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/IInferenceBackend.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
// Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
15-
//
16-
// SPDX-License-Identifier: Apache-2.0
1+
/*
2+
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
* property and proprietary rights in and to this material, related
6+
* documentation and any modifications thereto. Any use, reproduction,
7+
* disclosure or distribution of this material and related documentation
8+
* without an express license agreement from NVIDIA CORPORATION or
9+
* its affiliates is strictly prohibited.
10+
*
11+
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
12+
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
13+
*/
1714

1815
#pragma once
1916

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/Inferencer.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
// Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
15-
//
16-
// SPDX-License-Identifier: Apache-2.0
1+
/*
2+
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
* property and proprietary rights in and to this material, related
6+
* documentation and any modifications thereto. Any use, reproduction,
7+
* disclosure or distribution of this material and related documentation
8+
* without an express license agreement from NVIDIA CORPORATION or
9+
* its affiliates is strictly prohibited.
10+
*
11+
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
12+
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
13+
*/
1714

1815
#pragma once
1916

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/TensorRTInferencer.cpp

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ size_t getDataSize(const std::vector<int64_t>& shape, ChannelType dataType) {
4949

5050
std::error_code TensorRTInferencer::getLayerInfo(LayerInfo& layer, std::string layerName) {
5151
layer.name = layerName;
52-
layer.index = m_inferenceEngine->getBindingIndex(layerName.c_str());
53-
auto dim = m_inferenceEngine->getBindingDimensions(layer.index);
54-
nvinfer1::TensorFormat tensorFormat = m_inferenceEngine->getBindingFormat(layer.index);
52+
auto dim = m_inferenceEngine->getTensorShape(layer.name.c_str());
53+
nvinfer1::TensorFormat tensorFormat = m_inferenceEngine->getTensorFormat(layer.name.c_str());
5554

5655
std::error_code err;
5756
err = getCVCoreChannelLayoutFromTensorRT(layer.layout, tensorFormat);
@@ -64,7 +63,7 @@ std::error_code TensorRTInferencer::getLayerInfo(LayerInfo& layer, std::string l
6463
}
6564

6665
err = getCVCoreChannelTypeFromTensorRT(layer.dataType,
67-
m_inferenceEngine->getBindingDataType(layer.index));
66+
m_inferenceEngine->getTensorDataType(layer.name.c_str()));
6867
layer.layerSize = getDataSize(layer.shape, layer.dataType);
6968
if (err != make_error_code(ErrorCode::SUCCESS)) {
7069
return ErrorCode::INVALID_ARGUMENT;
@@ -174,16 +173,15 @@ std::error_code TensorRTInferencer::convertModelToEngine(int32_t dla_core,
174173
}
175174
builderConfig->addOptimizationProfile(optimization_profile);
176175

177-
// Creates TensorRT Engine Plan
178-
std::unique_ptr<nvinfer1::ICudaEngine> engine(
179-
builder->buildEngineWithConfig(*network, *builderConfig));
180-
if (!engine) {
176+
// Creates TensorRT Model stream
177+
std::unique_ptr<nvinfer1::IHostMemory> model_stream(
178+
builder->buildSerializedNetwork(*network, *builderConfig));
179+
if (!model_stream) {
181180
GXF_LOG_ERROR("Failed to build TensorRT engine from model %s.", model_file);
182181
return InferencerErrorCode::INVALID_ARGUMENT;
183182
}
184183

185-
std::unique_ptr<nvinfer1::IHostMemory> model_stream(engine->serialize());
186-
if (!model_stream || model_stream->size() == 0 || model_stream->data() == nullptr) {
184+
if (model_stream->size() == 0 || model_stream->data() == nullptr) {
187185
GXF_LOG_ERROR("Fail to serialize TensorRT Engine.");
188186
return InferencerErrorCode::INVALID_ARGUMENT;
189187
}
@@ -284,13 +282,14 @@ TensorRTInferencer::TensorRTInferencer(const TensorRTInferenceParams& params)
284282
}
285283

286284
m_hasImplicitBatch = m_inferenceEngine->hasImplicitBatchDimension();
287-
m_bindingsCount = m_inferenceEngine->getNbBindings();
285+
m_ioTensorsCount = m_inferenceEngine->getNbIOTensors();
288286
if (!m_hasImplicitBatch) {
289-
for (size_t i = 0; i < m_bindingsCount; i++) {
290-
if (m_inferenceEngine->bindingIsInput(i)) {
291-
nvinfer1::Dims dims_i(m_inferenceEngine->getBindingDimensions(i));
287+
for (size_t i = 0; i < m_ioTensorsCount; i++) {
288+
const char* name = m_inferenceEngine->getIOTensorName(i);
289+
if (m_inferenceEngine->getTensorIOMode(name) == nvinfer1::TensorIOMode::kINPUT) {
290+
nvinfer1::Dims dims_i(m_inferenceEngine->getTensorShape(name));
292291
nvinfer1::Dims4 inputDims{1, dims_i.d[1], dims_i.d[2], dims_i.d[3]};
293-
m_inferenceContext->setBindingDimensions(i, inputDims);
292+
m_inferenceContext->setInputShape(name, inputDims);
294293
}
295294
}
296295
}
@@ -299,7 +298,6 @@ TensorRTInferencer::TensorRTInferencer(const TensorRTInferenceParams& params)
299298
if (err != make_error_code(ErrorCode::SUCCESS)) {
300299
throw err;
301300
}
302-
m_buffers.resize(m_bindingsCount);
303301
}
304302

305303
// Set input layer tensor
@@ -309,7 +307,8 @@ std::error_code TensorRTInferencer::setInput(const TensorBase& trtInputBuffer,
309307
return ErrorCode::INVALID_ARGUMENT;
310308
}
311309
LayerInfo layer = m_modelInfo.inputLayers[inputLayerName];
312-
m_buffers[layer.index] = trtInputBuffer.getData();
310+
m_inferenceContext->setTensorAddress(inputLayerName.c_str(),
311+
trtInputBuffer.getData());
313312
return ErrorCode::SUCCESS;
314313
}
315314

@@ -320,7 +319,8 @@ std::error_code TensorRTInferencer::setOutput(TensorBase& trtOutputBuffer,
320319
return ErrorCode::INVALID_ARGUMENT;
321320
}
322321
LayerInfo layer = m_modelInfo.outputLayers[outputLayerName];
323-
m_buffers[layer.index] = trtOutputBuffer.getData();
322+
m_inferenceContext->setTensorAddress(outputLayerName.c_str(),
323+
trtOutputBuffer.getData());
324324
return ErrorCode::SUCCESS;
325325
}
326326

@@ -334,18 +334,18 @@ ModelMetaData TensorRTInferencer::getModelMetaData() const {
334334
std::error_code TensorRTInferencer::infer(size_t batchSize) {
335335
bool err = true;
336336
if (!m_hasImplicitBatch) {
337-
size_t bindingsCount = m_inferenceEngine->getNbBindings();
338-
for (size_t i = 0; i < bindingsCount; i++) {
339-
if (m_inferenceEngine->bindingIsInput(i)) {
340-
nvinfer1::Dims dims_i(m_inferenceEngine->getBindingDimensions(i));
341-
nvinfer1::Dims4 inputDims{static_cast<int>(batchSize), dims_i.d[1],
342-
dims_i.d[2], dims_i.d[3]};
343-
m_inferenceContext->setBindingDimensions(i, inputDims);
337+
size_t ioTensorsCount = m_inferenceEngine->getNbIOTensors();
338+
for (size_t i = 0; i < ioTensorsCount; i++) {
339+
const char* name = m_inferenceEngine->getIOTensorName(i);
340+
if (m_inferenceEngine->getTensorIOMode(name) == nvinfer1::TensorIOMode::kINPUT) {
341+
nvinfer1::Dims dims_i(m_inferenceEngine->getTensorShape(name));
342+
nvinfer1::Dims4 inputDims{1, dims_i.d[1], dims_i.d[2], dims_i.d[3]};
343+
m_inferenceContext->setInputShape(name, inputDims);
344344
}
345345
}
346-
err = m_inferenceContext->enqueueV2(&m_buffers[0], m_cudaStream, nullptr);
346+
err = m_inferenceContext->enqueueV3(m_cudaStream);
347347
} else {
348-
err = m_inferenceContext->enqueue(m_maxBatchSize, &m_buffers[0], m_cudaStream, nullptr);
348+
return InferencerErrorCode::INVALID_ARGUMENT;
349349
}
350350
if (!err) {
351351
return InferencerErrorCode::TENSORRT_INFERENCE_ERROR;
@@ -360,27 +360,14 @@ std::error_code TensorRTInferencer::setCudaStream(cudaStream_t cudaStream) {
360360
}
361361

362362
std::error_code TensorRTInferencer::unregister(std::string layerName) {
363-
size_t index;
364-
if (m_modelInfo.outputLayers.find(layerName) != m_modelInfo.outputLayers.end()) {
365-
index = m_modelInfo.outputLayers[layerName].index;
366-
} else if (m_modelInfo.inputLayers.find(layerName) != m_modelInfo.inputLayers.end()) {
367-
index = m_modelInfo.inputLayers[layerName].index;
368-
} else {
369-
return ErrorCode::INVALID_ARGUMENT;
370-
}
371-
m_buffers[index] = nullptr;
372363
return ErrorCode::SUCCESS;
373364
}
374365

375366
std::error_code TensorRTInferencer::unregister() {
376-
for (size_t i = 0; i < m_buffers.size(); i++) {
377-
m_buffers[i] = nullptr;
378-
}
379367
return ErrorCode::SUCCESS;
380368
}
381369

382370
TensorRTInferencer::~TensorRTInferencer() {
383-
m_buffers.clear();
384371
}
385372

386373
} // namespace inferencer

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/TensorRTInferencer.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
// Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
15-
//
16-
// SPDX-License-Identifier: Apache-2.0
1+
/*
2+
* Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
* property and proprietary rights in and to this material, related
6+
* documentation and any modifications thereto. Any use, reproduction,
7+
* disclosure or distribution of this material and related documentation
8+
* without an express license agreement from NVIDIA CORPORATION or
9+
* its affiliates is strictly prohibited.
10+
*
11+
* SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES
12+
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
13+
*/
1714

1815
#pragma once
1916

@@ -77,9 +74,8 @@ class TensorRTInferencer : public IInferenceBackendClient {
7774
nvinfer1::ICudaEngine* m_inferenceEngine;
7875
std::unique_ptr<nvinfer1::ICudaEngine> m_ownedInferenceEngine;
7976
std::unique_ptr<nvinfer1::IExecutionContext> m_inferenceContext;
80-
size_t m_bindingsCount;
77+
size_t m_ioTensorsCount;
8178
ModelMetaData m_modelInfo;
82-
std::vector<void*> m_buffers;
8379
bool m_hasImplicitBatch;
8480
std::vector<char> m_modelEngineStream;
8581
size_t m_modelEngineStreamSize = 0;

gxf_isaac_bi3d/gxf/gems/dnn_inferencer/inferencer/TensorRTUtils.h

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
// SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
// Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3-
//
4-
// Licensed under the Apache License, Version 2.0 (the "License");
5-
// you may not use this file except in compliance with the License.
6-
// You may obtain a copy of the License at
7-
//
8-
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
10-
// Unless required by applicable law or agreed to in writing, software
11-
// distributed under the License is distributed on an "AS IS" BASIS,
12-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
// See the License for the specific language governing permissions and
14-
// limitations under the License.
15-
//
16-
// SPDX-License-Identifier: Apache-2.0
1+
/*
2+
* Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
*
4+
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
* property and proprietary rights in and to this material, related
6+
* documentation and any modifications thereto. Any use, reproduction,
7+
* disclosure or distribution of this material and related documentation
8+
* without an express license agreement from NVIDIA CORPORATION or
9+
* its affiliates is strictly prohibited.
10+
*
11+
* SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES
12+
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
13+
*/
1714
#pragma once
1815

1916
#include "NvInferRuntime.h"

0 commit comments

Comments
 (0)