Closed Schroedi closed 3 weeks ago
For tensorflow on ARM Apple, you should install tensorflow-deps using conda (https://github.com/lfoppiano/material-parsers?tab=readme-ov-file#set-up-on-apple-m1, you can stop before the spacy model download stuff - same scientific approach 😄 )
I use usually Conda and I install most of the packages with pip unless they are particularly annoying (e.g. try to compile -fail - etc...)
The JEP library should not need to be copied under the grobid-home because the version in the python env should be used directly. For doing that you should export the equivalent of CONDA_PREFIX directory corresponding to VENV before running grobid.
Thanks for taking your time. I tried using conda but was not successful. It's the same situation as before.
About the CONDA_PREFIX
I was not completely sure what you meant. It points to the venv's rood directory. Adding that to the java.library.path does not make any difference for me. And conda already exports it.
I will continue to use my remote linux machine for now. So feel free to close this issue.
Just for the record, here is what I did:
brew install miniforge
conda init zsh
zsh
conda create -n grobidEnv python=3.9
conda activate grobidEnv
tensorflow-metal==0.6.0
tensorflow-macos==2.10.0
numpy==1.22.3
transformers==4.29.1
jep==4.2.0
# this is important as v70 is incompatible (https://github.com/pypa/setuptools/issues/4376#issuecomment-2126162839)
setuptools==69.5.1
conda install -c apple tensorflow-deps
pip install -r requirements.macos.txt
conda install scikit-learn=1.0.1
#clone into delft
# remove all already installed packages from delft/setup.py (diff below)
pip install -e delft
diff --git a/setup.py b/setup.py
index 456da4c..8145d05 100644
--- a/setup.py
+++ b/setup.py
@@ -15,20 +15,15 @@ setup(
install_requires=[
'numpy==1.22.3',
'regex==2021.11.10',
git apply grobidConf.patch
./gradlew clean install
java -Xmx4G -Djava.library.path=grobid-home/lib/mac_arm-64:/opt/homebrew/Caskroom/miniforge/base/envs/grobidEnv2/lib/ -jar grobid-core/build/libs/grobid-core-0.8.1-SNAPSHOT-onejar.jar -gH grobid-home -dIn /Users/ascadian/Projects/paperSegmentation/train_data/rawSingle -dOut /Users/ascadian/Projects/paperSegmentation/train_data/anno_raw_test_foo -exe createTraining
Error:
[...]
14:34:45.795 [main] INFO org.grobid.core.main.LibraryLoader - Loading JEP native library for DeLFT... /Users/ascadian/Projects/grobid4/grobid-home/lib/mac_arm-64
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.grobid.core.utilities.Utilities.launchMethod(Utilities.java:344)
at org.grobid.core.main.batch.GrobidMain.main(GrobidMain.java:194)
Caused by: java.lang.UnsatisfiedLinkError: no jep in java.library.path: grobid-home/lib/mac_arm-64:/opt/homebrew/Caskroom/miniforge/base/envs/grobidEnv2/lib/
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2434)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1993)
at org.grobid.core.main.LibraryLoader.load(LibraryLoader.java:158)
at org.grobid.core.factory.AbstractEngineFactory.init(AbstractEngineFactory.java:72)
at org.grobid.core.factory.GrobidFactory.<init>(GrobidFactory.java:19)
at org.grobid.core.factory.GrobidFactory.newInstance(GrobidFactory.java:73)
at org.grobid.core.factory.GrobidFactory.getInstance(GrobidFactory.java:30)
at org.grobid.core.engines.ProcessEngine.getEngine(ProcessEngine.java:46)
at org.grobid.core.engines.ProcessEngine.createTraining(ProcessEngine.java:376)
... 6 more
Adding the jep dir back to the java.library.path or copying the lib as before results in the same situation as in the original comment. (Jep init failed)
About the CONDA_PREFIX I was not completely sure what you meant. It points to the venv's rood directory. Adding that to the java.library.path does not make any difference for me. And conda already exports it.
You need to export it before running the gradle command.
That should be enough, however did you install jep in your conda environment?
What's your pip list
?
it looks like it's searching in the wrong directory
14:34:45.795 [main] INFO org.grobid.core.main.LibraryLoader - Loading JEP native library for DeLFT... /Users/ascadian/Projects/grobid4/grobid-home/lib/mac_arm-64
while it should load jep from your conda environment
@Schroedi I'm closing this, if you have still problems feel free to reopen/comment.
This is my attempt to use grobid on MacOS ARM. The docs state that MacOS is not fully supported so feel free to mark this issue as out of scope.
If anybody got it working, I would be interested in the package versions used.
Here I document what I tried and how far I got:
System
MacOS
14.4.1
(ARM M3) java --versionSteps
Output/Error
Used patches (in case the pastebin is unavailable)
grobidConf.patch delftMacArm.patch