Skip to content

fix build with CUDA#5976

Merged
mvieth merged 3 commits intoPointCloudLibrary:masterfrom
daizhirui:master
Mar 9, 2024
Merged

fix build with CUDA#5976
mvieth merged 3 commits intoPointCloudLibrary:masterfrom
daizhirui:master

Conversation

@daizhirui
Copy link
Copy Markdown
Contributor

CUDA_TOOLKIT_INCLUDE is not set when find_package(CUDAToolkit) is called with cmake >= 3.17, which causes error

gpu/utils/include/pcl/gpu/utils/safe_call.hpp:40:10: fatal error: cuda_runtime_api.h: No such file or directory

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 5, 2024

Which library/app are you building - I can't reproduce it and I'm using Cmake 3.28.
But thanks for notifying so quickly 😁

@daizhirui
Copy link
Copy Markdown
Contributor Author

Here is the command I use:

cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_CXX_FLAGS="${CXXFLAGS} -fPIC" \
		-DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS} -Wl,--as-needed" \
		-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS} -Wl,--as-needed" \
		-DCMAKE_CUDA_ARCHITECTURES="52;60;60;62;70;72;75;80;86;86-virtual" \
		-DBUILD_apps=ON \
		-DBUILD_apps_cloud_composer=ON \
		-DBUILD_apps_in_hand_scanner=ON \
		-DBUILD_apps_modeler=ON \
		-DBUILD_apps_point_cloud_editor=ON \
		-DBUILD_examples=ON \
		-DBUILD_global_tests=OFF \
		-DBUILD_surface_on_nurbs=ON \
		-DBUILD_CUDA=ON \
		-DBUILD_cuda_io=ON \
		-DBUILD_cuda_apps=ON \
		-DBUILD_GPU=ON \
		-DBUILD_gpu_kinfu=OFF \
		-DBUILD_gpu_kinfu_large_scale=OFF \
		-DBUILD_gpu_surface=ON \
		-DBUILD_gpu_tracking=ON \
		-DBUILD_simulation=ON \
		-DCMAKE_CUDA_COMPILER=/opt/cuda/bin/nvcc \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/OpenVDB \
		-DWITH_QT=QT6
cmake --build . --target all

The error occurs:

