haifengl / smile

Statistical Machine Intelligence & Learning Engine
https://haifengl.github.io
Other
6.02k stars 1.13k forks source link

M1 Mac is not supported #726

Closed mgroth0 closed 1 year ago

mgroth0 commented 1 year ago

I am trying to install this library for the first time on my M1 mac. I am including the library and its native dependencies as gradle dependencies.

I currently have:

smile = {module="com.github.haifengl:smile-core",version.ref="smile"}
smile-kotlin = {module="com.github.haifengl:smile-kotlin",version.ref="smile"}

javacpp =  {module="org.bytedeco:javacpp", version="1.5.7"}
openblas = {module="org.bytedeco:openblas",version="0.3.19-1.5.7"}
arpack-ng = {module="org.bytedeco:arpack-ng",version="3.8.0-1.5.7"}

with smile = "2.6.0".

I also use dependency substitution to add the classifer to the native dependencies.

 fun fixOpenBLASDependencies() {
    fixNativeDependencies(
      mod = "org.bytedeco:javacpp",
      version = "1.5.7",
      newMacClassifier = "macosx-arm64"
    )
    fixNativeDependencies(
      mod = "org.bytedeco:openblas",
      version = "0.3.19-1.5.7",
      newMacClassifier = "macosx-arm64"
    )
    fixNativeDependencies(
      mod = "org.bytedeco:arpack-ng",
      version = "3.8.0-1.5.7",
      newMacClassifier = "macosx-arm64"
    )
  }

 fun fixNativeDependencies(
    mod: String,
    version: String,
    newMacClassifier: String
  ) {
    configurations.all {
      it.resolutionStrategy.dependencySubstitution { sub ->
        sub.substitute(sub.module(mod))
          .using(sub.module("$mod:$version")).withClassifier(newMacClassifier)
      }
    }
  }

However, this results in a compilation error because arpack-ng and openblas have no build for macosx-arm64 (there should be macosx-aarch64 jars here and here but there are not). Note that javacpp does have macosx-arm64.

haifengl commented 1 year ago

not all algorithms need openblas and arpack. The rest should work on M1 as generic java. You may also try the master branch, which runs with javacpp 1.5.8. Openblas 1.5.8 should support macosx-arm64. arpack doesn't support arm64 though. Just exclude it. The build should be fine.