NeRF

编程入门 行业动态 更新时间:2024-10-12 01:28:26

<a href=https://www.elefans.com/category/jswz/34/1730111.html style=NeRF"/>

NeRF

记录在部署运行期间遇到的一些问题,分享给大家~

一、环境

RTX 3060 Ti、8G显存、Ubuntu18.04

二、部署

1. 下载代码
git clone .git --recurse-submodules
git submodule update --init --recursive
cd thirdparty/instant-ngp/ && git checkout feature/nerf_slam

这里clone的不是原作者的code,而是jrpowers的​ code,12 commits ahead, 2 commits behind ToniRV:master ​,因为官方给的代码在安装部署过程中遇到了不少问题,所以先跳过,给大家介绍成功的流程,下文会介绍部分官方代码在部署过程中遇到的问题及对应的解决方法。

2. 安装CUDA 11.7 和PyTorch

这里我用的是anaconda,如何使用conda请参照ubuntu下anaconda的安装、配置与使用_ubuntu怎么使用anaconda_zllz0907的博客-CSDN博客,


conda create -n nerf python=3.9
conda install -c "nvidia/label/cuda-11.7.0" cuda-toolkit
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url 
官方安装的是CUDA 11.3和torch 1.12.1,后来试了也是没问题的。
3. 安装requirements
pip install -r requirements.txt
pip install -r ./thirdparty/gtsam/python/requirements.txt
4. 编译ngp(确保cmake版本>3.22)
cmake ./thirdparty/instant-ngp -B build_ngp
cmake --build build_ngp --config RelWithDebInfo -j
5. 编译gtsam

官方代码在编译gtsam时大概率会遇到问题

cmake ./thirdparty/gtsam -DGTSAM_BUILD_PYTHON=1 -B build_gtsam 
cmake --build build_gtsam --config RelWithDebInfo -j
cd build_gtsam
make python-install

如果设备性能有限,或者编译时遇到cplusplus internal相关的问题,将上述第二行编译指令后的-j改为-j8或者更小的-j6,降低在编译时的并行数量。

6. 安装
python setup.py install

三、运行

1. 下载数据集
./scripts/download_replica_sample.bash
2. 运行
python ./examples/slam_demo.py --dataset_dir=./datasets/Replica/office0 --dataset_name=nerf --buffer=100 --slam --parallel_run --img_stride=2 --fusion='nerf' --multi_gpu --gui

注意download_replica_sample.bash中的数据下载地址是Datasets,而运行地址是小写字母datasets,需改成一致。

如果运行时出现检测不到CUDA设备或者无gui画面时,错误如下:

RuntimeError: Could not allocate memory: 
/thirdparty/instant-ngp/dependencies/tiny-cuda-nn/include/tiny-cuda-nn/gpu_memory.h:123 cudaMalloc(&rawptr, n_bytes+DEBUG_GUARD_SIZE*2) 
failed with error no CUDA-capable device is detected

将上述运行指令中的--multi_gpu选项去掉即可。

3. 其他模式运行

跳过SLAM,用位姿真值和深度运行。3060Ti 8G现存可以运行这种模式

./scripts/download_cube.bash 
python ./examples/slam_demo.py --dataset_dir=./datasets/nerf-cube-diorama-dataset/room --dataset_name=nerf --buffer=100 --img_stride=1 --fusion='nerf' --gui

运行画面如下:

四、官方代码问题解决记录

1. gtsam编译问题

在执行cmake --build build_gtsam --config RelWithDebInfo后遇到

#0 3.429 pyparsing.exceptions.ParseException: Expected string_end, found 'namespace'  (at char 1249), (line:46, col:1)
#0 3.450 make[2]: *** [python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/build.make:76: python/gtsam_unstable.cpp] Error 1
#0 3.450 make[1]: *** [CMakeFiles/Makefile2:32340: python/CMakeFiles/pybind_wrap_gtsam_unstable.dir/all] Error 2

解决:

将thirdparty中的gtsam代码替换为,重新执行编译步骤即可。

2. 路径问题

download_replica_sample.bash中的数据下载地址是Datasets,而运行地址是小写字母datasets.

3. 运行时报错
 File "/NeRF-SLAM/./examples/../slam/vio_slam.py", line 65, in initial_statenaive_pose = gtsam.Pose3.identity()
AttributeError: type object 'gtsam.gtsam.Pose3' has no attribute 'identity'
Traceback (most recent call last):File "<string>", line 1, in <module>File "anaconda3/envs/zl/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_mainexitcode = _main(fd, parent_sentinel)File "anaconda3/envs/zl/lib/python3.9/multiprocessing/spawn.py", line 126, in _mainself = reduction.pickle.load(from_parent)File "anaconda3/envs/zl/lib/python3.9/multiprocessing/synchronize.py", line 110, in __setstate__self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory
Traceback (most recent call last):File "<string>", line 1, in <module>File "anaconda3/envs/zl/lib/python3.9/multiprocessing/spawn.py", line 116, in spawn_mainexitcode = _main(fd, parent_sentinel)File "anaconda3/envs/zl/lib/python3.9/multiprocessing/spawn.py", line 126, in _mainself = reduction.pickle.load(from_parent)File "anaconda3/envs/zl/lib/python3.9/multiprocessing/synchronize.py", line 110, in __setstate__self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory

重新卸载安装其他版本的gtsam也没解决,于是跳转至前文介绍的部署流程了。

更多推荐

NeRF

本文发布于:2023-11-16 14:44:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624944.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NeRF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!