[  3%] Built target pcl_common
[  3%] Building CUDA object cuda/segmentation/CMakeFiles/pcl_cuda_segmentation.dir/src/connected_components.cu.o
[  3%] Building CXX object examples/common/CMakeFiles/pcl_example_scope_time.dir/example_scope_time.cpp.o
[  4%] Building CXX object examples/geometry/CMakeFiles/pcl_example_half_edge_mesh.dir/example_half_edge_mesh.cpp.o
[  4%] Building CXX object stereo/CMakeFiles/pcl_stereo.dir/src/stereo_grabber.cpp.o
[  4%] Building CXX object examples/common/CMakeFiles/pcl_example_organized_point_cloud.dir/example_organized_point_cloud.cpp.o
[  4%] Building CUDA object gpu/containers/CMakeFiles/pcl_gpu_containers.dir/src/device_memory.cpp.o
[  4%] Building CXX object gpu/containers/CMakeFiles/pcl_gpu_containers.dir/src/error.cpp.o
[  4%] Building CUDA object cuda/features/CMakeFiles/pcl_cuda_features.dir/src/normal_3d.cu.o
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/point_xy_32i.cpp.o
[  4%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac.cpp.o
[  4%] Building CXX object sample_consensus/CMakeFiles/pcl_sample_consensus.dir/src/sac_model_circle.cpp.o
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/point_xy_32f.cpp.o
[  4%] Building CXX object examples/common/CMakeFiles/pcl_example_check_if_point_is_valid.dir/example_check_if_point_is_valid.cpp.o
[  4%] Building CXX object io/CMakeFiles/pcl_io_ply.dir/src/ply/ply_parser.cpp.o
[  4%] Building CXX object examples/common/CMakeFiles/pcl_example_copy_point_cloud.dir/example_copy_point_cloud.cpp.o
[  4%] Building CXX object gpu/containers/CMakeFiles/pcl_gpu_containers.dir/src/initialization.cpp.o
[  4%] Building CXX object octree/CMakeFiles/pcl_octree.dir/src/octree_inst.cpp.o
[  4%] Building CXX object kdtree/CMakeFiles/pcl_kdtree.dir/src/kdtree_flann.cpp.o
In file included from /home/daizhirui/.cache/paru/clone/pcl-git/src/pcl/gpu/containers/src/initialization.cpp:38:
/home/daizhirui/.cache/paru/clone/pcl-git/src/pcl/gpu/utils/include/pcl/gpu/utils/safe_call.hpp:40:10: fatal error: cuda_runtime_api.h: No such file or directory
   40 | #include <cuda_runtime_api.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [gpu/containers/CMakeFiles/pcl_gpu_containers.dir/build.make:105: gpu/containers/CMakeFiles/pcl_gpu_containers.dir/src/initialization.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/densecrf.cpp.o
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/pairwise_potential.cpp.o
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/permutohedral.cpp.o
[  4%] Building CXX object ml/CMakeFiles/pcl_ml.dir/src/svm_wrapper.cpp.o
[  4%] Linking CXX executable ../../bin/pcl_example_scope_time

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 5, 2024

It is indeed not set, but builds on the CI's. I wonder if you have a specific cmake, which falls wrongly through the ifs 😄

@daizhirui
Copy link
Copy Markdown
Contributor Author

daizhirui commented Mar 5, 2024

I use cmake 3.28.3 and cuda 12.4
I guess it is due to I am using ArchLinux and cuda is installed in /opt/cuda.

@mvieth
Copy link
Copy Markdown
Member

mvieth commented Mar 6, 2024

Shouldn't this line be added directly after find_package(CUDAToolkit QUIET)? Otherwise it would overwrite the value set by find_package(CUDA 9.0) if CMake < 3.17, no?

Copy link
Copy Markdown
Contributor

@larshg larshg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the line as per @mvieth

@daizhirui
Copy link
Copy Markdown
Contributor Author

Done. Thanks for pointing it out.

mvieth
mvieth previously approved these changes Mar 7, 2024
Copy link
Copy Markdown
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mvieth mvieth added module: cmake changelog: fix Meta-information for changelog generation labels Mar 7, 2024
@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 8, 2024

Not related to this PR per se, only changes to thrust/cuda 12.4:

@daizhirui Can you build octree and surface? Or do you also get errors about thrust::tuple get method?

larshg
larshg previously approved these changes Mar 8, 2024
@daizhirui daizhirui dismissed stale reviews from larshg and mvieth via 670b846 March 8, 2024 10:14
@daizhirui
Copy link
Copy Markdown
Contributor Author

daizhirui commented Mar 8, 2024

My previous build succeeded because it was actually CUDA 12.3. The NVIDIA driver reports CUDA 12.4 but it turned out it was 12.3. I tried another build with CUDA 12.4 and got the same error as yours @larshg.
I already fix it. Now I am sure that it works with CUDA 12.4.

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 8, 2024

My previous build succeeded because it was actually CUDA 12.3. The NVIDIA driver reports CUDA 12.4 but it turned out it was 12.3. I tried another build with CUDA 12.4 and got the same error as yours @larshg. I already fix it. Now I am sure that it works with CUDA 12.4.

Nice, however I think we might need to add some #ifdefs if CUDA 9.0 doesn't support the newer thrust::get API. But lets see what the CI says. Think the oldest we build with is v10.1.243 (ubuntu 20.04)

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 8, 2024

Opened an issue NVIDIA/cccl#1519, as according to documentation it should be possible to use get member functions:
https://nvidia.github.io/cccl/thrust/api/groups/group__tuple.html

@larshg
Copy link
Copy Markdown
Contributor

larshg commented Mar 8, 2024

As per response in the nvidia issue, the documentation had not been updated,so this change is fine.

Copy link
Copy Markdown
Member

@mvieth mvieth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mvieth mvieth merged commit ccc4eee into PointCloudLibrary:master Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: fix Meta-information for changelog generation module: cmake

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants