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

OPENNLP-1515: Changing onnx dependency to onnxruntime. #551

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

jzonthemtn
Copy link
Contributor

Thank you for contributing to Apache OpenNLP.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with OPENNLP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn clean install at the root opennlp folder?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file in opennlp folder?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found in opennlp folder?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions for build issues and submit an update to your PR as soon as possible.

@jzonthemtn
Copy link
Contributor Author

jzonthemtn commented Oct 12, 2023

The onnxruntime-gpu dependency does not support OSX x64. The onnxruntime dependency supports Windows, Linux, and OSX x64. (There is not yet a runtime for Apple Silicon.) https://onnxruntime.ai/docs/get-started/with-java.html

A motivation for this change is to offer better support for ONNX models in Apache Solr - apache/solr#1999

So, I'm proposing defaulting to onnxruntime to support more OS's out of the box in the short term. In the long term, I would like to find a way to have both dependencies and give the user control over which is used.

Copy link

@epugh epugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@kinow kinow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Does that mean GPUs won't be supported until the OSX support is added to the removed dependency? If so, I think we should just include that info in the ANNOUNCE for the next release. Thanks!

@rzo1
Copy link
Contributor

rzo1 commented Oct 12, 2023

What about using <profiles> and <os>-based activation via Maven?

@kinow
Copy link
Member

kinow commented Oct 12, 2023

What about using <profiles> and <os>-based activation via Maven?

I think that would be for build only? Unless we produced artefacts to be uploaded to Maven per OS (I think I saw that once, some different flag in the dependency in Maven pom.xml, but never actually used it?)

@rzo1
Copy link
Contributor

rzo1 commented Oct 12, 2023

Something like:

<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>
  <parent>
    <groupId>org.apache.opennlp</groupId>
    <artifactId>opennlp</artifactId>
    <version>2.3.1-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
  </parent>
  <groupId>org.apache.opennlp</groupId>
  <artifactId>opennlp-dl</artifactId>
  <name>Apache OpenNLP DL</name>

  <properties>
    <onxx-runtime.artifact.name>onnxruntime_gpu</onxx-runtime.artifact.name>
  </properties>

  <profiles>
    <profile>
      <id>system-osx</id>
      <activation>
        <os>
          <family>mac</family>
        </os>
      </activation>
      <properties>
        <onxx-runtime.artifact.name>onnxruntime</onxx-runtime.artifact.name>
      </properties>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>org.apache.opennlp</groupId>
      <artifactId>opennlp-tools</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.microsoft.onnxruntime</groupId>
      <artifactId>${onxx-runtime.artifact.name}</artifactId>
      <version>${onnxruntime.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Think it would propagate for the transient dependencies as well but would need special treatment for building the zip releases (ie. include both libs)

@jzonthemtn
Copy link
Contributor Author

jzonthemtn commented Oct 12, 2023

Looks good to me. Does that mean GPUs won't be supported until the OSX support is added to the removed dependency? If so, I think we should just include that info in the ANNOUNCE for the next release. Thanks!

Yes, I think so. Someone could manually enable GPU by replacing the onnxruntime.jar with an onnxruntime-gpu.jar in their lib directory. I guess I feel like enabling GPU should require the extra step, instead of making someone replace the jars to go the other way, which is what ended up happening in Apache Solr.

@rzo1
Copy link
Contributor

rzo1 commented Oct 12, 2023

I agree with you @jzonthemtn - maybe we can attach a classifier-jar (separate issue) for GPU support in another issue? People consuming it via Maven can use the classifier to get correct transient dependencies without using excludes.

But maybe it isn't worth the effort. No idea how many people actually consume it via Maven ;-)

@jzonthemtn
Copy link
Contributor Author

I agree with you @jzonthemtn - maybe we can attach a classifier-jar (separate issue) for GPU support in another issue? People consuming it via Maven can use the classifier to get correct transient dependencies without using excludes.

But maybe it isn't worth the effort. No idea how many people actually consume it via Maven ;-)

I think that would be ideal. I will write a new JIRA for it.

@mawiesne mawiesne merged commit 2348136 into apache:main Oct 15, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants