ElasticFusion 在Ubuntu16.04试运行

本文详细记录了一位用户在Ubuntu16.04系统中配置ElasticFusion的过程,包括CUDA11.2和CUDA8.0的安装、NVIDIA驱动的处理、OpenGL版本问题以及解决编译错误的步骤。用户遇到了CUDA版本不兼容、驱动导致的OpenGL版本限制和编译失败等问题,最终成功运行ElasticFusion。
摘要由CSDN通过智能技术生成

ElasticFusion 在Ubuntu16.04试运行

计算机环境

CPU: Intel® Core™ i9-10980XE CPU @ 3.00GHz × 36
GPU: GeForce RTX 3090 x2

安装Ubuntu16.04

  • 没有网络,调试了一下
    • 用有线网络更新
    • 换清华源

配制环境

安装nv驱动

ubuntu自带的nouveau驱动会影响cuda安装,不当操作会导致黑屏和登陆循环。
终端运行

lsmod | grep nouveau

若有输出,则

cd /etc/modprobe.d
sudo touch blacklist-nouveau.conf
sudo gedit blacklist-nouveau.conf

在打开的文件中输入

blacklist nouveau  
options nouveau modeset=0 

保存退出,然后

sudo update-initramfs -u

一定要重启,再用终端检测一下

lsmod | grep nouveau

没有输出,可以进入下一步

安装驱动

卸载掉原有驱动

sudo apt-get remove --purge nvidia-*

CTRL + ALT + F1进入字符界面,关闭图形界面,一定要这么做,所以在驱动安装完成前,建议把以下几步记下来

sudo service lightdm stop

安装nvidia驱动,注意!第二行不要写–no-x-check –no-nouveau-check –no-opengl-files其他nv驱动安装教程里会有这一句,会导致后面报错。

sudo chmod a+x NVIDIA-Linux-x86_64-460.32.03.run //获取权限
sudo ./NVIDIA-Linux-x86_64-460.32.03.run //安装驱动( 原本有–no-x-check –no-nouveau-check –no-opengl-files )

按Enter键,直到完成。重启,登录,命令行输入

nvidia-smi

在这里插入图片描述

打开设置,看看Graphics显示是否正确。以下界面说明驱动安装完成。不用再进入字符页面了
在这里插入图片描述

安装CUDA11.2(11.2有问题,应该安装CUDA8.0)

(下面是安装CUDA11.2的步骤,后来发现CUDA版本太高了,后按同样步骤重装了CUDA8.0)

进入下载的文件路径

sudo sh cuda_11.2.0_460.27.04_linux.run

出现说明之后,accept,不安装驱动,其余选择是,直至安装完成。

配置环境变量,运行如下命令打开个人资料文件

sudo gedit  /etc/profile

打开文件后在文件末尾添加路径,也就是安装目录,命令如下:

export  PATH=/usr/local/cuda-11.2/bin:$PATH
export  LD_LIBRARY_PATH=/usr/local/cuda-11.2/lib64$LD_LIBRARY_P ATH 

保存,然后重启电脑,进入终端

cd /home/thx/NVIDIA_CUDA-11.2_Samples/1_Utilities/deviceQuery
sudo make
./deviceQuery

如果result = PASS,则安装成功,否则失败,可能原因是环境未配置好,或者是cuda与驱动版本不兼容。

如果需要卸载重装,运行下列命令卸载 cuda

cd /usr/local/cuda/bin
sudo ./cuda-uninstaller

安装依赖:

sudo apt-get install -y cmake-qt-gui git build-essential libusb-1.0-0-dev libudev-dev openjdk-7-jdk freeglut3-dev libglew-dev libsuitesparse-dev libeigen3-dev zlib1g-dev libjpeg-dev

报错:'openjdk-7-jdk’安装失败
原因是16.04源默认不含openjdk7,通过以下指令安装

sudo add-apt-repository ppa:openjdk-r/ppa 
sudo apt-get update 
sudo apt-get install openjdk-7-jdk
  • 之后安装OpenNI2和Pangolin

OpenNI2

安装occipital的fork版本,该版本没有install按钮,直接make就可以

git clone https://github.com/occipital/OpenNI2
cd OpenNI2
sudo make

但后面需要在Pangolin和ElasticFusion的findopenni2.cmake文档中分别加入openni2的path和library路径
/home/thx/OpenNI2/Include
/home/thx/OpenNI2/Bin
放在 “${CMAKE_SOURCE_DIR}/…/…/…/…/…/deps/OpenNI2/Include” 与/user/include之间

Pangolin

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build && cd build
cmake ..
sudo make -j8
sudo make install
sudo ldconfig 	

编译ElasticFusion

首先通过git下载源码,命令如下:

git clone https://github.com/mp3guy/ElasticFusion.git

Core编译

cd ElasticFusion
cd Core
mkdir build && cd build
cmake ../src/
make -j8

编译失败

