I have created and attached a notebook to a GPU-enabled Databricks cluster (6.4 ML (includes Apache Spark 2.4.5, GPU, Scala 2.11), EC2 type: p2.xlarge).

I have started running the notebook that includes cells with PySpark/MLlib code for performing cross-validation and prediction using a Pipeline consisting of a VectorAssembler, MinMaxScaler, and GBTRegressor.

When I run this job it appears to be utilizing only CPU (Ganglia UI shows no GPU activity whatsoever, but plenty of CPU being used). Perhaps there is PyCpark code I need to add to my notebook and/or configuration settings for the cluster to allow for running this code with the help of my cluster's GPU?

I am new with Spark/MLlib, it's very possible that I am missing something obvious. Thanks in advance for any suggestions!


Spark itself does not use GPUs at all, so this is not surprising.

The operations it performs are at best L3 BLAS ops of moderate size, and most are small L1 operations, so generally a GPU isn't a win. It does use BLAS to accelerate those ops in hardware if a BLAS library like MKL or OpenBLAS is present.

  • $\begingroup$ Thank you, Sean. If this is the case then I wonder why Databricks even offers GPU-enabled instances for clusters? Surely it can't be just to take advantage of new users like me, right? Maybe GPUs are somehow useful with Databricks but just not for training ML models/pipelines? $\endgroup$ – James Adams Mar 23 '20 at 17:49
  • $\begingroup$ Oh, because frameworks that use GPUs most certainly run on Spark, like Tensorflow/Keras, Pytorch. You can run a Spark task that runs code that uses GPUs. You don't need to use Spark to use Databricks either. $\endgroup$ – Sean Owen Mar 23 '20 at 22:17
  • $\begingroup$ So then it's the Spark ML framework that can't leverage GPU(s), whereas TF/Keras, PyTorch, et al can? $\endgroup$ – James Adams Mar 24 '20 at 0:02
  • 1
    $\begingroup$ Yes, Spark itself is just the execution framework, so has no need of specialized hardware itself. Spark ML doesn't do enough large math that a GPU would make much difference (but it's not crazy); but yes you can imagine running workloads on Spark that very much do need a GPU. $\endgroup$ – Sean Owen Mar 24 '20 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.