在Ubuntu 22中安装NARUTO(Neural Active Reconstruction)的注意事项

手动执行build.sh

build.sh的兼容性不高,要逐步执行。
逐步执行以下命令,遇到问题后,可参考后面的修改命令和方法。

ROOT=${PWD} 

### create conda environment ###
conda create -y -n naruto python=3.8 cmake=3.14.0

### activate conda environment ###
conda activate naruto

# ### Setup habitat-sim ###
cd ${ROOT}/third_parties
git clone git@github.com:Huangying-Zhan/habitat-sim.git habitat_sim
cd habitat_sim
pip install -r requirements.txt
python setup.py install --headless --bullet

### extra installation ###
pip install opencv-python
conda install -y ipython
pip install mmcv==2.0.0

### CoSLAM installation ###
cd ${ROOT}/third_parties/coslam
git checkout 3bb904e
pip install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip install -r requirements.txt
cd external/NumpyMarchingCubes
python setup.py install

### NARUTO installation ###
pip install -r ${ROOT}/envs/requirements.txt

配置合理的网络环境

要能正常访问GitHub,不做介绍

export https_proxy=XXXX http_proxy=XXXX all_proxy=XXX

下载habitat-sim

这一步已在PR中修复。使用新版时请跳过
首先会卡在这一步

git clone git@github.com:Huangying-Zhan/habitat-sim.git habitat_sim

因为在假设用户已经配置好了Git的SSH密钥,实际上大多数人是没有配置的。
要改成HTTPS克隆

git clone https://github.com/Huangying-Zhan/habitat-sim.git habitat_sim

正确安装CoSLAM

其次会卡在这里

pip install torch==1.10.1+cu113 torchvision==0.11.2+cu113 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu113/torch_stable.html
pip install -r requirements.txt

修复这个问题需要两步:

1.更换CUDA版本

脚本中的torch和cuda版本已经很老了,需要ubuntu 20才可以。
在Ubuntu 22,要更换为cuda 11.7实现兼容性平衡,不然会出现各种CUDA Mismatch或者编译失败。


sudo apt install cuda-toolkit-11-7

export CUDA_HOME=/usr/local/cuda-11.7
export LD_LIBRARY_PATH='/usr/local/cuda-11.7/lib64':$LD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH

pip uninstall torch torchvision torchaudio 
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 -f https://download.pytorch.org/whl/cu117/torch_stable.html

2.修改requirements.txt

requirements.txt (位于${ROOT}/third_parties/coslam)中有两个难以安装的包

git+https://github.com/facebookresearch/pytorch3d.git
git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

pytorch3d的安装可以参考官网,更换为预编译包,减少编译出错概率。

pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu117_pyt1131/download.html

而tinycudann则需要严格对应CUDA版本。即做到更换CUDA版本中要求的内容。然后按原来的步骤进行编译安装。

为了保证tinycudann安装稳定,可以尝试指定其版本
git+https://github.com/NVlabs/tiny-cuda-nn@v1.7.1/#subdirectory=bindings/torch

修改C++代码以实现编译兼容

这些问题一年前已经有一个PR在修复了。但遗憾的是目前也没合并或者被NARUTO采用。

在执行

cd external/NumpyMarchingCubes
python setup.py install

时,会出现如下错误

numeric_limits' is not a member of 'std'

这可能由于其编写时未考虑C++代码兼容性问题。

可以修改third_parties/coslam/external/NumpyMarchingCubes/marching_cubes/src/marching_cubes.cpp:

vim ${ROOT}/third_parties/coslam/external/NumpyMarchingCubes/marching_cubes/src/marching_cubes.cpp

在代码中添加#include <limits>即可

#include <vector>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <list>
#include <limits> //添加这一行
#include "tables.h"
#include "sparsegrid3.h"
#include "marching_cubes.h"

移除冲突的torch包

在脚本中最后一步

### NARUTO installation ###
pip install -r ${ROOT}/envs/requirements.txt

${ROOT}/envs/requirements.txt中的torch版本会与已安装的修改了版本的torch冲突。移除它们即可

#torch==1.10.1+cu113
#torchaudio==0.10.1+cu113
#torchvision==0.11.2+cu113

使用新版的conda激活环境

source activate命令是用于旧版conda的,

source activate naruto

在新版中应更换为

conda activate naruto
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值