Instant-ngp linux
ubuntu 20.04
GPU RTX3050Ti
Instant-ngp官方文档地址
https://github.com/NVlabs/instant-ngp
参考链接
Instant-ngp linux部署及使用 - 简书
Ubuntu20.04复现instant-ngp,自建数据集,导出mesh_XINYU W的博客-CSDN博客
步骤
安装基本依赖
sudo apt-get install build-essential git python3-dev python3-pip libopenexr-dev libxi-dev \
libglfw3-dev libglew-dev libomp-dev libxinerama-dev libxcursor-dev
安装CUDA
官网给的是NVIDIA+CUDA,但我个人推荐现在自己电脑装对应的显卡驱动
首先进入
CUDA Toolkit - Free Tools and Training | NVIDIA Developer
download now
Linux
x86_64
ubuntu
20.04
runfile(local)
可以参考
Ubuntu 20.04安装CUDA 11.4, cuDNN 8.24 - 知乎
ubuntu将cuda卸载干净_ubuntu卸载cuda-CSDN博客
也可以参考下面
可以看到
wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
sudo sh cuda_12.2.2_535.104.05_linux.run
这是可以看到535,那我们就在自己电脑的软件和更新里面选择(记得先sudo apt update,sudo apt upgrade),选择NVIDIA driver metapackage 来自****535(专有)
点击应用更改,需要等待一定时间,完成后重启。
重启后打开终端下载(4.3G左右,大概8分钟)
wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
下载后
安装前可以选择为gcc降级
sudo apt-get install gcc-7 g++-7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 1
sudo update-alternatives --display gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 9
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 1
sudo update-alternatives --display g++
安装驱动
sudo sh cuda_12.2.2_535.104.05_linux.run
选“continue”
取消Driver的选取(X是选中的意思,因为之前已经安装过驱动)
然后Install
完成后屏幕输出
Driver: Installed
Toolkit: Installed in /usr/local/cuda-10.1/
Samples: Installed in /home/abneryepku/
Please make sure that
- PATH includes /usr/local/cuda-10.1/
- LD_LIBRARY_PATH includes /usr/local/cuda-10.1/lib64, or, add /usr/local/cuda-10.1/lib64 to /etc/ld.so.conf and run ldconfig as root
这里我的是12.2,上面是放别人的所以是10.1,注意自己的版本
~/.bashrc 文件中写入(10.1为自己对应的版本)
sudo gedit ~/.bashrc
# add nvcc compiler to path
export PATH=$PATH:/usr/local/cuda-10.1/bin
# add cuBLAS, cuSPARSE, cuRAND, cuSOLVER, cuFFT to path
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64:/usr/lib/x86_64-linux-gnu
然后
source ~/.bashrc
检查CUDA是否安装成功
终端输入nvcc -V,若有输出,则安装成功
至此,cuda和驱动安装成功
安装cmake
cmake安装包:链接: https://pan.baidu.com/s/1Dv99ODmhjzizkz5clEKI2g?pwd=zims 提取码: zims
1.从官网下载cmake安装包,输入指令解压缩
sudo tar -zxvf cmake-3.24.0-rc1.tar.gz
2.进入解压缩后的文件夹中执行
sudo ./bootstrap
sudo make
sudo make install
安装OptiX
OptiX安装脚本:链接: https://pan.baidu.com/s/1Dv99ODmhjzizkz5clEKI2g?pwd=zims 提取码: zims
下载Optix安装脚本到 /usr/local 目录(执行下面命令是会提示你是否安装在/usr/local )
bash NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64.sh
执行完安装脚本后,会在/usr/local下生成 NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64/ 目录
即
cd /usr/local
ll
可以看到NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64/
设置OptiX_INSTALL_DIR为环境变量,在 ~/.bashrc 文件最后添加以下内容
export OptiX_INSTALL_DIR="/usr/local/NVIDIA-OptiX-SDK-7.5.0-linux64-x86_64"
安装COLMAP
1.安装依赖包
sudo apt-get install \
git \
build-essential \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libboost-test-dev \
libeigen3-dev \
libsuitesparse-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgflags-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libcgal-qt5-dev
2.安装ceres-solver
ceres环境配置
下载地址:
git clone https://github.com/ceres-solver/ceres-solver
安装附加库前需要安装依赖项,依赖项会报错。解决:
//第一步,打开sources.list
sudo gedit /etc/apt/sources.list
//第二步,将下面的源粘贴到最上方sources.list
deb http://cz.archive.ubuntu.com/ubuntu trusty main universe
//第三步,更新源(看网速)
sudo apt-get update
//第四步,重新输入依赖项安装命令安装依赖项
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libgtest-dev
#进入到解压后的压缩文件夹中,进行编译:(预计10分钟)
mkdir build
cd build
cmake ..
make -j4
#然后执行:
sudo make install
sudo ldconfig
#验证是否安装成功:
/usr/local/include/ceres有ceres的头文件,/usr/local/lib/下能找到名为libceres.a的库文件
以上是ceres的配置
3.安装colmap
git clone https://github.com/colmap/colmap
cd colmap
git checkout dev
mkdir build
cd build
cmake ..
这一步可能会报You must set CMAKE_CUDA_ARCHITECTURES to e.g. 'native', 'all-major', '70', etc. "的错,在错的文件的位置加上下面这行即可
set(CMAKE_CUDA_ARCHITECTURES "native")
如果在完成上面添加重新cmake .. 报了gpu的另一个错则换成下面这个
set(CMAKE_CUDA_ARCHITECTURES "all-major")
rm -rf *
cmake ..
make -j12
sudo make install
4.验证colmap
colmap -h
# 有GUI的可执行以下命令
colmap gui
部署instant-ngp
1.clone项目代码到项目目录
git clone --recursive https://github.com/nvlabs/instant-ngp
cd instant-ngp
2.使用cmake构建项目
cmake . -B build
cmake --build build --config RelWithDebInfo -j 16
3.使用测试数据测试
./instant-ngp ./data/nerf/fox
./instant-ngp data/sdf/armadillo.obj
./instant-ngp data/image/albert.exr
2023.10.12