Skip to content

Commit

Permalink
handle NumberFormatException with executorId (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahsams authored and kmadhugit committed Dec 13, 2017
1 parent 3fb5218 commit 46b5dd5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gpu-enabler/src/main/scala/com/ibm/gpuenabler/GPUSparkEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ private[gpuenabler] object GPUSparkEnv {
if (env.isGPUEnabled) {
val executorId = env.executorId match {
case "driver" => 0
case _ => SparkEnv.get.executorId.toInt
case _ =>
val execIdStr = SparkEnv.get.executorId
if (execIdStr.forall( _.isDigit )) {
execIdStr.substring(0, Math.min(execIdStr.length, 5)).toInt
} else {
val stripNum = ("[0-9]".r findAllIn execIdStr).mkString("")
if (stripNum.isEmpty) 0
else stripNum.substring(0, Math.min(stripNum.length, 5)).toInt
}
}

env.gpuDevice = executorId % env.gpuCount
Expand Down

0 comments on commit 46b5dd5

Please sign in to comment.