Installing neurosymbolic programming tools for NX 3: Leiningen, Javabridge and Python Integration

Previous Forum postings have covered the installation of open source tools for integrating AI symbolic programming with the powerful deep neural network (DNN) CV and machine learning resources in the NVIDIA Jetson JetPack development environment. Special attention has been directed at integrating with the excellent Jetson Python dev toolscape (e.g., for Jupyter Notebooks and PyTorch).

In the formal context of evolving AI methods, newer neural-symbolic (or neurosymbolic) programming techniques may be used for enhancing explainability of DNN-based functions, efficiency of machine learning, and availability of complementary new methods for inference.

Our example project is now developing integrated broad-range scientific image processing laboratory and AI research applications on a Xavier NX cluster edge ‘appliance’. All programming resources are also hosted on a Dell Xeon 20 RTX GPU workstation running NVIDIA SDK with JetPack, consistent with NV EGX specifications.

The first posting covered the following software:

  • OpenJDK and its JVM as dependencies
  • NIH ImageJ (jar) for image processing
  • CLIPS (jar or bin) for symbolic rule-oriented programming
  • Protege (jar) for ontology access, symbolic linking, reasoning

The second posting covered:

On to installing Leiningen and libpython-clj + javabridge for Python
(Concentrated info warning!)

In coming up on Clojure programming and function libraries, a project build management library is essential. Leiningen was chosen.

It can automatically set up project directories and starting configuration boilerplate files consistent with good dev repository practices, as well as downloading necessary libraries, jars, and dependencies via Maven.

And thanks again to the comprehensive Ubuntu apt environment, there were install archives for Leiningen. So the only initial binaries download step was:

 sudo apt install leiningen

for both the workstation (amd64) and Xavier NX (arm64) Ubuntu 18.04 systems.

Available resources for running Clojure with Python include a Python library of Clojure functions (libpython-clj) and a Python library for interacting with Java jars (Javabridge). It seemed best to start with both.

The comprehensive host site for libpython-clj didn’t simply describe installation details for the library.

But in the end, it only required the relatively ‘simple’ installation and ‘first-use activation’ of the previously downloaded Leiningen to set up libpython-clj locally on either workstation or Xavier NX.

The steps are summarized below, and new users are urged to consult these excellent pages for a better understanding of libpython-clj use with the Clojure REPL (Read Eval Print Loop; ‘CLI’} and more.

The latest Python development library and pip3 are required:

 sudo apt install libpython3.6-dev python3-pip

Numpy, pandas, and matplotlib are also required, but they were covered by the workstation’s Anaconda Navigator installation and apparently installed in the NX L4T base.

Then, from the terminal, Leiningen (lein) is used to create a new test project, its directories and boilerplate files:

     lein new app libpython-clj-play
     cd libpython-clj-play

Then edit the new project.clj ‘boilerplate’ file to add the source dependencies (~ line 6) and save.

     :dependencies [[org.clojure/clojure "1.10.1"]
                  [cnuernber/libpython-clj "1.33"]]

Then, returning to the terminal:

  lein deps

to download verbosely all the many basic project dependency files and the libpython-clj library to the hidden /repository subdirectory in ~/Home/.m2 .

After all that, the easily installed Javabridge Python package seems to be ideal for the first task of launching and interacting with the previously set up ImageJ and Protege, as well as with CLIPSJNI and Clojure processes.

The primary dependencies for installation also include pip3 and numpy as covered, then pip is used:

    pip install javabridge

Talk about treasure hidden in plain view at the end of this platform integration process! To quote the web site: “The javabridge was developed for CellProfiler, where it is used together with python-bioformats to interface to various Java code, including Bio-Formats and ImageJ”.


Installation image from NX0:

1 Like