ipex-llm icon indicating copy to clipboard operation
ipex-llm copied to clipboard

An error is reported when I created the SparkContext : Exception: Java gateway process exited before sending its port number

Open kwonder0926 opened this issue 5 years ago • 8 comments

when I used jupyter to to verify if BigDL can run successfully. But reported error as follow:

[hadoop@node01 bin]$ jupyter-with-bigdl.sh --master local[*]
sc = SparkContext(appName="text_classifier",
                    conf=create_spark_conf())
init_engine()
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-6-06882b30264e> in <module>()
      1 sc = SparkContext(appName="text_classifier",
----> 2                     conf=create_spark_conf())
      3 init_engine()

/install/spark-2.4.7/python/pyspark/context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    131                     " note this option will be removed in Spark 3.0")
    132 
--> 133         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    134         try:
    135             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,

/install/spark-2.4.7/python/pyspark/context.py in _ensure_initialized(cls, instance, gateway, conf)
    314         with SparkContext._lock:
    315             if not SparkContext._gateway:
--> 316                 SparkContext._gateway = gateway or launch_gateway(conf)
    317                 SparkContext._jvm = SparkContext._gateway.jvm
    318 

/install/spark-2.4.7/python/pyspark/java_gateway.py in launch_gateway(conf)
     44     :return: a JVM gateway
     45     """
---> 46     return _launch_gateway(conf)
     47 
     48 

/install/spark-2.4.7/python/pyspark/java_gateway.py in _launch_gateway(conf, insecure)
    106 
    107             if not os.path.isfile(conn_info_file):
--> 108                 raise Exception("Java gateway process exited before sending its port number")
    109 
    110             with open(conn_info_file, "rb") as info:

Exception: Java gateway process exited before sending its port number

Someone can help me?

kwonder0926 avatar Jun 08 '21 03:06 kwonder0926

my environment variables setted in all nodes as follow:

export JAVA_HOME=/install/jdk1.8.0_141
export PATH=$PATH:$JAVA_HOME/bin

export HADOOP_HOME=/install/hadoop-3.1.4
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin

export ZK_HOME=/install/zookeeper-3.6.2
export PATH=$PATH:$ZK_HOME/bin

export SPARK_HOME=/install/spark-2.4.7
export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.10.7-src.zip:$PYTHONPATH
export PATH=$PATH:$SPARK_HOME/bin
export PYSPARK_PYTHON=python

export ANACONDA_HOME=/install/anaconda3
export PATH=$ANACONDA_HOME/bin:$PATH

export BIGDL_HOME=/install/bigdl-0.12.2
export BIGDL_JARS=$BIGDL_HOME/lib/bigdl_0.12.2-jar-with-dependencies.jar
export BigDL_JAR_PATH=${BigDL_HOME}/lib/bigdl-VERSION-jar-with-dependencies.jar
export BIGDL_PACKAGES=$BIGDL_HOME/lib/bigdl_0.12.2-python-api.zip
export BIGDL_API_PATH=$BIGDL_HOME/lib/bigdl_0.12.2-python-api.zip
export SPARK_DRIVER_MEMORY=20g
export PATH=$PATH:$BIGDL_HOME/bin
"/etc/profile" 102L, 2773C 

I do not know how to set the environment variables BIGDL_JARS and BIGDL_PACKAGES

kwonder0926 avatar Jun 08 '21 03:06 kwonder0926

It seems that there is something wrong with my jar dependency, but I don't know how to solve it

[hadoop@node02 bin]$ spark-shell-with-bigdl.sh 
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
        at org.apache.spark.deploy.SparkHadoopUtil$.org$apache$spark$deploy$SparkHadoopUtil$$appendS3AndSparkHadoopConfigurations(SparkHadoopUtil.scala:464)
        at org.apache.spark.deploy.SparkHadoopUtil$.newConfiguration(SparkHadoopUtil.scala:436)
        at org.apache.spark.deploy.SparkSubmit$$anonfun$2.apply(SparkSubmit.scala:323)
        at org.apache.spark.deploy.SparkSubmit$$anonfun$2.apply(SparkSubmit.scala:323)
        at scala.Option.getOrElse(Option.scala:121)
        at org.apache.spark.deploy.SparkSubmit.prepareSubmitEnvironment(SparkSubmit.scala:323)
        at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:774)
        at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:161)
        at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:184)
        at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
        at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:920)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:929)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)

Please if you have any idea how I can solve this issue, I will be gratefull. Thank you!

kwonder0926 avatar Jun 08 '21 04:06 kwonder0926

Hi, if you download bigdl from here: https://bigdl-project.github.io/master/#release-download/ just unzip the downloaded package and set BIGDL_HOME to the root directory of the zipped package. Have a try and tell us if you have further issues. Thanks.

hkvision avatar Jun 08 '21 08:06 hkvision

You can refer to our document to set the environment variables: https://bigdl-project.github.io/master/#PythonUserGuide/run-without-pip/

hkvision avatar Jun 09 '21 02:06 hkvision

You can refer to our document to set the environment variables: https://bigdl-project.github.io/master/#PythonUserGuide/run-without-pip/

Thank you for your timely reply! But I still have a little bit of confusion,I'm not sure about the case of this environment variable. In the yarn virtual environment, it's lowercase BigDL_HOME=,but before it was capitalized export SPARK_HOME=folder path where you extract the spark package

I'm trying to reconfigure the cluster environment now, and when I finish configuring, I will try to install bigdl again。 Thank you again for your reply

kwonder0926 avatar Jun 09 '21 03:06 kwonder0926

I got it. It turned out that there was something wrong with my cluster environment. When I reconfigured the environment, my bigdl worked properly。

kwonder0926 avatar Jun 09 '21 09:06 kwonder0926

Oh, glad to hear that you got your problem resolved! Enjoy your trip with BigDL :)

hkvision avatar Jun 09 '21 10:06 hkvision

Hello, I got the same error with bigdl docker container when I tried to execute nn context :

/tmp/ipykernel_188/2945161649.py in <module>
----> 1 sc = init_nncontext("anomaly detection")
      2 spark= SparkContext(sc)

/opt/work/bigdl-2.1.0/python/bigdl-spark_3.1.2-2.1.0-python-api.zip/bigdl/dllib/nncontext.py in init_nncontext(conf, cluster_mode, spark_log_level, redirect_spark_log, **kwargs)
    534         spark_args.update(conf.getAll())
    535     if cluster_mode == "spark-submit":
--> 536         sc = init_internal_nncontext(conf, spark_log_level, redirect_spark_log)
    537     elif cluster_mode == "local":
    538         if conf:

/opt/work/bigdl-2.1.0/python/bigdl-spark_3.1.2-2.1.0-python-api.zip/bigdl/dllib/nncontext.py in init_internal_nncontext(conf, spark_log_level, redirect_spark_log)
    642 
    643     if isinstance(conf, six.string_types):
--> 644         sc = getOrCreateSparkContext(conf=None, appName=conf)
    645     else:
    646         sc = getOrCreateSparkContext(conf=conf)

/opt/work/bigdl-2.1.0/python/bigdl-spark_3.1.2-2.1.0-python-api.zip/bigdl/dllib/nncontext.py in getOrCreateSparkContext(conf, appName)
    684             if appName:
    685                 spark_conf.setAppName(appName)
--> 686             return SparkContext.getOrCreate(spark_conf)
    687         else:
    688             return SparkContext.getOrCreate()

/opt/work/spark-3.1.2/python/lib/pyspark.zip/pyspark/context.py in getOrCreate(cls, conf)
    382         with SparkContext._lock:
    383             if SparkContext._active_spark_context is None:
--> 384                 SparkContext(conf=conf or SparkConf())
    385             return SparkContext._active_spark_context
    386 

/opt/work/spark-3.1.2/python/lib/pyspark.zip/pyspark/context.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    142                 " is not allowed as it is a security risk.")
    143 
--> 144         SparkContext._ensure_initialized(self, gateway=gateway, conf=conf)
    145         try:
    146             self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,

/opt/work/spark-3.1.2/python/lib/pyspark.zip/pyspark/context.py in _ensure_initialized(cls, instance, gateway, conf)
    329         with SparkContext._lock:
    330             if not SparkContext._gateway:
--> 331                 SparkContext._gateway = gateway or launch_gateway(conf)
    332                 SparkContext._jvm = SparkContext._gateway.jvm
    333 

/opt/work/spark-3.1.2/python/lib/pyspark.zip/pyspark/java_gateway.py in launch_gateway(conf, popen_kwargs)
    106 
    107             if not os.path.isfile(conn_info_file):
--> 108                 raise Exception("Java gateway process exited before sending its port number")
    109 
    110             with open(conn_info_file, "rb") as info:

Exception: Java gateway process exited before sending its port number

fatenlouati avatar Dec 10 '22 13:12 fatenlouati