window에서 nerfstudio 설치하기

코드짜는침팬지·2024년 1월 13일
0

학부연구생 겸 기업 프로젝트 겸 졸업논문 주제로 열심히 공부하고 있는 NeRF 입니다.

모델들을 하나하나 트레이닝하고 실험하는게 너무 복잡하고 귀찮아 NeRF studio를 사용 해보기로 했습니다. docker버전의 경우 xoft님의 블로그에 있는데 window는 아직 설치 해보신 분들이 없는 것 같아 해보았습니다.

환경설정은 NeRF stuidio의 기본 설정을 참고하면 됩니다.
cuda 는 11.8를 기반으로 하며, INSTANT NGP의 기본 설정이 되어있는 상태이므로 오류가 발생할 수도 있습니다. 만약 오류가 발생한다면, NeRFstudio의 FAQ를 찾아보셔도 좋고, 다음링크를 통해 instant ngp를 설치해보시고 하셔도 좋습니다.

Create environment

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

Dependencies

PyTorch
Note that if a PyTorch version prior to 2.0.1 is installed, the previous version of pytorch, functorch, and tiny-cuda-nn should be uninstalled.

pip uninstall torch torchvision functorch tinycudann

Torch 2.1.2 with CUDA 11.8 (recommended)
Install PyTorch 2.1.2 with CUDA 11.8:

pip install torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118

To build the necessary CUDA extensions, cuda-toolkit is also required. We recommend installing with conda:

conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit

tiny-cuda-nn
After pytorch and ninja, install the torch bindings for tiny-cuda-nn:

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

Installing nerfstudio

From pip

pip install nerfstudio

From source Optional, use this command if you want the latest development version.

git clone https://github.com/nerfstudio-project/nerfstudio.git
cd nerfstudio
pip install --upgrade pip setuptools
pip install -e .

Tab completion (bash & zsh)

This needs to be rerun when the CLI changes, for example if nerfstudio is updated.

ns-install-cli

여기까지가 기본 설치 과정입니다.

모델 트레이닝 하기

# Download some test data:
ns-download-data nerfstudio --capture-name=poster
# Train model
ns-train nerfacto --data data/nerfstudio/poster

혹시 안된다면 training model 경로를 절대경로로 수정하시면 됩니다.

(nerfstudio) C:\Users\joong>ns-train nerfacto --data C:\Users\joong\data\nerfstudio\poster

다음 커맨드를 입력하라고 나오는데 안됩니다.
디렉토리를 못찾는다 나오거든요
다음 링크를 통해 직접 다운로드 받는것을 추천드립니다.
nerfstudio 는 기본적으로 Home path를 사용하기 때문에

C:\Users\사용자이름\data

이곳에서 파일을 관리합니다.
파일을 다운로드 해주시고,

C:\Users\사용자이름\data\nerfstudio

이곳에서 압축을 해제 해주세요.


다음과 같이 나오면 성공입니다. f2nerf와 비슷한 트레이닝 세트네요
이제 https://viewer.nerf.studio/versions/23-05-15-1/?websocket_url=ws://localhost:7007
이곳에 접속하면

안됩니다! docker로 해도 실시간 렌더링이 안되고 window로 하면 아예 disconnected가 떠버렸습니다. 포트 방화벽을 해제해도 안됩니다!

(nerfstudio) C:\Users\joong>set

환경변수들을 확인해봅니다.

ffmpeg=C:\ProgramData\chocolatey
HOMEDRIVE=C:
HOMEPATH=\Users\joong
LOCALAPPDATA=C:\Users\joong\AppData\Local

혹시 모르니 home 환경도 변경 해보고 cli도 다시 설치 해봅니다.

(nerfstudio) C:\Users\joong>set HOME=\Users\joong
(nerfstudio) C:\Users\joong>ns-install-cli

7007 포트에 문제가 있는건 아닐까? 싶어서 포트를 변경 해봅니다.

(nerfstudio) C:\Users\joong>ns-train nerfacto --data C:\Users\joong\data\nerfstudio\poster --viewer.websocket-port 7878

잘되는걸 확인할 수 있습니다.

참고로 완성된 모델을 보시고 싶다면, 다음 명령어를 실행 하시면 됩니다.

(nerfstudio) C:\Users\joong>ns-viewer --load-config outputs\posters\nerfacto\2024-01-13_164452\config.yml

그 외에도
nerfstudio에 설명이 자세히 나와 있습니다.

참고 자료

https://xoft.tistory.com/26
https://zhuanlan.zhihu.com/p/654394767
https://docs.nerf.studio/

profile
학과 꼴찌 공대 호소인

0개의 댓글