Closed maydaygmail closed 9 years ago
You can run scripts directly from the command line:
bidmach mycommands.scala
the behavior is the same as calling ":load" from the scala prompt. You dont need to create a main method (it wont be called unless you do it in the script), just give a list of expressions to be eval'ed.
If you really want to use your own jar, you can put it in
bidmach -e expression
to invoke a class from your jar (its a complete expression so can include arguments). There are examples of both approaches in
We dont use sbt to run BIDMach/BIDMat since they both require native path setting which I think is out of sbt's reach (as a pure java application).
I write a src/main/scala/exp/lrexp.scala file: //////////////////////////////////// package exp
import BIDMat.{CMat,CSMat,DMat,Dict,IDict,Image,FMat,FND,GMat,GIMat,GSMat,HMat,IMat,Mat,SMat,SBMat,SDMat} import BIDMat.MatFunctions. import BIDMat.SciFunctions. import BIDMat.Solvers. import BIDMat.Plotting. import BIDMach.Learner import BIDMach.models.{FM,GLM,KMeans,KMeansw,LDA,LDAgibbs,Model,NMF,SFA} import BIDMach.datasources.{DataSource,MatDS,FilesDS,SFilesDS} import BIDMach.mixins.{CosineSim,Perplexity,Top,L1Regularizer,L2Regularizer} import BIDMach.updaters.{ADAGrad,Batch,BatchNorm,IncMult,IncNorm,Telescoping} import BIDMach.causal.{IPTW}
object LRExp { def main(args:Array[String]) = { println("LRExp") val a = grand(20,30) println(a) } } ///////////////////////////////////////
./sbt package
generate a jar
and then typing ./sbt "runMain exp.LRExp"
println("LRExp") can be executed successfully
then appear errors: error java.lang.UnsatisfiedLinkError: Could not load the native library. [error] Error while loading native library "bidmatmkl-linux-x86_64" with base name "bidmatmkl" [error] Operating system name: Linux [error] Architecture : amd64 [error] Architecture bit size: 64 [error] Stack trace from the attempt to load the library as a resource: [error] java.lang.NullPointerException: No resource found with name '/lib/libbidmatmkl-linux-x86_64.so' [error] at jcuda.LibUtils.loadLibraryResource(LibUtils.java:149)
however, in interactive shells, scala scripts can run successfully:
how can I run the program in a command not in interactive? Thanks!