Failing to add NX to nerves

I’m trying to add NX support to a nerves livebook but torchx fails to build during mix firmware. It fails with:

Could NOT find Torch (missing: TORCH_LIBRARY)

Has anyone tried to add NX to nerves before? Any special procedure to get it working in this case?

1 Like

Nerves Livebook comes with Nx installed, but it only includes the default non-accelerated backend. If you’re doing something simple, this might be enough.

Adding the EXLA or TorchX backends to Nerves is bleeding edge right now. EXLA appears easier to use on Nerves at the moment. This has been done on Raspberry Pi 4s. Other boards may work, but the Pi4 is the only one that I know has been used. I’ve also verified that it works at a very basic level.

Since this is a rapidly improving topic, I’m hesitant to post too much here since it will quickly be out of date and may be confusing once everything gets ironed out.

Could I suggest joining the Erlang Ecosystem’s Machine Learning group slack? See erlef.org/wg/machine-learning. Updates on Nerves support get posted there. Searching for Nerves will get you high level EXLA build instructions now.

2 Likes

Thanks @fhunleth, I’ve already requested to join the slack group :slight_smile: But just add more color on what I’m trying to accomplish here: I would like to use a “small” image classification model like RESNet on rpi0 by importing it via AxonOnnx. I also had the impression that Nx on torch (even CPU mode) would be faster than pure Nx and since torch is a C++ lib it could be straight forward to cross-compile it as NIFs.

Got it. Yes, your impression is correct. Pure Nx is a little slow.

I haven’t tried cross-compiling Torch in months. Using Nx’s EXLA backend instead was nice since there’s a precompiled binary that works on the Pi4. There’s not a precompiled binary for the Pi0 so I see why you’re going down this route. I’ll be curious on your progress. I really hope this works for you.