Skip to content

java.lang.NoClassDefFoundError: org/tensorflow/Tensor #14540

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

Open
aarandag opened this issue Mar 28, 2025 · 1 comment
Open

java.lang.NoClassDefFoundError: org/tensorflow/Tensor #14540

aarandag opened this issue Mar 28, 2025 · 1 comment
Assignees
Labels

Comments

@aarandag
Copy link

aarandag commented Mar 28, 2025

I'm trying to run this example locally (machine translation with MarianMT), and I'm finding this error:

sentence_detector_dl download started this may take some time.
Approximate size to download 514.9 KB
Download done! Loading the resource.
[ / ]
An error occurred while calling z:com.johnsnowlabs.nlp.pretrained.PythonResourceDownloader.downloadModel.
: java.lang.NoClassDefFoundError: org/tensorflow/Tensor
at com.johnsnowlabs.ml.tensorflow.TensorflowWrapper$.read(TensorflowWrapper.scala:453)
at com.johnsnowlabs.ml.tensorflow.ReadTensorflowModel.readTensorflowModel(TensorflowSerializeModel.scala:154)
at com.johnsnowlabs.ml.tensorflow.ReadTensorflowModel.readTensorflowModel$(TensorflowSerializeModel.scala:123)
at com.johnsnowlabs.nlp.annotators.sentence_detector_dl.SentenceDetectorDLModel$.readTensorflowModel(SentenceDetectorDLModel.scala:648)
at com.johnsnowlabs.nlp.annotators.sentence_detector_dl.ReadsSentenceDetectorDLGraph.readSentenceDetectorDLGraph(SentenceDetectorDLModel.scala:621)
...

I'm using this artifact: com.johnsnowlabs.nlp:spark-nlp_2.12:5.2.3, configuring it in spark.jars.packages, so all dependencies should be installed. Things I tried with no success:

  • install tensorflow with pip.
  • install the org.tensorflow.tensorflow:1.15.0

What is strange to me is that Tensorflow should be bundled in spark-nlp, right?

Any help would be greatly appreciated. Thank you!

EDIT: I encountered this error in an Apple Silicon (M1) laptop. When running on an arm64 laptop, I didn't find this issue. So I think it must be related.

@DevinTDHa DevinTDHa self-assigned this Apr 17, 2025
@DevinTDHa
Copy link
Member

Hi @aarandag,

Thanks for reporting. Indeed, Tensorflow should be bundled with Spark NLP.

However, if you are running on Apple Silicon, you need to consider the following:

  1. Your Java installation needs to be compiled for Apple Silicon, see Installation for M1 Macs
  2. Start Spark NLP with the right flags to enable Apple Silicon support:
import sparknlp

spark = sparknlp.start(apple_silicon=True)

Can you try this and let us know if it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants