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