Nerfstudio動かしてみた - murata-lab/worklog-tomoya GitHub Wiki
Nerfstudio動かしてみた
Nerfstudioとは
Nerfstudioとは、ブラウザ上で「NeRF」の作成、学習、可視化を簡単に行うことができるツール
環境構築
conda activate nerfstudio
python -m pip install --upgrade pip
pip uninstall torch torchvision functorch tinycudann
conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit
pip install ninja git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
最後のコマンドを実行したところ後半部分がエラーになったが、今回の動作の際には特に問題なかった。
学習手順
チュートリアルで紹介されているnerfactoを用いた学習を行った。
データダウンロード
ns-download-data nerfstudio --capture-name=poster
学習の実行
ns-train nerfacto --data data/nerfstudio/poster
学習時に--machine.num-devices {実行したいGPU数}
と指定することで、複数のGPUで並列に実行することができる。
しかし、以下の設定で試したところ実際にはむしろ4倍遅くなった...
おそらくI/O周りの問題と考えられる。
また、2つのGPUの場合でも同様だった。
export CUDA_VISIBLE_DEVICES=0,1,2,3
ns-train nerfacto --machine.num-devices 4 --data data/nerfstudio/poster
PyNeRFでの学習
高速で実行できるPyNeRFを使ってみる
インストール手順
pip install git+https://github.com/hturki/pynerf
pip install torch-scatter -f https://data.pyg.org/whl/torch-${TORCH_VERSION}+${CUDA}.html
ここで、setup.pyでエラーが起こった。
その原因はsetuptoolsのバージョンにあり、こちらのIssueで指摘されていた通り、69.5.1
を用いたら解決できた。
pip install setuptools==69.5.1
学習の実行
以下のコードで実行したところ、デフォルトのposterデータセットだと形式が合わないためか、Sparse
フォルダがないというエラーが発生した。
ns-train PyNeRF --data data/nerfstudio/poster