Hacking Haskell on Nvidia Jetson - Experience Report

October 18, 2019 - Haskell, Jetson, aarch64

I guess I could have subtitled this post “Wearing the hair shirt, pants and beanie”; it’s been quite a journey but as we say, “All’s well that ends well!” And it did. For those seriously pressed to get to the skinny there’s a TL;DR summary of how to get to work using ghc-8.8.1 on the Jetson Nano.

Why the Nano?

For a SBC under $100 this is some piece of kit. We are used to Nvidia making very powerful graphics and GPGPU cards at a price and power consumption on the high end. I used to have a couple of their consumer graphics cards in my workstation and we were obliged to upgrade the UPS once I started running CUDA jobs on them. Not so the Nano, its power consumption is a few amps at 5v and the power upgrade requires switching from USB to a decent 5v 4A supply via the barrel jack if you intend to thrash it. (It is also possible to provide 6A via the J48 header by using two 3A 5v feeds, which makes more sense for a permanent installation).

Why Haskell?

I was already developing a graphical application in gloss on MacOS as a visualisation tool for data I was collecting and analysing from a logging device on board a yacht. We were interested in collision detection and more focussed on fleet safety with data being uploaded remotely for offline analysis.

The prospect of being able to take the analysis and visualisation on board using the Jetson as a platform was something I thought we might explore in another few months or so once we had got past prototyping of the on board devices. But I had imagined I’d be back in C++ to make that happen, once we had a good idea of whether it was to be a chart plotter or something more attuned to the needs of the racing yachtsman.

There were a couple of threads on Reddit (cf.) which pointed to the possibility of ghc-8.8 being the place to start. At this time cf. ghc-8.8.1 wasn’t even a thing on Stackage so this really was a stretch as the application had grown to have quite a few dependencies on some important and complex libraries.

Well how about getting a hello world to run as a quick experiment? After all the development system was built, I had a spare SSD for a development setup and Amazon had arranged for this tiny touch screen to be delivered. jetson-devsys-picture

Steps along the road

Hello world

  • nix
  • use nix to install ghc — fail
  • Install ghc-8.8.1 from aarch64 binary package.
  • install llvm
  • convince ghc that all is well with llvm
  • hello world

Something more challenging

  • bootstrap
  • cabal-install - fail
  • install stack - good
  • build hpack - good

Conclusion

I am less enamoured with the Haskell ecosystem and tooling than before, not just due to this experience. See: SpatiaLite GIS my first monad in anger