nerfstudio icon indicating copy to clipboard operation
nerfstudio copied to clipboard

How to efficiently debug while developing my own models.

Open MobiusLqm opened this issue 2 years ago • 11 comments

Hi, Thanks to your wonderful work on this framework! I want to develop my own model according to my idea. Previously, I usually use IDE like Pycharm( where I could debug line by line) to help me find and fix bugs. But when using NeRFstudio,we use commands like "ns-train xxxxx" instead of " python train.py". I mean the entry is seems not from python scripts and do not use python interpreter, How can I debug my own model? Is there some ways to efficiently Debug ?

MobiusLqm avatar Jul 17 '23 17:07 MobiusLqm

If you want to set breakpoints and investigate some tensors during the training process, consider using the "set trace" functionality from the python debugger https://docs.python.org/3/library/pdb.html. It can be a powerful tool if you learn how to use it. Good luck.

maturk avatar Jul 18 '23 05:07 maturk

If you want to set breakpoints and investigate some tensors during the training process, consider using the "set trace" functionality from the python debugger https://docs.python.org/3/library/pdb.html. It can be a powerful tool if you learn how to use it. Good luck.

Hi,maturk. Thanks for your advice, I am trying to find the python entrypoints of bash comands like "ns-train", then excute codes in a python way. Then I can debug using IDE . Could you please give your opinion this method?I am a fresh pythoner, so am not sure whether it can work out and whose method is better.

MobiusLqm avatar Jul 19 '23 10:07 MobiusLqm

If you want to set breakpoints and investigate some tensors during the training process, consider using the "set trace" functionality from the python debugger https://docs.python.org/3/library/pdb.html. It can be a powerful tool if you learn how to use it. Good luck.

Hi,maturk. Thanks for your advice, I am trying to find the python entrypoints of bash comands like "ns-train", then excute codes in a python way. Then I can debug using IDE . Could you please give your opinion this method?I am a fresh pythoner, so am not sure whether it can work out and whose method is better.

I am not too familiar with this, but nerfstudio uses tyro (https://github.com/brentyi/tyro) as a CLI tool which is used to execute the various python scripts with correct arguments. You can look for the keywords "tyro.cli(" inside scripts like train.py, render.py, etc. You can see that the authors even define "entrypoint()" functions there. Hope this gives you some guidance. Debugging with a dedicated IDE tools might not work, but you can try out the pdb library to manually set your trace points.

maturk avatar Jul 19 '23 10:07 maturk

If you want to set breakpoints and investigate some tensors during the training process, consider using the "set trace" functionality from the python debugger https://docs.python.org/3/library/pdb.html. It can be a powerful tool if you learn how to use it. Good luck.

Hi,maturk. Thanks for your advice, I am trying to find the python entrypoints of bash comands like "ns-train", then excute codes in a python way. Then I can debug using IDE . Could you please give your opinion this method?I am a fresh pythoner, so am not sure whether it can work out and whose method is better.

I am not too familiar with this, but nerfstudio uses tyro (https://github.com/brentyi/tyro) as a CLI tool which is used to execute the various python scripts with correct arguments. You can look for the keywords "tyro.cli(" inside scripts like train.py, render.py, etc. You can see that the authors even define "entrypoint()" functions there. Hope this gives you some guidance. Debugging with a dedicated IDE tools might not work, but you can try out the pdb library to manually set your trace points.

Thank you so much for your detailed explianation. I will try it later.

MobiusLqm avatar Jul 19 '23 10:07 MobiusLqm

train.py in nerfstudio/scripts/train.py is equivalent to ns-train. You can just replace everything ns-train with a call to that file.

Goulustis avatar Jul 22 '23 05:07 Goulustis

train.py in nerfstudio/scripts/train.py is equivalent to ns-train. You can just replace everything ns-train with a call to that file.

thank you so much for your advice.

MobiusLqm avatar Jul 25 '23 07:07 MobiusLqm

train.py in nerfstudio/scripts/train.py is equivalent to ns-train. You can just replace everything ns-train with a call to that file.

I successfully debugged locally. Additionally, do not install nerfstudio, otherwise "import nerfstudio" instruction will firstly find the installed package of "nerfstudio". Then I add system path of "xxx/nerfstudio/nerfstudio" to the python script and run "python train.py". It works at last.

wen-yuan-zhang avatar Aug 03 '23 10:08 wen-yuan-zhang

Perhaps an easier way is to do the editable install pip install -e <path/to/local/nerfstudio/clone>.

jkulhanek avatar Aug 28 '23 19:08 jkulhanek

hi @MobiusLqm , were you able to debug it on the IDE?

anas-zafar avatar Oct 03 '23 18:10 anas-zafar

hi @zParquet, did you debug it in an IDE?

anas-zafar avatar Oct 03 '23 18:10 anas-zafar

@anas-zafar yeah. I debugged it in pycharm and it worked normally.

wen-yuan-zhang avatar Dec 31 '23 08:12 wen-yuan-zhang

Hi, If you are going to debug nerfstudio models (NeRF, NeRFacto,..), remove "ns-train" and keep others. For example: vanilla-nerf --vis viewer+wandb --data/.../

samadbarrikhojasteh avatar Feb 12 '24 09:02 samadbarrikhojasteh