haifengl / smile

Statistical Machine Intelligence & Learning Engine

Home Page:https://haifengl.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

M1 Mac is not supported

mgroth0 opened this issue · comments

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.

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.