diff --git a/perception/lidar_centerpoint/CMakeLists.txt b/perception/lidar_centerpoint/CMakeLists.txt index 6831d7a57017b..d7fce8647b7b1 100644 --- a/perception/lidar_centerpoint/CMakeLists.txt +++ b/perception/lidar_centerpoint/CMakeLists.txt @@ -52,23 +52,27 @@ else() set(TRT_AVAIL OFF) endif() -option(TORCH_AVAIL "Torch available" OFF) -if(CUDA_FOUND) - set(Torch_DIR /usr/local/libtorch/share/cmake/Torch) - find_package(Torch) - if(TORCH_FOUND) - if(CUDA_VERBOSE) - message(STATUS "TORCH_INCLUDE_DIRS: ${TORCH_INCLUDE_DIRS}") - message(STATUS "TORCH_LIBRARIES: ${TORCH_LIBRARIES}") - endif() - set(TORCH_AVAIL ON) - else() - message("Torch NOT FOUND") - set(TORCH_AVAIL OFF) +# set flags for CUDNN availability +option(CUDNN_AVAIL "CUDNN available" OFF) +# try to find the CUDNN module +find_library(CUDNN_LIBRARY +NAMES libcudnn.so${__cudnn_ver_suffix} libcudnn${__cudnn_ver_suffix}.dylib ${__cudnn_lib_win_name} +PATHS $ENV{LD_LIBRARY_PATH} ${__libpath_cudart} ${CUDNN_ROOT_DIR} ${PC_CUDNN_LIBRARY_DIRS} ${CMAKE_INSTALL_PREFIX} +PATH_SUFFIXES lib lib64 bin +DOC "CUDNN library." +) +if(CUDNN_LIBRARY) + if(CUDA_VERBOSE) + message(STATUS "CUDNN is available!") + message(STATUS "CUDNN_LIBRARY: ${CUDNN_LIBRARY}") endif() + set(CUDNN_AVAIL ON) +else() + message("CUDNN is NOT Available") + set(CUDNN_AVAIL OFF) endif() -if(TRT_AVAIL AND CUDA_AVAIL AND TORCH_AVAIL) +if(TRT_AVAIL AND CUDA_AVAIL AND CUDNN_AVAIL) # Download trained models find_program(GDOWN_AVAIL "gdown") if(NOT GDOWN_AVAIL) @@ -84,27 +88,29 @@ if(TRT_AVAIL AND CUDA_AVAIL AND TORCH_AVAIL) set(FILE_PATH ${DATA_PATH}/${FILE_NAME}) if(EXISTS ${FILE_PATH}) file(MD5 ${FILE_PATH} EXISTING_FILE_HASH) - if(NOT ${FILE_HASH} EQUAL ${EXISTING_FILE_HASH}) - message(STATUS "... file hash changes. Downloading now ...") - execute_process(COMMAND gdown --quiet https://drive.google.com/uc?id=${GFILE_ID} -O ${FILE_PATH}) + if(${FILE_HASH} EQUAL ${EXISTING_FILE_HASH}) + message(STATUS "File already exists.") + else() + message(STATUS "File hash changes. Downloading now ...") + execute_process(COMMAND gdown --quiet https://drive.google.com//uc?id=${GFILE_ID} -O ${FILE_PATH}) + # file(MD5 ${FILE_PATH} DOWNLOADED_FILE_HASH) # disable to pass ci + message(STATUS "Downloaded file hash: ${DOWNLOADED_FILE_HASH}") endif() else() - message(STATUS "... file doesn't exists. Downloading now ...") - execute_process(COMMAND gdown --quiet https://drive.google.com/uc?id=${GFILE_ID} -O ${FILE_PATH}) + message(STATUS "File doesn't exists. Downloading now ...") + execute_process(COMMAND gdown --quiet https://drive.google.com//uc?id=${GFILE_ID} -O ${FILE_PATH}) + # file(MD5 ${FILE_PATH} DOWNLOADED_FILE_HASH) # disable to pass ci + message(STATUS "Downloaded file hash: ${DOWNLOADED_FILE_HASH}") endif() endfunction() # default model - download(pts_voxel_encoder_default.onnx 1_8OCQmrPm_R4ZVh70QsS9HZo6uGrlbgz 01b860612e497591c4375d90dff61ef7) - download(pts_voxel_encoder_default.pt 1RZ7cuDnI-RBrDiWe-2vEs16mR_z0e9Uo 33136caa97e3bcef2cf3e04bbc93d1e4) - download(pts_backbone_neck_head_default.onnx 1UxDyt8T-TMJS7Ujx-1vbbqGRfDbMUZg2 e23a8ad4ea440f923e44dbe072b070da) - download(pts_backbone_neck_head_default.pt 1toAhmOriX8bwVI-ohuas9_2EBZnltoXh eb0df29b30acf9c1082ac4490af0bbc5) + download(pts_voxel_encoder_default.onnx 1KFhmA4oFT6CtZx5806QeMzn5H2tKa3oD 410f730c537968cb27fbd70c941849a8) + download(pts_backbone_neck_head_default.onnx 1iyk5VoQ4uNBGPZwypVZIMjSuSYAI1RxP e97c165c7877222c0e27e44409a07517) # aip_x2 model - download(pts_voxel_encoder_aip_x2.onnx 1x-NAHQ3W0lbLmjJlrL6Nhvdq8yz6Ux0n 65eeb95c5e48ebfe6894146cdb48c160) - download(pts_voxel_encoder_aip_x2.pt 1jzKopAhXWjnEgo_v8rtYy0hQIayUE-oL 4db81ce8edc6571aa0afb1ae43ee72e9) - download(pts_backbone_neck_head_aip_x2.onnx 1l2fdIQcBWr3-6stVoNkudnL4OZaPqmNT a33c8910fd9c9c910b10904d3cd96717) - download(pts_backbone_neck_head_aip_x2.pt 18iOAlRsjvcWoUG9KiL1PlD7OY5mi9BSw 274fdf1580dd899e36c050c1366f1883) + download(pts_voxel_encoder_aip_x2.onnx 13aYPRHx17Ge4BqxzW9drAUSWTppjtUV5 3ae5e9efd7b2ed12115e6f0b28cac58d) + download(pts_backbone_neck_head_aip_x2.onnx 14PJ_L3Jpz6Yi8GzoctVOEbGWcaCLArGp 6a406a19e05660677c162486ab332de8) find_package(ament_cmake_auto REQUIRED) ament_auto_find_build_dependencies() @@ -112,25 +118,33 @@ if(TRT_AVAIL AND CUDA_AVAIL AND TORCH_AVAIL) include_directories( lib/include ${CUDA_INCLUDE_DIRS} - ${TORCH_INCLUDE_DIRS} ) ### centerpoint ### ament_auto_add_library(centerpoint SHARED + lib/src/centerpoint_trt.cpp lib/src/pointcloud_densification.cpp lib/src/voxel_generator.cpp - lib/src/centerpoint_trt.cpp lib/src/tensorrt_wrapper.cpp lib/src/network_trt.cpp + lib/src/utils.cpp + ) + + cuda_add_library(centerpoint_cuda_libraries SHARED + lib/src/circle_nms_kernel.cu + lib/src/postprocess_kernel.cu + lib/src/preprocess_kernel.cu + lib/src/scatter_kernel.cu ) target_link_libraries(centerpoint ${NVINFER} ${NVONNXPARSER} - ${NVINFER_PLUGIN} ${CUDA_LIBRARIES} ${CUBLAS_LIBRARIES} - ${TORCH_LIBRARIES} + ${CUDA_curand_LIBRARY} + ${CUDNN_LIBRARY} + centerpoint_cuda_libraries ) ## node ## diff --git a/perception/lidar_centerpoint/README.md b/perception/lidar_centerpoint/README.md index 99acf6399d118..193ffa801659a 100644 --- a/perception/lidar_centerpoint/README.md +++ b/perception/lidar_centerpoint/README.md @@ -20,10 +20,9 @@ We trained the models using . ### Output -| Name | Type | Description | -| ---------------------------------- | ----------------------------------------------------- | ------------------------ | -| `~/output/objects` | `autoware_auto_perception_msgs::msg::DetectedObjects` | detected objects | -| `~/debug/pointcloud_densification` | `sensor_msgs::msg::PointCloud2` | densification pointcloud | +| Name | Type | Description | +| ------------------ | ----------------------------------------------------- | ---------------- | +| `~/output/objects` | `autoware_auto_perception_msgs::msg::DetectedObjects` | detected objects | ## Parameters @@ -34,30 +33,16 @@ We trained the models using . | `score_threshold` | float | `0.4` | detected objects with score less than threshold are ignored | | `densification_world_frame_id` | string | `map` | the world frame id to fuse multi-frame pointcloud | | `densification_num_past_frames` | int | `1` | the number of past frames to fuse with the current frame | -| `use_encoder_trt` | bool | `false` | use TensorRT VoxelFeatureEncoder | -| `use_head_trt` | bool | `true` | use TensorRT DetectionHead | | `trt_precision` | string | `fp16` | TensorRT inference precision: `fp32` or `fp16` | | `encoder_onnx_path` | string | `""` | path to VoxelFeatureEncoder ONNX file | | `encoder_engine_path` | string | `""` | path to VoxelFeatureEncoder TensorRT Engine file | -| `encoder_pt_path` | string | `""` | path to VoxelFeatureEncoder TorchScript file | | `head_onnx_path` | string | `""` | path to DetectionHead ONNX file | | `head_engine_path` | string | `""` | path to DetectionHead TensorRT Engine file | -| `head_pt_path` | string | `""` | path to DetectionHead TorchScript file | ## Assumptions / Known limits - The `object.existence_probability` is stored the value of classification confidence of a DNN, not probability. -- If you have an error like `'GOMP_4.5' not found`, replace the OpenMP library in libtorch. - - ```bash - sudo apt install libgomp1 -y - sudo rm /usr/local/libtorch/lib/libgomp-75eea7e8.so.1 - sudo ln -s /usr/lib/x86_64-linux-gnu/libgomp.so.1 /usr/local/libtorch/lib/libgomp-75eea7e8.so.1 - ``` - -- if `use_encoder_trt` is set `use_encoder_trt`, more GPU memory is allocated. - ## (Optional) Error detection and handling