2

Hello to every linux/ubuntu lover all around,

I'm trying to run my Kinect 2 on my Ubuntu 21.10. The commands that I've issued one by one are the following :

marietto-BHYVE:/home/marietto# nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0


marietto-BHYVE:/home/marietto/Scrivania/libfreenect2# nvidia-smi

| NVIDIA-SMI 470.86       Driver Version: 470.86       CUDA Version: 11.4     

According with this site :

https://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version

For CUDA versions 11.1, 11.2, 11.3, 11.4.0 ----> max supported GCC version = 10

So,I should do :

MAX_GCC_VERSION=10

sudo apt install gcc-$MAX_GCC_VERSION g++-$MAX_GCC_VERSION

g++-10 is already at the most recent version available (10.3.0-11ubuntu1).
gcc-10 is already at the most recent version available (10.3.0-11ubuntu1).

sudo ln -s /usr/bin/gcc-10 /usr/lib/cuda/bin/gcc
sudo ln -s /usr/bin/gcc-$MAX_GCC_VERSION /usr/lib/cuda/bin/gcc 
sudo ln -s /usr/bin/g++-$MAX_GCC_VERSION /usr/lib/cuda/bin/g++

because the cuda version that I've installed requires a gcc version not higher than 10.

Later,according with this guide :

https://www.notaboutmy.life/posts/run-kinect-2-on-ubuntu-20-lts/

I should compile libfreenect2 as follows :

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/home/marietto/Desktop/libfreenect2

unfortunately it seems that it won't accept gcc 10 for compiling libfreenect2 :

marietto-BHYVE:/home/marietto/Scrivania/libfreenect2# make

[  4%] Built target generate_resources_tool
[  7%] Building NVCC (Device) object CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o
In file included from /usr/include/cuda_runtime.h:83,
                 from <command-line>:
/usr/include/crt/host_config.h:139:2: error: #error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
  139 | #error -- unsupported GNU version! gcc versions later than 10 are not supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk.
      |  ^~~~~
/home/marietto/Scrivania/libfreenect2/src/cuda_kde_depth_packet_processor.cu:39:10: fatal error: helper_math.h: File o directory non esistente
   39 | #include <helper_math.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
CMake Error at cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o.RelWithDebInfo.cmake:220 (message):
  Error generating
  /home/marietto/Scrivania/libfreenect2/CMakeFiles/cuda_compile_1.dir/src/./cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o
make[2]: *** [CMakeFiles/freenect2.dir/build.make:103: CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o] Errore 1
make[1]: *** [CMakeFiles/Makefile2:194: CMakeFiles/freenect2.dir/all] Errore 2
make: *** [Makefile:149: all] Errore 2

2 Answers 2

1

I've found the solution by reading the tutorials below :

https://linuxconfig.org/how-to-switch-between-multiple-gcc-and-g-compiler-versions-on-ubuntu-20-04-lts-focal-fossa

and :

How to choose the default gcc and g++ version?

but the error of the missing "helper_math.h" file persists,so I need to start another post.

1
  • helper_math.h is found in the cuda samples. Are they installed on your system?
    – ubfan1
    Jan 18 at 21:56
0

in general I find its best to stick to any of the Ubuntu LTS releases ... 18.04 or 20.04 etc ... as these tend to be better supported by things like nvidia drivers etc

So I am on Ubuntu 20.04 and I installed cuda by doing this

remove all of those symlinks you created to override compiler versions

Software & Updates -> Additional Drivers -> choose Nouveau

cd /var/crash # remove any files here

cd /etc/apt

grep -r cuda * # gives you for example file /etc/apt/sources.list.d/cuda-ubuntu2004-11-6-local.list

now remove any file returned by above command or just comment out all lines inside of said file(s)

reboot

Now install cuda ( it will auto install matching nvidia drivers BUT you must start from using Nouveau )

https://developer.nvidia.com/cuda-downloads Linux -> x86_64 -> Ubuntu -> 20.04 -> deb ( local )

above takes you to link

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_local

