Skip to content

Any examples - in particular on using RunOnSpark.runOnSpark() ? #7

Open

Description

@javadba

I would like to create a small PR with a small Test and/or example. Some suggested code to use for these would be appreciated.

Otherwise I will be attempting to reverse engineer from the API's and put together something.

Activity

  1. jamesjia94 commented on Jun 11, 2016

    @jamesjia94
    Contributor

    I created a KMeans learner that uses RunOnSpark under BIDMach_Spark/scripts/KMeansLearner.ssc.

    Let me know if you have any questions!

  2. javadba commented on Jun 11, 2016

    @javadba
    Author

    Sounds perfect! Taking a look.

  3. javadba commented on Jun 11, 2016

    @javadba
    Author

    How do I run it? In general : is there a reference about .ssc files? I do not undertand: where is the interpreter for them and how they work.

  4. javadba commented on Jun 11, 2016

    @javadba
    Author

    I can not find any documentation on the web for .ssc files. They contain scala, java, python, and some custom language. Please point some references about them.

  5. jamesjia94 commented on Jun 11, 2016

    @jamesjia94
    Contributor

    From what I understand, the .ssc files are just a custom extension that we use to denote a scala script e.g. you can load them into a scala interpreter using scala -i test.ssc. The spark shell also used to support the -i command, though I don't think it has been working since 1.5.0+. I've been using :load path_to_file.ssc inside the Spark REPL.
    I don't know about the .ssc files that aren't in scala, but I imagine it'd be for a similar purpose? @jcanny

  6. javadba commented on Jun 11, 2016

    @javadba
    Author

    So when I do

    :load /git/BIDMach_Spark/scripts/KMeansLearner.ssc
    

    the obvious problem is that some of the setup stuff like opts variable that are created via init_bidmach.scala are not there: so it fails. What is the way to run this in REPL?

  7. jamesjia94 commented on Jun 11, 2016

    @jamesjia94
    Contributor

    KMeans.learner() returns a tuple of (learner, opts), so opts should be in scope. Could you paste the specific error that you are receiving?

  8. javadba commented on Jun 11, 2016

    @javadba
    Author

    How are you starting spark-shell? The BIDMat/Mach libraries will need to be present.

    Here is what I have done so far:

    cala> :require /git/BIDMach/BIDMach.jar
    Added '/git/BIDMach/BIDMach.jar' to classpath.

    scala> :require /git/BIDMach_Spark/BIDMach_Spark.jar
    Cannot load '/git/BIDMach_Spark/BIDMach_Spark.jar'

    scala> :require /git/BIDMach_Spark/BIDMatHDFS.jar.jar
    Cannot load '/git/BIDMach_Spark/BIDMatHDFS.jar.jar'

    scala> :require /git/BIDMach_Spark/BIDMatHDFS.jar
    Added '/git/BIDMach_Spark/BIDMatHDFS.jar' to classpath.

    scala> :load /git/BIDMach_Spark/scripts/KMeansLearner.ssc
    Loading /git/BIDMach_Spark/scripts/KMeansLearner.ssc...
    import org.apache.spark.rdd.RDD
    import scala.reflect.ClassTag
    import BIDMat.MatIO
    import BIDMat.SerText
    import BIDMach.RunOnSpark._
    :30: error: object MockLearner is not a member of package BIDMach
    import BIDMach.MockLearner
    ^

  9. jamesjia94 commented on Jun 12, 2016

    @jamesjia94
    Contributor

    You can delete the MockLearner import or pull from BIDMach_Spark. It's a remnant from an older version of the test.
    Also, you'll have to specify the MASTER_DNS as the master DNS address of your spark machine, and also supply your own data in BIDMat matrix forms.
    For example, I use the mnist8M dataset which can be downloaded using BIDMach/scripts/getmnist8m.sh. The script automatically saves the matrices into FMats. You can then run BIDMach_Spark/scripts/load_mnist.ssc and BIDMach_Spark/scripts/append_mnist.ssc to load the data onto HDFS.

  10. javadba commented on Jun 12, 2016

    @javadba
    Author

    OK I pulled your update .

    How do we load the jars? They are not complementary:

    scala> :require /git/BIDMat/BIDMat.jar
    Added '/git/BIDMat/BIDMat.jar' to classpath.

    scala> :require /git/BIDMach/BIDMach.jar
    The path '/git/BIDMach/BIDMach.jar' cannot be loaded, because existing classpath entries conflict.

    But if I just do the BIDMach.jar we get this:

    error: missing or invalid dependency detected while loading class file 'MatIO.class'.
    Could not access type MatIOtrait in package BIDMat,
    because it (or its dependencies) are missing. Check your build definition for
    missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.)

  11. jamesjia94 commented on Jun 13, 2016

    @jamesjia94
    Contributor

    You can use the --jars option with a comma separated list of jars. Alternatively, you can configure the spark conf via spark.driver.extraClassPath and spark.executor.extraClassPath.

  12. javadba commented on Jun 13, 2016

    @javadba
    Author

    Hi James, yes but that was not my question/issue here. If you review again my last post it was about : "which" jars need to be used - given the apparent incompatibility of the combinations I tried.

    Please say explicitly which combination of jars works for you - i.e. that you are using to get this to work.

  13. jamesjia94 commented on Jun 13, 2016

    @jamesjia94
    Contributor

    If you use --jars BIDMach.jar,BIDMat.jar instead of :require, the scala/Spark repl doesn't throw any errors.
    That being said, here is my spark conf.

    spark.executor.extraClassPath /opt/BIDMach/lib/BIDMatHDFS.jar:/opt/BIDMach/BIDMach.jar:/opt/BIDMach/lib/BIDMat.jar:/opt/BIDMach/lib/ptplot.jar:/opt/BIDMach/lib/ptplotapplication.jar:/opt/BIDMach/lib/jhdf5.jar:/opt/BIDMach/lib/commons-math3-3.2.jar:/opt/BIDMach/lib/lz4-1.3.jar:/opt/BIDMach/lib/json-io-4.1.6.jar:/opt/BIDMach/lib/jfreechart-1.0.19.jar:/opt/BIDMach/lib/jcommon-1.0.23.jar:/opt/BIDMach/lib/jcuda-0.7.0a.jar:/opt/BIDMach/lib/jcublas-0.7.0a.jar:/opt/BIDMach/lib/jcufft-0.7.0a.jar:/opt/BIDMach/lib/jcurand-0.7.0a.jar:/opt/BIDMach/lib/jcusparse-0.7.0a.jar

    spark.driver.extraClassPath /opt/BIDMach/lib/BIDMatHDFS.jar:/opt/BIDMach/BIDMach.jar:/opt/BIDMach/lib/BIDMat.jar:/opt/BIDMach/lib/ptplot.jar:/opt/BIDMach/lib/ptplotapplication.jar:/opt/BIDMach/lib/jhdf5.jar:/opt/BIDMach/lib/commons-math3-3.2.jar:/opt/BIDMach/lib/lz4-1.3.jar:/opt/BIDMach/lib/json-io-4.1.6.jar:/opt/BIDMach/lib/jfreechart-1.0.19.jar:/opt/BIDMach/lib/jcommon-1.0.23.jar:/opt/BIDMach/lib/jcuda-0.7.0a.jar:/opt/BIDMach/lib/jcublas-0.7.0a.jar:/opt/BIDMach/lib/jcufft-0.7.0a.jar:/opt/BIDMach/lib/jcurand-0.7.0a.jar:/opt/BIDMach/lib/jcusparse-0.7.0a.jar

    spark.driver.extraLibraryPath /opt/BIDMach/lib:/usr/local/cuda/lib64:/usr/local/hadoop/lib/native
    spark.executor.extraLibraryPath /opt/BIDMach/lib:/usr/local/cuda/lib64:/usr/local/hadoop/lib/native

  14. javadba commented on Jun 13, 2016

    @javadba
    Author

    Thanks a lot James - I did not realize that ":require" would behave differently than --jars. Trying now.

  15. javadba commented on Jun 13, 2016

    @javadba
    Author

    How did you convert the MNIST files to Sequence files?

  16. javadba commented on Jun 13, 2016

    @javadba
    Author

    Oh right the HDFSIO class. Give me few mins on that.

  17. javadba commented on Jun 13, 2016

    @javadba
    Author

    Looks like your load_mnist.ssc should do the trick.

  18. jamesjia94 commented on Jun 13, 2016

    @jamesjia94
    Contributor

    Yes, that's correct. You can then merge all those files into one file via append_mnist.ssc to create a larger dataset.

  19. javadba commented on Jun 13, 2016

    @javadba
    Author

    thx - yes I did see that too. Few mins should have something here.

  20. javadba commented on Jun 13, 2016

    @javadba
    Author

    How did you set the lz4? I have been unable to get past the following:

    java.lang.RuntimeException: native lz4 library not available

  21. jamesjia94 commented on Jun 13, 2016

    @jamesjia94
    Contributor

    Did you add the path to hadoop native libraries to the library path of your executors and driver?

  22. javadba commented on Jun 13, 2016

    @javadba
    Author

    The lz4 is not residing under hadoop in my case. I did add the path to the lz4 under SPARK_LIBRARY_PATH in $SPARK_HOME/conf/spark-env.sh

  23. javadba commented on Jun 13, 2016

    @javadba
    Author

    oh ok - so the problem may be due to Hadoop not having access to lz4 - not spark. I am going to add lz4 to hadoop now

  24. javadba commented on Jun 13, 2016

    @javadba
    Author

    This is a significant task since the native Hadoop binaries are not installed by default. Do you have a suggestion on how to approach this if lz4 were not available? Otherwise this is going to take me some time to understand how to install on my mac.

  25. javadba commented on Jun 13, 2016

    @javadba
    Author

    Apparently the Mac brew uses MH_DYLD flags and not MH_BUNDLE - contributing to my challenges here. I am kinda stalled now: setting up native library builds is not within my prior experience. I would suggest that it were likely I will not be the only one running into this issue.

  26. jamesjia94 commented on Jun 13, 2016

    @jamesjia94
    Contributor

    Sorry I am not familiar with that. My mac installation of hadoop has the required native library (libhadoop.so), but I haven't run BIDMach_Spark on my mac before. I'm in Switzerland right now so I'll be sleeping soon, but I can try running through things on my mac tomorrow if you haven't figured it out.

  27. javadba commented on Jun 13, 2016

    @javadba
    Author

    Thanks James . I will update here in a bit: presently trying to build lz4 natively but the Makefile does not mention either MH_DYLD or MH_BUNDLE. This is new territory for me.

  28. javadba commented on Jun 14, 2016

    @javadba
    Author

    I downloaded and built hadoop with native to obtain libhadoop.dynlib. However "hadoop checknative" returns all false. I am still struggling on my end with this.

  29. javadba commented on Jun 16, 2016

    @javadba
    Author

    I needed a day off to attend to other things: got back on this earlier today. I fixed the hadoop native libs issue: it had to do with setting the DYLD_LIBRARY_PATH.

    After that - still many things to do for this to work. Setting spark and hadoop settings, and creating a smaller version of the mnist files (8M too big for my machine). It seems to be going now on a small slice of the data.

    I will put together a PR tomorrow.

  30. javadba commented on Jun 16, 2016

    @javadba
    Author

    PR is in #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions