Sending a PR to pytorch

I’ve previously contributed to torchvision, pytorch docs but I’ve not contributed to pytorch. My request to send a PR has been approved. I can’t simply clone the forked repo because it has not been compiled (import torch didn’t work) .

Do I need to build Pytorch from source to see the updated change that I do with python code ?

Building it from source hangs my laptop after sometime and it’s very slow. I also want to check first if my change is working or not. What should I do ?

Can you list the minimal steps required?

@ptrblck, could you please suggest?

@tom created a great tutorial on how to fix your first bug in PyTorch (including a video) here.

1 Like

Three quick comments (though we’d really need more context to see where you want input):

  • Building and testing PyTorch your changes before submission is essential to a successful PR.
  • You may want to skip it for developing the patch, in particular when you are working on Python parts. I sometimes pick the “very quick and very dirty” way of just editing the installed .py files and then incorporating the changes to the source.
  • Building PyTorch is quite intense in terms of resources, but the CONTRIBUTING.md has hints how to speed up at least rebuilds.
  • My personal way of doing things (I think it is in the video) is to use python3 setup.py build (even though PyTorch always helpfully reminds me that I’m doing it wrong) and then using the packages in ./build/lib.SOMETHING/ (either with (cd build/lib.*/ ; ipython3) or with PYTHONPATH=./build/lib.SOMETHING python3 test/sometest.py. In this way of working, you cannot run python from the checkout path because it’ll find the torch module there but that won’t find the compiled C extension modules.
    The fancy people have venvs and setup.py develop but I never had the ambition for that type of sophistication.

Just give us a shout when there is something specific you want input on.

Best regards

Thomas

2 Likes

Thanks a lot for your support.