Skip to content

Commit 162dbdc

Browse files
author
Andy Feng
committed
Enable Apache Spark 2.0
1 parent f9a3c65 commit 162dbdc

4 files changed

Lines changed: 6 additions & 27 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,11 @@ cluster](../../wiki/GetStarted_EC2).
6060

6161
## Building for Spark 2.X
6262

63-
Optional: To use a local **SNAPSHOT** version of Spark: first perform a **mvn install** from your local Spark to your local maven repository as follows:
64-
65-
<pre>
66-
cd $SPARK_HOME
67-
mvn <spark options\> install
68-
</pre>
69-
70-
Next: configure the **CaffeOnSpark/caffe-grid** maven build to use the correct versions of Spark for your environment.
71-
72-
You may either :
73-
74-
1) Accept the "default" Spark2.X settings by using
75-
76-
mvn -Dspark2 clean package
77-
78-
The default settings are:
79-
80-
- spark-2.0.0-SNAPSHOT
63+
CaffeOnSpark supports both Spark 1.x and 2.x. For Spark 2.0, our default settings are:
64+
- spark-2.0.0
8165
- hadoop-2.7.1
8266
- scala-2.11.7
83-
84-
2) You can manually specify particular values yourself. For example for the 2.0.0-preview with hadoop 2.7.2 and scala 2.11.8:
85-
86-
mvn -Dspark.version=2.0.0-preview -Dhadoop.version=2.7.2 -Dscala.major.version=2.11 -Dscala.version=2.11.8 clean package
67+
You may want to adjust them in caffe-grid/pom.xml.
8768

8869

8970
## Mailing List

‎caffe-grid/pom.xml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
<hadoop.version>2.7.1</hadoop.version>
3636
<scala.version>2.11.7</scala.version>
3737
<scala.major.version>2.11</scala.major.version>
38-
<slf4j.version>1.6.6</slf4j.version>
39-
<spark.version>2.0.0-SNAPSHOT</spark.version>
38+
<spark.version>2.0.0</spark.version>
4039
</properties>
4140
</profile>
4241
</profiles>

‎caffe-grid/src/main/python/com/yahoo/ml/caffe/CaffeOnSpark.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from ConversionUtil import wrapClass
88
from RegisterContext import registerContext
99
from pyspark.sql import DataFrame,SQLContext
10-
from pyspark.mllib.linalg import Vectors
1110

1211
class CaffeOnSpark:
1312
"""CaffeOnSpark is the main class for distributed deep learning.
@@ -18,7 +17,7 @@ class CaffeOnSpark:
1817

1918
def __init__(self,sc):
2019
registerContext(sc)
21-
wrapClass("org.apache.spark.sql.DataFrame")
20+
wrapClass("org.apache.spark.sql.Dataset")
2221
self.__dict__['caffeonspark']=wrapClass("com.yahoo.ml.caffe.CaffeOnSpark")
2322
self.__dict__['cos']=self.__dict__.get('caffeonspark')(sc)
2423
self.__dict__['sqlcontext']=SQLContext(sc,self.__dict__['cos'].sqlContext)

‎caffe-grid/src/main/scala/com/yahoo/ml/caffe/DataFrameSource.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class DataFrameSource(conf: Config, layerId: Int, isTrain: Boolean)
105105
val has_id : Boolean = columnNames.contains("id")
106106

107107
//mapping each row to RDD tuple
108-
df.map(row => {
108+
df.rdd.map(row => {
109109
val id: String = if (!has_id) "" else row.getAs[String]("id")
110110
val sample = new Array[Any](numTops)
111111
(0 until numTops).map(i => sample(i) = row.getAs[Any](topNames(i)))

0 commit comments

Comments
 (0)