Skip to content

Commit 38032f7

Browse files
committed
Fix conditional cuda
1 parent acd9b51 commit 38032f7

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if(${PROJECT_NAME}_CUDA_ENABLED)
2222
find_package(CUDAToolkit REQUIRED)
2323
set(${PROJECT_NAME}_CUDA_CATKIN_DEPENDS "CUDAToolkit")
2424
set(${PROJECT_NAME}_CUDA_INCLUDE_DIRS "${CUDAToolkit_INCLUDE_DIRS}")
25-
set(${PROJECT_NAME}_CUDA_TARGET_LINK_LIBRARIES "CUDAToolkit")
25+
set(${PROJECT_NAME}_CUDA_TARGET_LINK_LIBRARIES "CUDA::cudart")
2626
endif()
2727

2828
configure_file(include/${PROJECT_NAME}/config.hpp.in ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME}/config.hpp)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#ifndef YOLO_ONNX_ROS_CONFIG_HPP_
22
#define YOLO_ONNX_ROS_CONFIG_HPP_
33

4-
//Set which version of the Tree Interface to use
5-
#define YOLO_ONNX_ROS_CUDA_ENABLED @onnx_yolo_ros_CUDA_ENABLED@
4+
#define YOLO_ONNX_FALSE 0
5+
#define YOLO_ONNX_TRUE 1
6+
#define YOLO_ONNX_ROS_CUDA_ENABLED YOLO_ONNX_@yolo_onnx_ros_CUDA_ENABLED@
67

78
#endif //#define YOLO_ONNX_ROS_CONFIG_HPP_

include/yolo_onnx_ros/yolo_inference.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <yolo_onnx_ros/config.hpp>
1212

13-
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
13+
#if defined(YOLO_ONNX_ROS_CUDA_ENABLED) && YOLO_ONNX_ROS_CUDA_ENABLED
1414
#include <cuda_fp16.h>
1515
#endif
1616

src/detection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ std::tuple<std::unique_ptr<YOLO_V8>, DL_INIT_PARAM> Initialize()
148148
// Mayve change the model from V11 to V8
149149
params.modelPath = "yolo11m.onnx";
150150
params.imgSize = { 640, 640 };
151-
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
151+
#if defined(YOLO_ONNX_ROS_CUDA_ENABLED) && YOLO_ONNX_ROS_CUDA_ENABLED
152152
params.cudaEnable = true;
153153

154154
// GPU FP32 inference

src/yolo_inference.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#define benchmark
55
#define min(a, b) (((a) < (b)) ? (a) : (b))
66

7-
#ifdef ONNX_YOLO_ROS_CUDA_ENABLED
7+
#if defined(YOLO_ONNX_ROS_CUDA_ENABLED) && YOLO_ONNX_ROS_CUDA_ENABLED
88
namespace Ort
99
{
1010
template<>
@@ -196,7 +196,7 @@ const char* YOLO_V8::RunSession(const cv::Mat& iImg, std::vector<DL_RESULT>& oRe
196196
}
197197
else
198198
{
199-
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
199+
#if defined(YOLO_ONNX_ROS_CUDA_ENABLED) && YOLO_ONNX_ROS_CUDA_ENABLED
200200
half* blob = new half[processedImg.total() * 3];
201201
BlobFromImage(processedImg, blob);
202202
std::vector<int64_t> inputNodeDims = { 1, 3, imgSize_.at(1), imgSize_.at(0) };
@@ -369,7 +369,7 @@ char* YOLO_V8::WarmUpSession() {
369369
}
370370
else
371371
{
372-
#ifdef YOLO_ONNX_ROS_CUDA_ENABLED
372+
#if defined(YOLO_ONNX_ROS_CUDA_ENABLED) && YOLO_ONNX_ROS_CUDA_ENABLED
373373
half* blob = new half[iImg.total() * 3];
374374
BlobFromImage(processedImg, blob);
375375
std::vector<int64_t> YOLO_input_node_dims = { 1, 3, imgSize_.at(1), imgSize_.at(0) };

0 commit comments

Comments
 (0)