thx@thx-MS-7B96:~/ElasticFusion/Core/build$ make -j8
[  4%] Building NVCC (Device) object CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_reduce.cu.o
[  9%] Building NVCC (Device) object CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_cudafuncs.cu.o
nvcc fatal   : Unsupported gpu architecture 'compute_30'
CMake Error at cuda_compile_generated_reduce.cu.o.cmake:207 (message):
  Error generating
  /home/thx/ElasticFusion/Core/build/CMakeFiles/cuda_compile.dir/Cuda/./cuda_compile_generated_reduce.cu.o


CMakeFiles/efusion.dir/build.make:70: recipe for target 'CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_reduce.cu.o' failed
make[2]: *** [CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_reduce.cu.o] Error 1
make[2]: *** Waiting for unfinished jobs....
nvcc fatal   : Unsupported gpu architecture 'compute_30'
CMake Error at cuda_compile_generated_cudafuncs.cu.o.cmake:207 (message):
  Error generating
  /home/thx/ElasticFusion/Core/build/CMakeFiles/cuda_compile.dir/Cuda/./cuda_compile_generated_cudafuncs.cu.o


CMakeFiles/efusion.dir/build.make:63: recipe for target 'CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_cudafuncs.cu.o' failed
make[2]: *** [CMakeFiles/cuda_compile.dir/Cuda/cuda_compile_generated_cudafuncs.cu.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/efusion.dir/all' failed
make[1]: *** [CMakeFiles/efusion.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

原因是CUDA11.2不支持较为古老的显卡版本,需要更改Cmake对工程的配置,去掉对compute_30的支持
打开 ~/ElasticFusion/Core/build/CMakeCache.txt
修改CUDA_ARCH_BIN的值为86,因为RTX3090显卡的算力为8.6
(后面发现CUDA_ARCH_PTX要改成61,不然最后运行测试集的时候会报错)
Configure和Generate
在这里插入图片描述重新make -j8
在这里插入图片描述

查了半天资料,官方给出的说明是:

弃用声明:CUDA 9.0中已针对所有设备弃用__shfl,__ shfl_up,__ shfl_down和__shfl_xor

所以我把CUDA11.2卸载了,重装了CUDA8.0
由于CUDA8.0不支持8.9这么高的算力,所以我们又把上面的CUDA_ARCH_BIN值改成50。将build文件清空,重新cmake make,编译成功。
在这里插入图片描述

GPUTest编译

cd ElasticFusion
cd GPUTest
mkdir build && cd build
cmake ../src/
make -j8

GUI编译

cd ../../GUI
mkdir build && cd build
cmake ../src && make -j8

运行datasets

下载数据集http://www.doc.ic.ac.uk/~sleutene/datasets/elasticfusion/dyson_lab.klg
放到ElasticFusion/GUI/build文件夹内

cd ElasticFusion
cd GUI/build
./ElasticFusion -l dyson_lab.klg

不出意外的报错了!!!
我吐了

GLSL Shader compilation failed: /home/thx/ElasticFusion/Core/src/Shaders/copy_unstable.geom:
0:19(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

OpenGL Error 500: GL_INVALID_ENUM: An unacceptable value is specified for an enumerated argument.
In: /usr/local/include/pangolin/gl/gl.hpp, line 205
OpenGL Error 501: GL_INVALID_VALUE: A numeric argument is out of range.
In: /usr/local/include/pangolin/gl/gl.hpp, line 205
Segmentation fault (core dumped)

查看一下OpenGL版本

thx@thx-MS-7B96:~/ElasticFusion/GUI/build$ glxinfo | grep OpenGL
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: llvmpipe (LLVM 6.0, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

不对啊,为啥运行在VMware上呢?不是应该在NVDIA上吗?
它用的是集显,所以OpenGL最高只能到3.0。
所以推测是显卡驱动出了问题
在这里插入图片描述
一看果然。
上网搜了一下,在安装NV驱动时不要加–no-opengl-files
重装驱动吧
after

thx@thx-MS-7B96:~$ glxinfo | grep OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce RTX 3090/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 460.32.03
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6.0 NVIDIA 460.32.03
OpenGL shading language version string: 4.60 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 460.32.03
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

在这里插入图片描述
运行,继续报错

thx@thx-MS-7B96:~/ElasticFusion/GUI/build$ ./ElasticFusion -l dyson_lab.klg
Error: invalid texture reference: /home/thx/ElasticFusion/Core/src/Cuda/convenience.cuh:68

在另一篇博客中找到了答案。这与cuda的编译有关,仔细查看Core/src/cmakelist文件,发现第33行set(CUDA_ARCH_PTX “” CACHE STRING “Specify ‘virtual’ PTX arch to build PTX intermediate code for. Example: 1.0 1.2 or 10 12”)的双引号之间因该缺了什么。于是查了一些资料其中CUDA_ARCH_BIN adds support of only listed GPUs. As alternative CMake scripts also parse ‘CUDA_ARCH_PTX’ variable, which is a list of intermediate PTX codes to include in final so-file. The PTX code can/will be JIT compiled for any current or future GPU.

最终在双引号之间加了61,cuda的cmake参数。
重新编译Core
运行成功

在这里插入图片描述

插摄像头实时渲染

待更新


  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值