Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML-171]when enabled oap mllib, spark.dynamicAllocation.enabled should be set… #190

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions mllib-dal/src/main/scala/com/intel/oap/mllib/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,24 @@ object Utils {

def isOAPEnabled(): Boolean = {
val sc = SparkSession.active.sparkContext
return sc.getConf.getBoolean("spark.oap.mllib.enabled", true)
val dynamic = sc.getConf.getBoolean("spark.dynamicAllocation.enabled", false)
val isoap = sc.getConf.getBoolean("spark.oap.mllib.enabled", true)
if (isoap && dynamic) {
throw new Exception(
s"OAP MLlib does not support dynamic allocation, " +
s"spark.dynamicAllocation.enabled should be set to false")
}
isoap
}

def getOneCCLIPPort(data: RDD[_]): String = {
val executorIPAddress = Utils.sparkFirstExecutorIP(data.sparkContext)
val kvsIP = data.sparkContext.getConf.get("spark.oap.mllib.oneccl.kvs.ip",
executorIPAddress)
val kvsIP = data.sparkContext.getConf.get("spark.oap.mllib.oneccl.kvs.ip", executorIPAddress)
// TODO: right now we use a configured port, will optimize auto port detection
// val kvsPortDetected = Utils.checkExecutorAvailPort(data, kvsIP)
val kvsPortDetected = 3000
val kvsPort = data.sparkContext.getConf.getInt("spark.oap.mllib.oneccl.kvs.port",
kvsPortDetected)
val kvsPort =
data.sparkContext.getConf.getInt("spark.oap.mllib.oneccl.kvs.port", kvsPortDetected)

kvsIP + "_" + kvsPort
}
Expand Down Expand Up @@ -96,20 +102,23 @@ object Utils {
def checkExecutorAvailPort(data: RDD[_], localIP: String): Int = {

if (localIP == "127.0.0.1" || localIP == "127.0.1.1") {
println(s"\nOneCCL: Error: doesn't support loopback IP ${localIP}, " +
s"please assign IP address to your host.\n")
println(
s"\nOneCCL: Error: doesn't support loopback IP ${localIP}, " +
s"please assign IP address to your host.\n")
System.exit(-1)
}

val sc = data.sparkContext
val result = data.mapPartitions { p =>
val port = OneCCL.getAvailPort(localIP)
if (port != -1) {
Iterator(port)
} else {
Iterator()
val result = data
.mapPartitions { p =>
val port = OneCCL.getAvailPort(localIP)
if (port != -1) {
Iterator(port)
} else {
Iterator()
}
}
}.collect()
.collect()

result(0)
}
Expand All @@ -127,9 +136,11 @@ object Utils {
// check workers' platform compatibility
val executor_num = Utils.sparkExecutorNum(sc)
val data = sc.parallelize(1 to executor_num, executor_num)
val result = data.mapPartitions { p =>
Iterator(OneDAL.cCheckPlatformCompatibility())
}.collect()
val result = data
.mapPartitions { p =>
Iterator(OneDAL.cCheckPlatformCompatibility())
}
.collect()

result.forall(_ == true)
}
Expand Down