Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONNX not supported Mac OS X #638

Closed
isaacmg opened this issue Oct 22, 2018 · 10 comments
Closed

ONNX not supported Mac OS X #638

isaacmg opened this issue Oct 22, 2018 · 10 comments

Comments

@isaacmg
Copy link

isaacmg commented Oct 22, 2018

I'm trying to test out the ONNX preset on Mac and I'm getting the following error.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Platform "macosx-x86_64" not supported by class org.bytedeco.javacpp.onnx
	at org.bytedeco.javacpp.Loader.load(Loader.java:928)
	at org.bytedeco.javacpp.Loader.load(Loader.java:891)
	at org.bytedeco.javacpp.onnx.<clinit>(onnx.java:10)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at org.bytedeco.javacpp.Loader.load(Loader.java:950)
	at org.bytedeco.javacpp.Loader.load(Loader.java:891)
	at org.bytedeco.javacpp.onnx$ISchemaRegistry.<clinit>(onnx.java:1324)
	at LoadModelONNX.<init>(LoadModelONNX.java:6)
	at runModel.main(runModel.java:6)

This is what my POM file looks like.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.model_loader</groupId>
    <artifactId>caffe_model</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.bytedeco.javacpp-presets/onnx-platform -->
        <dependency>
            <groupId>org.bytedeco.javacpp-presets</groupId>
            <artifactId>onnx-platform</artifactId>
            <version>1.3.0-1.4.3</version>
        </dependency>

    </dependencies>

</project>

Am I missing anything?

@saudet
Copy link
Member

saudet commented Oct 22, 2018

No, we probably just need to adjust the build in the cppbuild.sh file:
https://github.com/bytedeco/javacpp-presets/blob/master/onnx/cppbuild.sh
Could you give it a try and send a pull request if it works? That would be great!

@isaacmg
Copy link
Author

isaacmg commented Oct 23, 2018

Sorry, I'm not too familiar with javacpp-presets or the maven build process (I mostly work in Python but need to make sure our model runs in Java). Are you saying to download the sh file and run it manually on my machine or something else? Thanks.

@saudet
Copy link
Member

saudet commented Oct 23, 2018 via email

@isaacmg
Copy link
Author

isaacmg commented Oct 26, 2018

Okay I added "macosx" to presets/onnx.java, but when went to install with maven I ran into fatal error: too many errors emitted, stopping now I think this is a problem with my Mac though as it has happened before when building caffe2 from the source.

@saudet
Copy link
Member

saudet commented Oct 26, 2018

I've included support for Mac in this PR: #622
Please give it a try! Thanks

@isaacmg
Copy link
Author

isaacmg commented Oct 30, 2018

Thanks I'm still having problems building on my Mac but I think this is due to problems with cmake on my end. I did get it running on Linux. I was wondering once I load the model what method do I call to actually make the predictions? Usually in Python I would do something like

prepared_backend = onnx_caffe2.backend.prepare(model)
W = {model.graph.input[0].name: model_inputs.numpy()}
c2_out = prepared_backend.run(W)[0]

Now I just have a ModelProto class but don't know what to do with it.

saudet pushed a commit that referenced this issue Oct 31, 2018
 * Add build for Mac OS X to presets for ONNX (issue #638)
@saudet
Copy link
Member

saudet commented Oct 31, 2018

I've merged the PR, so snapshots will be available sometime tomorrow.
Please try those: http://bytedeco.org/builds/ Thanks!

@saudet
Copy link
Member

saudet commented Oct 31, 2018

@EmergentOrder Any ideas about how we can do what @isaacmg mentions above?

@EmergentOrder
Copy link
Member

@isaacmg This preset does not include a backend. It enables us to do things like load a model, check it, optimize it, perform shape inference, convert it to a different ONNX version and gain access to the operator schemas and IR.

The JavaCPP Preset offers an API that is as close as possible to the ONNX C++ API in Java.

In contrast, my project ONNX-Scala aims to provide a typeful, idiomatic and purely functional Scala API to ONNX.

ONNX-Scala provides a clean separation between API, program definition, and backend implementation.

Currently there is no backend available for ONNX-Scala either, but the plan is to have several backend implementations available. The first cut of the first one should be ready in the near future.
Lantern is the top candidate right now.

I am also working on a JavaCPP Preset for ngraph , which should provide us with an ONNX backend in Java (also a candidate for a backend in ONNX-Scala)

@saudet
Copy link
Member

saudet commented Jan 13, 2019

Support for Mac has been included in version 1.4.4! Enjoy

@saudet saudet closed this as completed Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants