Skip to content

Cuda registration #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3b86289
Moved cuda registration to its own files, still looking for a way to …
blackzafiro Mar 2, 2017
7111eec
Will need thrust to create 3D clouds, so -fno-exceptions will be remo…
blackzafiro Apr 4, 2017
a4453bf
Began implementation of CudaRegistration.
Mar 8, 2017
2199537
Added frame for cuda device data. Began implementing apply.
blackzafiro Mar 21, 2017
46fd5ab
Added diretory 'compile' to .gitignore.
blackzafiro Apr 4, 2017
ba92c41
Removed Eclipse auxiliary files
blackzafiro Apr 4, 2017
9133eeb
Merge branch 'OpenKinect:master' into CudaRegistration
blackzafiro Mar 22, 2024
601df00
Fixed spaces vs tab convention
veroarriola Aug 23, 2024
0de07f9
Removed OpenGL warning
veroarriola Aug 23, 2024
e1e73cf
Changing to CUDA as language, not complete.
veroarriola Aug 26, 2024
d279a60
Updated to ENABLE_LANGUAGE(CUDA). Old code is still there but commented.
veroarriola Aug 27, 2024
3d23d10
Fussing as it should have been from the beginning.
veroarriola Sep 4, 2024
4a71a37
Main
veroarriola Sep 6, 2024
8f23ded
Sequence diagram for dev, start.
veroarriola Sep 9, 2024
6bef13a
Sequence diagram with frame production in Protonect complete.
veroarriola Jan 30, 2025
828cfa0
Testing cuda_registration in Protonect. Need to debug.
veroarriola Jan 30, 2025
d634183
Debugging lines...
veroarriola Jan 30, 2025
9e70e6f
Debugging...
veroarriola Jan 31, 2025
29e2b6e
Bug gone. I had dst and src inverted in cudadMemcpyAsync.
veroarriola Feb 5, 2025
53c6156
Set CMKAE_CUDA_ARCHITECTURES
veroarriola Feb 13, 2025
885b9df
CUDA 50 for our laptop.
veroarriola Mar 13, 2025
0ab3569
Arquitectura para 2a laptop
veroarriola Mar 13, 2025
6b78902
RgbPacketProcessor creation
veroarriola Mar 19, 2025
b1a66ec
Build instructions for development.
veroarriola Mar 26, 2025
e93b15e
Corrected error in directories.
veroarriola Mar 26, 2025
4a785b2
Indications to avoid VAAPI
veroarriola Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
build
buildcuda
buildcudadev
compile