above simply shows you below which you then issue yourself

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin

sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda-repo-ubuntu2004-11-6-local_11.6.0-510.39.01-1_amd64.deb


sudo dpkg -i cuda-repo-ubuntu2004-11-6-local_11.6.0-510.39.01-1_amd64.deb


sudo apt-key add /var/cuda-repo-ubuntu2004-11-6-local/7fa2af80.pub


sudo apt-get update


sudo apt-get -y install cuda

reboot

nvidia-smi
Mon Jan 17 13:20:46 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.39.01    Driver Version: 510.39.01    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:02:00.0  On |                  N/A |
|  0%   56C    P0    29W / 190W |   1362MiB /  6144MiB |     25%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1280      G   /usr/lib/xorg/Xorg                101MiB |
|    0   N/A  N/A      1965      G   /usr/lib/xorg/Xorg                656MiB |
|    0   N/A  N/A      2110      G   /usr/bin/gnome-shell               82MiB |
|    0   N/A  N/A      2493      G   ...AAAAAAAAA= --shared-files       19MiB |
|    0   N/A  N/A      4865      G   ...167530988844266480,131072       19MiB |
|    0   N/A  N/A      6981      G   ...axaca/src/firefox/firefox      230MiB |
|    0   N/A  N/A      8585      G   ...AAAAAAAAA= --shared-files       39MiB |
|    0   N/A  N/A     10141      G   ...AAAAAAAAA= --shared-files       68MiB |
|    0   N/A  N/A     10638      G   ...AAAAAAAAA= --shared-files      114MiB |
+-----------------------------------------------------------------------------+

nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Fri_Dec_17_18:16:03_PST_2021
Cuda compilation tools, release 11.6, V11.6.55
Build cuda_11.6.r11.6/compiler.30794723_0

cat proc/driver/nvidia/version

NVRM version: NVIDIA UNIX x86_64 Kernel Module  510.39.01  Fri Dec 31 11:03:22 UTC 2021
GCC version:  gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04) 

Once you do above then your git repo compiles OK as per below

gcc --version

gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ --version

g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

oaxaca@wasayama ~/src/doitt/github.com/OpenKinect/libfreenect2/build $ cmake .. 
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- using tinythread as threading library
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libusb-1.0>=1.0.20'
--   Found libusb-1.0, version 1.0.23
-- Checking for modules 'libva;libva-drm'
--   Found libva, version 1.7.0
--   Found libva-drm, version 1.7.0
-- Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so (found version "80") 
-- Could NOT find TegraJPEG (missing: TegraJPEG_LIBRARIES TegraJPEG_INCLUDE_DIRS TegraJPEG_WORKS) 
-- Performing Test TURBOJPEG_WORKS
-- Performing Test TURBOJPEG_WORKS - Success
-- Found TurboJPEG: /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0  
-- Checking for module 'glfw3'
--   Found glfw3, version 3.3.2
CMake Warning (dev) at /usr/share/cmake-3.16/Modules/FindOpenGL.cmake:275 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/x86_64-linux-gnu/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/x86_64-linux-gnu/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/x86_64-linux-gnu/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:269 (FIND_PACKAGE)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - found
-- Found OpenCL: /usr/lib/x86_64-linux-gnu/libOpenCL.so (found version "2.0") 
-- Performing Test OpenCL_C_WORKS
-- Performing Test OpenCL_C_WORKS - Success
-- Performing Test OpenCL_CXX_WORKS
-- Performing Test OpenCL_CXX_WORKS - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda (found version "11.6") 
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_VISIBILITY - Success
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY
-- Performing Test COMPILER_HAS_HIDDEN_INLINE_VISIBILITY - Success
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR
-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Linking with these libraries: 
 /usr/lib/x86_64-linux-gnu/libusb-1.0.so
 pthread
 va-drm
 va
 /usr/lib/x86_64-linux-gnu/libjpeg.so
 /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0
 /usr/lib/x86_64-linux-gnu/libglfw.so
 /usr/lib/x86_64-linux-gnu/libGL.so
 /usr/lib/x86_64-linux-gnu/libOpenCL.so
 /usr/local/cuda/lib64/libcudart_static.a
 -lpthread
 dl
 /usr/lib/x86_64-linux-gnu/librt.so
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.17") found components: doxygen dot 
-- Configurating examples
-- Using in-tree freenect2 target
-- Checking for module 'libopenni2'
--   Found libopenni2, version 2.2.0.3
-- Found OpenNI2: /usr/lib  
-- Feature list:
--   CUDA    yes
--   CXX11    disabled
--   Examples    yes
--   OpenCL    yes
--   OpenGL    yes
--   OpenNI2    yes
--   TegraJPEG    no
--   Threading    tinythread
--   TurboJPEG    yes
--   VAAPI    yes
--   VideoToolbox    no (Apple only)
--   streamer_recorder    disabled
-- Configuring done
-- Generating done
-- Build files have been written to: /home/oaxaca/src/doitt/github.com/OpenKinect/libfreenect2/build

