pytorch / functorch

functorch is JAX-like composable function transforms for PyTorch.
https://pytorch.org/functorch/
BSD 3-Clause "New" or "Revised" License
1.38k stars 102 forks source link

Installing functorch breaks torchaudio #1057

Closed dellis23 closed 1 year ago

dellis23 commented 1 year ago

I'm following along with this colab from the functorch installation docs.

After installing and restarting, when I try to import torchaudio, the runtime crashes. At first, I got this error:

OSError: /usr/local/lib/python3.7/dist-packages/torchaudio/lib/libtorchaudio.so: undefined symbol: _ZN2at4_ops7resize_4callERKNS_6TensorEN3c108ArrayRefIlEENS5_8optionalINS5_12MemoryFormatEEE

Now, I'm just getting the runtime crashing with no visible error.

I know functorch was merged into pytorch proper, but I don't see any instructions about how to use it from there. Would that fix the issue? If so, should the main docs be updated?

dellis23 commented 1 year ago

Actually, it looks like the readme inside the functorch directory in pytorch also recommends installing from pip: https://github.com/pytorch/pytorch/tree/master/functorch#install

zou3519 commented 1 year ago

What are the versions of PyTorch and torchaudio that you are using?

zou3519 commented 1 year ago

We've updated the installation instructions to document how to use functorch from pytorch as per your feedback. Please see https://pytorch.org/functorch/stable/install.html . In general the runtime crashing is likely due to a version mismatch between PyTorch, functorch, torchaudio.

dellis23 commented 1 year ago

I was installing functorch into a vanilla colab instance. See here: https://gist.github.com/dellis23/61bdd9b93ba3d577e73739af8f4f82a9

It looks like the version requirements for functorch are incompatible with torchaudio (and torchtext and torchvision)?

dellis23 commented 1 year ago

Note that this also happens even after running the following after installing:

get_ipython().kernel.do_shutdown(True)
zou3519 commented 1 year ago

Colab has PyTorch 1.12.1 installed by default. The newest released PyTorch and functorch is 1.13.0, but colab does not install those by default yet. Attempting an upgrade of the PyTorch in colab sometimes leads to weirdness in colab. Thank you for pointing this out -- on the functorch side we should just recommend installation of the older version of functorch in our colab install instructions.

The easiest way to use functorch on colab is: in a fresh new colab, pip install functorch==0.2.1 (this is the version of functorch that is compatible with PyTorch 1.12.1). Could you let me know if that doesn't work please?

dellis23 commented 1 year ago

That seems to crash the session altogether with no error message. See here (though you'll have to execute it to see it happen). Here are screenshots:

image image
zou3519 commented 1 year ago

"Your session crashed for an unknown reason" is what happens when you execute get_ipython().kernel.do_shutdown(True). This is expected. Colab doesn't give a good error message when you restart the kernel.

Are you able to import torchaudio after ignoring the "Your session crashed for an unknown reason" message?

dellis23 commented 1 year ago

Ah whoops! You're right, that works. Thanks for the fix. Feel free to do what you want to with this issue. Not sure if you want to leave it open until things are all working on 1.13, or update the docs to mention the specific version installation.

zou3519 commented 1 year ago

Though the grapevine it sounds like PyTorch 1.13 will be the default in colab soon, so, probably easiest to wait until 1.13 and then we can remove the confusing "crash" in the instructions necessary for installing an external package into colab

zou3519 commented 1 year ago

Colab now has PyTorch 1.13 installed by default, so closing this issue.