如何安装nerfstudio?完整步骤详解

在Ubuntu20.04上安装nerfstudio

1 安装conda

# 下载软件
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh --no-check-certificate
# 安装
bash Miniconda3-py38_4.8.3-Linux-x86_64.sh
# 安装过程中选择安装路径
# 安装完毕后验证是否安装成功(需重启终端)
conda -V

2 新建环境

Python版本需要>=3.7,这里选择3.8版本

conda create --name nerfstudio -y python=3.8
conda activate nerfstudio
python -m pip install --upgrade pip

3 安装pytorch

预先安装cuda 11.3 cudnn8.2.1

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html

安装 tinycudann
下面是官网给出的安装命令,最好不要用这个,后面会遇到一系列问题

pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

选用下面的命令安装,先从https://github.com/NVlabs/tiny-cuda-nn下载github仓库,然后本地安装

# 安装git
sudo apt-get install build-essential git
# 下载仓库
git clone --recursive https://github.com/nvlabs/tiny-cuda-nn
cd tiny-cuda-nn
# 还有两个包要自己手动安装
pip install fmt
pip install cutlass
# 如果直接pip安装速度很慢,在后面跟上 -i 镜像源地址
# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn fmt
# 编译,如果没安装cmake的话需要安装cmake,至少3.18版本
cmake . -B build
cmake --build build --config RelWithDebInfo -j

安装cmake参照如下命令

# 下载
wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.tar.gz
# 解压
tar zxvf cmake-3.18.0-Linux-x86_64.tar.gz
# 安装
sudo mv cmake-3.18.0-Linux-x86_64 /opt/cmake-3.18.0
sudo ln -sf /opt/cmake-3.18.0/bin/*  /usr/bin/
# 检验是否安装成功
cmake --version
# 若出现cmake version 3.18.0则说明安装成功

1.png
如果使用cmake –build build –config RelWithDebInfo -j 命令编译很久进度条都没有变化的话,尝试把 -j 去掉后重新执行
2.png

# 安装tinycudann
cd bindings/torch
python setup.py install

安装完成之后检查一下是否安装成功

Python
import tinycudann

若不报错,则说明已经安装成功
3.png

4 安装nerfstudio

官方文档有两种安装方式,推荐使用第二种,第一种会下载torch2.0.0,后面各种报错
第一种,使用pip直接安装

pip install nerfstudio

第二种,先下载github仓库,本地安装

# 下载github仓库
git clone https://github.com/nerfstudio-project/nerfstudio.git
# 进入文件目录
cd nerfstudio
# 安装nerfstudio
pip install --upgrade pip setuptools
pip install -e .

这里安装的时候应该会默认下载torch1.13.1,后面跑代码的时候依然报错,需要重新下载torch1.12.1,使用如下命令重新安装pytorch

pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 -f https://download.pytorch.org/whl/torch_stable.html

4.png

物联沃分享整理
物联沃-IOTWORD物联网 » 如何安装nerfstudio?完整步骤详解

发表评论