Where does file helper_math.h live ?

oaxaca@wasayama ~/src/doitt/github.com/OpenKinect/libfreenect2/build $ make -j16
Scanning dependencies of target generate_resources_tool
[  3%] Building CXX object CMakeFiles/generate_resources_tool.dir/tools/generate_resources.cpp.o
[  6%] Linking CXX executable bin/generate_resources_tool
[  6%] Built target generate_resources_tool
[ 15%] Generating resources.inc.h
[ 15%] Building NVCC (Device) object CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o
[ 15%] Building NVCC (Device) object CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_depth_packet_processor.cu.o
/home/oaxaca/src/doitt/github.com/OpenKinect/libfreenect2/src/cuda_depth_packet_processor.cu:31:10: fatal error: helper_math.h: No such file or directory
   31 | #include <helper_math.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
/home/oaxaca/src/doitt/github.com/OpenKinect/libfreenect2/src/cuda_kde_depth_packet_processor.cu:39:10: fatal error: helper_math.h: No such file or directory
   39 | #include <helper_math.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
CMake Error at cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o.RelWithDebInfo.cmake:220 (message):
  Error generating
  /home/oaxaca/src/doitt/github.com/OpenKinect/libfreenect2/build/CMakeFiles/cuda_compile_1.dir/src/./cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o

CMake Error at cuda_compile_1_generated_cuda_depth_packet_processor.cu.o.RelWithDebInfo.cmake:220 (message):
  Error generating
  /home/oaxaca/src/doitt/github.com/OpenKinect/libfreenect2/build/CMakeFiles/cuda_compile_1.dir/src/./cuda_compile_1_generated_cuda_depth_packet_processor.cu.o



make[2]: *** [CMakeFiles/freenect2.dir/build.make:84: CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_kde_depth_packet_processor.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/freenect2.dir/build.make:77: CMakeFiles/cuda_compile_1.dir/src/cuda_compile_1_generated_cuda_depth_packet_processor.cu.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: CMakeFiles/freenect2.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
5
  • thanks but I can't follow your tutorial. You used a lower ubuntu version than mine with a lower nvidia driver and a lower gcc version. It means that I should recreate everything. Not a good idea. I want to keep ubuntu 21.10 as main OS. Maybe I can accept to remove / upgrade the (old) ubuntu drivers and (reinstalling / upgrade) the cuda libraries.
    – Marietto
    Jan 17 at 18:23
  • @Marietto I will try tonight on a different laptop which is using Ubuntu 22.04 Jan 17 at 18:26
  • can u try with ubuntu 21.10 ? it's my version. if u use 22.04,I can't be sure that it works the same when I repeat your steps.
    – Marietto
    Jan 17 at 18:34
  • @Marietto Where does file helper_math.h live ? see above compile error Jan 17 at 18:40
  • I've installed gcc9 and I've used as default : pastebin.ubuntu.com/p/d49QPgG6WY ; still does not work.
    – Marietto
    Jan 17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.