xgboost icon indicating copy to clipboard operation
xgboost copied to clipboard

[[xgboost4j-spark] Exception while converting booster to XGBoost model

Open nikunjgit opened this issue 9 years ago • 5 comments

Hello, I sometimes see that even though training is successful and Rabit returns with status code 0, the following code causes the spark job to fail:

In xgboost/jvm-packages/xgboost4j-spark/src/main/scala/ml/dmlc/xgboost4j/scala/spark/XGBoost.scala: convertBoosterToXGBoostModel(distributedBoosters.first(), isClassificationTask)

Here, for some reason distributedBoosters.first() is causing the problem. I'm unable to figure out why that would be the case since distributedBoosters can never be empty.

Environment info

Operating System: Ubuntu 12.04.5 LTS

Compiler: gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)

Package used (python/R/jvm/C++): jvm

xgboost version used: d9584ab

Steps to reproduce

val paramMap = List( "eta" -> 0.1, "max_depth" -> 6, "tracker_conf" -> TrackerConf(Duration(500, scala.concurrent.duration.SECONDS), "scala"), "objective" -> "binary:logistic").toMap

val classificationModel = XGBoost.trainWithDataFrame( dataset, paramMap, 300, nWorkers = 40, useExternalMemory = true, featureCol = "features", labelCol = "indexedLabel")

What have you tried?

INFO XGBoostSpark: Rabit returns with exit code 0

Container marked as failed: container_e497_1482450014832_615058_01_000031 on host. Exit status: 255. Diagnostics: Exception from container-launch.

2016-12-29 07:44:23,220 [Driver] (MLCoreSystemException:190) ERROR {"exceptionType":"SYSTEM","stackTrace":"org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 14.0 failed 10 times, most recent failure: Lost task 0.9 in stage 14.0 (TID 609, hadoopworker1143-sjc1.prod.uber.internal): ExecutorLostFailure (executor 12 exited caused by one of the running tasks) Reason: Container marked as failed: container_e497_1482450014832_615058_01_000017 on host: hadoopworker1143-sjc1.prod.uber.internal. Exit status: 255. Diagnostics: Exception from container-launch.\nContainer id: container_e497_1482450014832_615058_01_000017\nExit code: 255\nStack trace: ExitCodeException exitCode=255: \n\tat org.apache.hadoop.util.Shell.runCommand(Shell.java:573)\n\tat org.apache.hadoop.util.Shell.run(Shell.java:476)\n\tat org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:758)\n\tat org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:213)\n\tat org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)\n\tat org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat java.lang.Thread.run(Thread.java:745)\n\n\nContainer exited with a non-zero exit code 255\n\nDriver stacktrace:\n\tat org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1450)\n\tat org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1438)\n\tat org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1437)\n\tat scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)\n\tat scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)\n\tat org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1437)\n\tat org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:811)\n\tat org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:811)\n\tat scala.Option.foreach(Option.scala:257)\n\tat org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:811)\n\tat org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1659)\n\tat org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1618)\n\tat org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1607)\n\tat org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)\n\tat org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:632)\n\tat org.apache.spark.SparkContext.runJob(SparkContext.scala:1886)\n\tat org.apache.spark.SparkContext.runJob(SparkContext.scala:1899)\n\tat org.apache.spark.SparkContext.runJob(SparkContext.scala:1912)\n\tat org.apache.spark.rdd.RDD$$anonfun$take$1.apply(RDD.scala:1305)\n\tat org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)\n\tat org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)\n\tat org.apache.spark.rdd.RDD.withScope(RDD.scala:358)\n\tat org.apache.spark.rdd.RDD.take(RDD.scala:1279)\n\tat org.apache.spark.rdd.RDD$$anonfun$first$1.apply(RDD.scala:1319)\n\tat org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)\n\tat org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)\n\tat org.apache.spark.rdd.RDD.withScope(RDD.scala:358)\n\tat org.apache.spark.rdd.RDD.first(RDD.scala:1318)\n\tat ml.dmlc.xgboost4j.scala.spark.XGBoost$.postTrackerReturnProcessing(XGBoost.scala:306)\n\tat ml.dmlc.xgboost4j.scala.spark.XGBoost$.trainWithRDD(XGBoost.scala:297)\n\tat ml.dmlc.xgboost4j.scala.spark.XGBoostEstimator.train(XGBoostEstimator.scala:119)\n\tat ml.dmlc.xgboost4j.scala.spark.XGBoostEstimator.train(XGBoostEstimator.scala:34)\n\tat org.apache.spark.ml.Predictor.fit(Predictor.scala:97)\n\tat ml.dmlc.xgboost4j.scala.spark.XGBoost$.trainWithDataFrame(XGBoost.scala:181)

nikunjgit avatar Dec 29 '16 08:12 nikunjgit

Also note that the training did happen successfully and I saw all the iteration logs with the error reducing gradually.

nikunjgit avatar Dec 29 '16 08:12 nikunjgit

so you may want to confirm two things

  1. whether all partitions contain data (I think the current code base handles empty partition, if you found this is the reason, it might be a bug)

  2. upgrade your gcc to 4.8 and try

CodingCat avatar Dec 30 '16 00:12 CodingCat

This was a data locality issue. Got fixed by setting spark.locality.wait. Basically, if first() is run on an executor which doesn't have the data local to it, then it will trigger a re-evaluation which will cause the problem

nikunjgit avatar Dec 30 '16 03:12 nikunjgit

this is interesting, so, you're on YARN-cluster mode and first() is run on a node which never run a Spark task?

This seems to be a to-be-resolved issue

CodingCat avatar Dec 30 '16 05:12 CodingCat

Hi CodingCat, I have seen the same issue as observed by nikunjgit, even after setting "spark.locality.wait=3s". Do you have any suggestion on what could be the root cause? I am still new to XGBoost and am trying to understand what is happening.

Thanks!

wmingshi avatar May 21 '17 19:05 wmingshi