Using MXNet from Java application


#1

Hello all,

I am currently evaluating a number of DL frameworks/libraries for use in our Java based system. MXNet would be an interesting choice due to the scalability, AWS support, and pretrained models. However, there is no Java API at the moment.
Has anyone tried to make MXnet usable for a Java application, maybe using Jython as a bridge or similar approach? I’d be grateful for any hints.

Cheers,

Martin


#2

I’m curious to hear your use case. Are you looking for a Java API to run training or inference or both?
A majority of users use python API for training. What are your reasons for not going that route? I’m not saying everyone should use Python. Just curious to know the constraints you are operating under.

Regarding Java API, there has been a discussion in dev@ email list on this topic recently: https://lists.apache.org/thread.html/0033017d02d913e6a1517331291a8f561dd56ed445932f7347b59898@<dev.mxnet.apache.org>

The popular proposal has been to build a Java interface on top of existing scala bindings and improve it based on user feedback. The work on that hasn’t started yet.


How to use Java to invoke a trained model with Mxnet/Gluon
#3

Thanks a lot for the reply and your interest. First a brief update to this question: I have been able to get Scala working in the context of our Java-based system, so from that point of view I would be able to use MXNet by way of the Scala API now.

I have read through the thread you pointed to and I agree with Jörn Kottman from OpenNLP that a Java API would be a very useful addition.
Specifically and to answer your question, the need for such a Java API in our case is driven by two factors:

  1. The system that I would like to integrate MXNet with is a Java-based one and therefore using Python is not suitable (I have tried it with Jython, but didn’t work due to problems with module loading). Using Scala would be an option, but introduces another dependency.

  2. Currently, I need to build MXNet natively on the target system even when using Scala API. For deployment purposes, this would be too cumbersome and risky, as the deployment could easily fail the heterogenous production systems that we are working with. Besides, the build from source is not working for me even on my development machine. (cf. Problems with building MXNet Shared Library from source on Mac OS (for Scala))

So, for the moment it seems like it makes more sense to use a different solution, such as Deeplearning4J. I would prefer MXNet, due to the prebuilt models and support from Amazon AWS, but if the library is not usable in a Java environment right now, I can’t really recommend it for our organisation.

Cheers,

Martin


#4

Hi

I too am interested in mxnet for Java. I am no terribly concerned (yet) about building mxnet locally. I would very much prefer an ecosystem without scala (for the perhaps seemingly bizarre reason that I have had trouble debugging scala code in the past - it appears to encapsulate objects inside objects which makes debugging a pain in the neck).

I am wondering how hard it would be to convert the scala adapter to java.

Phil Troy


#5

Same issue, I have trying to deploy Mxnet in Spark with scala api, however, it is too buggy right now. And scala mxnet need compile with Opencv, it is nightmare for production!

On the contrary, there are lots of tensorflow on spark production example on community, even the performance is not good.


#6

I have some good news to share. The work on building Java API interface for MXNet has been under way for some time and there is now alpha version available. You can download it from S3 for your CPU or GPU setup.

It is initial version of Java API, it currently supports only inference use cases. We do plan to extend it and would appreciate your feedback on how well it is suited for your use cases and what parts are missing. You can provide such feedback by sending an email to user at mxnet.incubator.apache dot org or by posting it as reply on this topic.