Running BigDL Apache Spark Deep Learning Library on Microsoft Data Science Virtual Machine

This post is co-authored by Gopi Kumar at Microsoft and Sergey Ermolin at Intel.


BigDL is a distributed deep learning library for Apache Spark. It has both Python and Scala interfaces and takes advantage of Spark-enabled distributed compute infrastructure, allowing users to write Deep Learning applications in a familiar native Spark context format. The Microsoft Data Science Virtual Machine (DSVM) is a customized VM image on Azure built specifically for doing data science and deep learning. It has many popular AI and data science tools pre-installed and pre-configured, helping jump-start the process of building intelligent apps that use predictive analytics and deep learning. DSVM is available on Windows Server 2012 and on Linux in both Ubuntu and CentOS7 editions.

This post shows how BigDL can be easily integrated into DSVM for Linux, and provides an example with LeNet5 character recognition implementation in Python. We first provide manual setup steps and then an automated mechanism to deploy BigDL on the DSVM with just a few clicks or commands. 

Provisioning DSVM

Before you start, you need to provision DSVM for Linux (Ubuntu) by visiting the product detail page and following the directions in the VM creation wizard:


When DSVM is configured, please make a note of its public IP address OR DNS name – you will need this to connect to DSVM via your connect tool of choice. The recommended tool for text interface is SSH or Putty. For a graphical interface, Microsoft recommends an X Client called X2GO.

NOTE: You may need to set up the proxy correctly if your network administrators require all connections to go through your network proxy. The only session type supported by default on DSVM is XFCE.

PuTTY Config

X2GO Config

Building BigDL

Invoke 'sudo' root privileges and clone BigDL from GitHub:

sudo -s
cd /opt
git clone

Build BigDL with Spark 2.0:

$ cd BigDL
$ bash -P spark_2.0

In the end, you should see these messages:

Note: The above screenshot shows BIgDL installed in a user's home directory. Installation in /opt would look the same.

Running a BigDL Example

DSVM Configuration Steps to Run BigDL Examples

Switch to Python-2.7

$ source /anaconda/bin/activate root

Confirm python version

$ python - - version

Install Python Packages

$ /anaconda/bin/pip install wordcloud
$ /anaconda/bin/pip install tensorboard

Creating script files to run Jupyter notebook and TensorBoard

In the directory where you cloned BigDL library (/opt/BigDL or ~/BigDL, depending on your choice), create a script, with the following content:

#setup paths

#this is needed for MSFT DSVM
export PYTHONPATH=${BigDL_HOME}/pyspark/dl:${PYTHONPATH}
#end MSFT DSVM-specific config

#use local mode or cluster mode
export PYSPARK_DRIVER_PYTHON_OPTS="notebook --notebook-dir=~/notebooks  --ip=* "

source ${BigDL_HOME}/dist/bin/

${SPARK_HOME}/bin/pyspark \
--master ${MASTER} \
--driver-cores 5  \
--driver-memory 10g  \
--total-executor-cores 8  \
--executor-cores 1  \
--executor-memory 10g \
--conf spark.akka.frameSize=64 \
--properties-file ${BigDL_HOME}/dist/conf/spark-bigdl.conf \
--py-files ${PYTHON_API_ZIP_PATH} \
--jars ${BigDL_JAR_PATH} \
--conf spark.driver.extraClassPath=${BigDL_JAR_PATH} \
--conf spark.executor.extraClassPath=bigdl-0.1.0--jar-with-dependencies.jar

# end of

chmod +x

In the same BigDL directory, create with the following content:

/anaconda/lib/python2.7/site-packages/tensorboard/tensorboard -

Please, note that '/anaconda/lib/python2.7/site-packages/' is installation-dependent and may change in future releases of DSVM. Thus, if these instructions do not work out-of-the-box for you, you may need to update this path.

Note the URL printed out at the end of the log: "" and open your DSVM browser with it to see the TensorBoard pane.

Launching a Text Classification Example

Execute and via bash commands from different terminals:


Open two browser tabs, one for text_classification.ipynb and another for TensorBoard.

Navigate to text_classification example:


Run the notebook. Will take a few minutes and in the end, you will see a loss graph like this:

Here's what your TensorBoard may look like, for the Text Classification example:


Automating the Installation of BigDL on DSVM

Azure Virtual Machines provide a mechanism to automatically run a script during the post provisioning when using Azure Resource Manager (ARM) templates. We have published the ARM template and the script to install BigDL on the DSVM for Linux (Ubuntu) when creating the VM on Azure at this GitHub location. On the same GitHub directory, there is also a "Deploy to Azure" button that will take the user to the Azure portal wizard and them through VM creation, automatically executing the above script to install/configure BigDL, so it's ready for use right after the VM is successfully provisioned.

The user can directly run /opt/BigDL/ to start a Jupyter notebook server to execute the samples.


In this post, we demonstrated that, with just a few small steps, one can leverage the Apache Spark BigDL library to run deep learning jobs on the Microsoft Data Science Virtual Machine.

BigDL continues to evolve and enjoys a solid support from open-source community as well as from Intel's dedicated software engineering team.

Gopi & Sergey

Additional Resources


Installing and configuring Spark-1.6 for legacy code implementation:

install Spark 1.6.1 WITH spark-2.0

Install spark 1.6.1:
Select 1.6.1.
cd Downloads
tar -xzf spark-1.6.1-bin-hadoop2.6.tgz

Move the directory from download location to where Spark is stored on the system.

To switch back to python 3.5 environment:

$source activate py35 (for Python 3.5)

To install Python packages Python 3.5 environment:

$sudo /anaconda/envs/py35/bin/conda install xxxx (for Python 3.5 env)

(Same for pip installs too)

Installing BigDL on Data Science Virtual Machine for Linux (CentOS):

We need to install Maven on the DSVM for Linux (CentOS) before compiling BigDL.

Installing Maven:

Note that on Cent-OS based Linux instead of Ubuntu's "apt-get" , you need to use "yum" to install new packages:

DSVM's default JAVA_HOME environmental variable points to an empty directory "/usr/lib/jvm/java-1.8.0-openjdk-"

You need to change it to another one (already existing) that contains Java 8 installation:

export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-"

Check that maven is installed correctly:

$ mvn –v

After this, you should be able to run a build on BigDL following the steps in the main section above.