Sign inSign up

mattf/spark

By mattf

Updated almost 4 years ago

Image
0

2.1K

mattf/spark repository overview

Usage examples

Single node with one or more GPUs

docker run -it --gpus all mattf/spark:alpha-... spark-shell --master spark://localhost:7077

At the Scala REPL, try...

scala> val df = spark.range(1, 100).select($"id" as "a").join(spark.range(1, 100).select($"id" as "b"), $"a" === $"b")
df: org.apache.spark.sql.DataFrame = [a: bigint, b: bigint]

scala> df.explain
== Physical Plan ==
GpuColumnarToRow false
+- GpuBroadcastHashJoin [a#2L], [b#6L], Inner, GpuBuildRight
   :- GpuProject [id#0L AS a#2L]
   :  +- GpuRange (1, 100, step=1, splits=64)
   +- GpuBroadcastExchange HashedRelationBroadcastMode(List(input[0, bigint, false])), [id=#25]
      +- GpuProject [id#4L AS b#6L]
         +- GpuRange (1, 100, step=1, splits=64)

scala> df.show
+---+---+                                                                       
|  a|  b|
+---+---+
|  1|  1|
|  2|  2|
|  3|  3|
...
only showing top 20 rows

Multiple nodes with one or more GPUs each

On your head node, which we'll call node0...

docker run -d -p 8080:8080 -p 7077:7077 mattf/spark:alpha-... start-master

On each of your worker nodes...

docker run -d --gpus all mattf/spark:alpha-... start-worker spark://node0:7077

After the cluster starts, connect to it with a Scala REPL...

docker run -it --net host --entrypoint spark-shell mattf/spark:alpha-... --master spark://node0:7077

Look at the web UI for the cluster...

open http://node0:8080

Kubernetes

Setup a service account that can manage pods (the executor pods)...

kubectl create rolebinding default --clusterrole=edit --serviceaccount=default:default

Setup a headless service so executor pods can find the driver pod. The name of this service must match the name of your driver pod (below)...

kubectl create service clusterip mydriver --clusterip=None
kubectl set selector service/mydriver run=mydriver

Run a spark-shell as your driver, remember the pod's name must match the service (above)...

kubectl run -it mydriver --image=mattf/spark:alpha-... --command -- spark-shell --master k8s://kubernetes

Tag summary

Content type

Image

Digest

sha256:6db4c29c5

Size

2.5 GB

Last updated

almost 4 years ago

docker pull mattf/spark:alpha-3.3.0-hadoop3-accelerator22.10.0