Running Hail on AWS


#1

Hi, I’m a spark newbie and trying to get started using Hail on AWS/EMR. I’ve followed many of the suggestions on this forum, and I can build Hail for Spark 2.2.0 on EMR 5.10.0 When I run pyspark from an ssh connection to the master node, I get an error when calling hl.init():

pyspark --jars hail-all-spark.jar \
--py-files hail-python.zip \
--conf spark.driver.extraClassPath=./hail-all-spark.jar \
--conf spark.executor.extraClassPath=./hail-all-spark.jar \
--conf spark.sql.files.openCostInBytes=1099511627776 \
--conf spark.sql.files.maxPartitionBytes=1099511627776 \
--conf spark.kryo.registrator=is.hail.kryo.HailKryoRegistrator

...
>>> hl.init()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-58>", line 2, in init
  File "/home/hadoop/hail-python.zip/hail/typecheck/check.py", line 546, in wrapper
  File "/home/hadoop/hail-python.zip/hail/context.py", line 177, in init
  File "<decorator-gen-56>", line 2, in __init__
  File "/home/hadoop/hail-python.zip/hail/typecheck/check.py", line 546, in wrapper
  File "/home/hadoop/hail-python.zip/hail/context.py", line 65, in __init__
  File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py", line 1133, in __call__
  File "/usr/lib/spark/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py", line 319, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling z:is.hail.HailContext.apply.
: org.apache.spark.SparkException: Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.driver.allowMultipleContexts = true. The currently running SparkContext was created at:
org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:58)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:247)
py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
py4j.Gateway.invoke(Gateway.java:236)
py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
py4j.GatewayConnection.run(GatewayConnection.java:214)
java.lang.Thread.run(Thread.java:748)
        at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$2.apply(SparkContext.scala:2472)
        at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$2.apply(SparkContext.scala:2468)
        at scala.Option.foreach(Option.scala:257)
        at org.apache.spark.SparkContext$.assertNoOtherContextIsRunning(SparkContext.scala:2468)
        at org.apache.spark.SparkContext$.markPartiallyConstructed(SparkContext.scala:2557)
        at org.apache.spark.SparkContext.<init>(SparkContext.scala:85)
        at is.hail.HailContext$.configureAndCreateSparkContext(HailContext.scala:102)
        at is.hail.HailContext$.apply(HailContext.scala:225)
        at is.hail.HailContext.apply(HailContext.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:280)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:214)
        at java.lang.Thread.run(Thread.java:748)

I’m guessing this means I’m somehow trying to create two spark contexts, or perhaps already have one running somewhere else (zeppelin)? Do you have suggestions? Thanks


#2

Try hl.init(sc)


#3

Do that if pyspark gives you a spark context. The rules aren’t super clear around that though


#4

That helps, I got a new error (below for reference), but I was able to get around that with an updated pyspark command (also below).

New error message

>>> import hail as hl
>>> import hail.expr.aggregators as agg
>>> hl.init(sc)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-58>", line 2, in init
  File "/home/hadoop/hail-python.zip/hail/typecheck/check.py", line 546, in wrapper
  File "/home/hadoop/hail-python.zip/hail/context.py", line 177, in init
  File "<decorator-gen-56>", line 2, in __init__
  File "/home/hadoop/hail-python.zip/hail/typecheck/check.py", line 546, in wrapper
  File "/home/hadoop/hail-python.zip/hail/context.py", line 65, in __init__
  File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py", line 1133, in __call__
  File "/usr/lib/spark/python/pyspark/sql/utils.py", line 63, in deco
    return f(*a, **kw)
  File "/usr/lib/spark/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py", line 319, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling z:is.hail.HailContext.apply.
: is.hail.utils.HailException: Found problems with SparkContext configuration:
  Invalid configuration property spark.serializer: required org.apache.spark.serializer.KryoSerializer.  Found: empty parameter.
        at is.hail.utils.ErrorHandling$class.fatal(ErrorHandling.scala:9)
        at is.hail.utils.package$.fatal(package.scala:26)
        at is.hail.HailContext$.checkSparkConfiguration(HailContext.scala:122)
        at is.hail.HailContext$.apply(HailContext.scala:227)
        at is.hail.HailContext.apply(HailContext.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
        at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
        at py4j.Gateway.invoke(Gateway.java:280)
        at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
        at py4j.commands.CallCommand.execute(CallCommand.java:79)
        at py4j.GatewayConnection.run(GatewayConnection.java:214)
        at java.lang.Thread.run(Thread.java:748)

By changing the pyspark command to include the spark.serializer property:

pyspark --jars hail-all-spark.jar \
--py-files hail-python.zip \
--conf spark.driver.extraClassPath=./hail-all-spark.jar \
--conf spark.executor.extraClassPath=./hail-all-spark.jar \
--conf spark.sql.files.openCostInBytes=1099511627776 \
--conf spark.sql.files.maxPartitionBytes=1099511627776 \
--conf spark.kryo.registrator=is.hail.kryo.HailKryoRegistrator \
--conf spark.serializer=org.apache.spark.serializer.KryoSerializer

I can now get the hail logo:

>>> import hail as hl
>>> import hail.expr.aggregators as agg
>>> hl.init(sc)
Running on Apache Spark version 2.2.0
SparkUI available at http://ip-172-31-20-18.us-west-2.compute.internal:4041
Welcome to
     __  __     <>__
    / /_/ /__  __/ /
   / __  / _ `/ / /
  /_/ /_/\_,_/_/_/   version devel-0f2f908dccaa
NOTE: This is a beta version. Interfaces may change
  during the beta period. We recommend pulling
  the latest changes weekly.

Thanks!


#5

thanks for posting the error even though you figured it out! will certainly help others in the future