# Dependency folders
depends/*/
Expand Down Expand Up @@ -123,6 +126,11 @@ ClientBin/
*.pfx
*.publishsettings

# Nsight Nvidia Eclipse
.cproject
.project
.settings/

# RIA/Silverlight projects
Generated_Code/

Expand Down
60 changes: 45 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#CMAKE_MINIMUM_REQUIRED(VERSION 3.28.3)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1)

SET(PROJECT_VER_MAJOR 0)
Expand Down Expand Up @@ -45,7 +46,6 @@ OPTION(ENABLE_PROFILING "Collect profiling stats (memory consuming)" OFF)
IF(ENABLE_PROFILING)
SET(LIBFREENECT2_WITH_PROFILING 1)
ENDIF()

IF(MSVC)
# suppress several "possible loss of data" warnings, and
# "zero-length array in struct" from libusb.h
Expand Down Expand Up @@ -266,6 +266,7 @@ ENDIF()
SET(HAVE_OpenGL disabled)
IF(ENABLE_OPENGL)
FIND_PACKAGE(GLFW3)
set(OpenGL_GL_PREFERENCE "GLVND")
FIND_PACKAGE(OpenGL)
SET(HAVE_OpenGL no)
IF(GLFW3_FOUND AND OPENGL_FOUND)
Expand All @@ -277,7 +278,8 @@ IF(ENABLE_OPENGL)
LIST(APPEND LIBFREENECT2_DLLS ${GLFW3_DLL})
LIST(APPEND LIBRARIES
${GLFW3_LIBRARIES}
${OPENGL_gl_LIBRARY}
${OPENGL_GL_LIBRARY}
${OPENGL_LIBRARIES}
)
LIST(APPEND SOURCES
src/flextGL.cpp
Expand Down Expand Up @@ -337,53 +339,81 @@ IF(ENABLE_OPENCL)
ENDIF(OpenCL_FOUND)
ENDIF(ENABLE_OPENCL)


SET(HAVE_CUDA disabled)
IF(ENABLE_CUDA)
FIND_PACKAGE(CUDA)
INCLUDE(CheckLanguage)
CHECK_LANGUAGE(CUDA)
# FIND_PACKAGE(CUDA)
SET(HAVE_CUDA no)
IF(CUDA_FOUND AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
#IF(CUDA_FOUND AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
IF(CMAKE_CUDA_COMPILER AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
SET(HAVE_CUDA "no (VS2015 not supported)")
ELSEIF(CUDA_FOUND)
#ELSEIF(CUDA_FOUND)
ELSEIF(CMAKE_CUDA_COMPILER)
SET(LIBFREENECT2_WITH_CUDA_SUPPORT 1)
SET(HAVE_CUDA yes)
ENABLE_LANGUAGE(CUDA)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 50 52 75 89)
endif()

#FIND_PACKAGE(CUDAToolkit)
STRING(REPLACE "\\" "/" NVCUDASAMPLES_ROOT "$ENV{NVCUDASAMPLES_ROOT}")
STRING(REPLACE "\\" "/" NVCUDASAMPLES8_0_ROOT "$ENV{NVCUDASAMPLES8_0_ROOT}")
CUDA_INCLUDE_DIRECTORIES(
#CUDA_INCLUDE_DIRECTORIES(
INCLUDE_DIRECTORIES(
"${MY_DIR}/include/"
"${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc"
"${NVCUDASAMPLES_ROOT}/common/inc"
"${NVCUDASAMPLES8_0_ROOT}/common/inc"
)
SET(CUDA_FLAGS -use_fast_math)
IF(NOT MSVC)
SET(CUDA_FLAGS "${CUDA_FLAGS} -Xcompiler -fPIC")
SET(CUDA_FLAGS "${CUDA_FLAGS} -Xcompiler -fPIC -D_FORCE_INLINES")
ENDIF()
IF(HAVE_CXX11 STREQUAL yes AND CUDA_VERSION VERSION_GREATER 7.0)
SET(CUDA_FLAGS "${CUDA_FLAGS} -std=c++11")
ENDIF()

SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REGEX REPLACE "-std=c\\+\\+.." "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
CUDA_COMPILE(CUDA_OBJECTS
# Thrust requires exceptions. If OpenCL from NVidia is used we don't need this flag.
STRING(REGEX REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "*************")
MESSAGE(STATUS ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS ${CUDA_FLAGS})
MESSAGE(STATUS ${CUDA_INCLUDE_DIRS})
MESSAGE(STATUS ${CUDA_LIBRARIES})
MESSAGE(STATUS ${CUDA_OBJECTS})
MESSAGE(STATUS "*************")
#CUDA_COMPILE(CUDA_OBJECTS
LIST(APPEND SOURCES
#include/libfreenect2/cuda_registration.h
src/cuda_depth_packet_processor.cu
src/cuda_kde_depth_packet_processor.cu
OPTIONS ${CUDA_FLAGS}
src/cuda_registration.cu
#OPTIONS ${CUDA_FLAGS}
)
SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")

INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

LIST(APPEND SOURCES
${CUDA_OBJECTS}
)
#LIST(APPEND SOURCES
# ${CUDA_OBJECTS}
#)

LIST(APPEND LIBRARIES
${CUDA_LIBRARIES}
)
#LIST(APPEND LIBRARIES
# ${CUDA_LIBRARIES}
#)
#set_target_properties(freenect2 PROPERTIES CUDA_ARCHITECTURES "35;50;75")
#SET_PROPERTY(TARGET freenect2 PROPERTY CUDA_ARCHITECTURES OFF)
ENDIF()
#ENDIF(CMAKE_CUDA_COMPILER)
ENDIF(ENABLE_CUDA)



# RPATH handling for CUDA 8.0 libOpenCL.so conflict. See #804.
IF(HAVE_OpenCL STREQUAL yes AND UNIX AND NOT APPLE)
FILE(GLOB CUDA_ld_so_conf /etc/ld.so.conf.d/cuda*.conf)
Expand Down
47 changes: 47 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Compile and execute development version

## With CUDA
* Edit ```CMakeLists.txt``` to assign ```CMAKE_CUDA_ARCHITECTURES``` in accordance with NVidia card.

```
cd
mkdir Programs && cd Programs
git clone https://github.com/NVIDIA/cuda-samples.git
export CUDA_SAMPLES_HOME=$HOME/Programs/cuda-samples

git clone https://github.com/blackzafiro/libfreenect2.git
cd ~/Programs/libfreenect2
mkdir buildcudadev && cd buildcudadev
cmake .. -DCMAKE_CUDA_FLAGS=-I\ $CUDA_SAMPLES_HOME/Common -DCMAKE_INSTALL_PREFIX=$HOME/freenect2cudadev
```

Para la Lenovo ideapad Y700 hay que apagar VAAPI:
```
cmake .. -DENABLE_VAAPPI=OFF -DCMAKE_CUDA_FLAGS=-I\ $CUDA_SAMPLES_HOME/Common -DCMAKE_INSTALL_PREFIX=$HOME/freenect2cudadev
```

To find the libraries:

```
export FREENECT_INSTALL_DIR=$HOME/freenect2cudadev
export FREENECT_COMPILE_DIR=$HOME/Programs/libfreenect2/buildcudadev
export LD_LIBRARY_PATH=$FREENECT_INSTALL_DIR/lib:$LD_LIBRARY_PATH
export PATH=$FREENECT_COMPILE_DIR/bin:$PATH
```

Test cuda buffer access with:

```
Protonect cudaccess
```


## Permissions for Kinect

```
sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
```

Replug Kinect after copying file.


Loading