Run pytorch in pyodide?
Asked Answered
S

1

7

Is there any way I can run the python library pytorch in pyodide? I tried installing pytorch with micropip but it gives this error message:

Couldn't find a pure Python 3 wheel for 'pytorch'

Symer answered 14/10, 2020 at 17:14 Comment(3)
Maybe you could try micropip.install("https://download.pytorch.org/whl/nightly/cpu/torch-1.6.0.dev20200328%2Bcpu-cp38-cp38-linux_x86_64.whl")? Or check other PyTorch provided wheels hereSpiros
Thank you very much. Do you know how I can get the wheels for other packages because pytorch is dependent on other packages like ctypes to work.Symer
Dunno, you would probably have to resolve it and search their respective wheels on your own. If you manage to get it working please post an answer with necessary steps as I'd like to know as well.Spiros
C
10

In Pyodide micropip only allows to install pure python wheels (i.e. that don't have compiled extensions). The filename for those wheels ends with none-any.whl (see PEP 427).

If you look at Pytorch wheels currently available on PyPi, their filenames ends with e.g. x86_64.whl so it means that they would only work on the x86_64 architecture and not in the WebAssembly VM.

The general solution to this is to add a package to the Pyodide build system. However in the case of pytorch, there is a blocker that cffi is currently not supported in pyodide (GH-pyodide#761), while it's required at runtime by pytorch (see an example of build setup from conda-forge). So it is unlikely that pytorch would be availble in pyodide in the near future.

Camisole answered 17/10, 2020 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.