.. _install-on-azure:

Install on Azure
----------------

This section describes how to install the Driverless AI image from Azure.

**Watch the installation video** `here <https://www.youtube.com/watch?v=aI16tA59lVU&index=5&list=PLNtMya54qvOE9fs3ylzaR_McnoUsuMV7X>`__. Note that some of the images in this video may change between releases, but the installation steps remain the same. 

Environment
~~~~~~~~~~~

+----------------------------+---------------+----------+-----------------+
| Provider                   | Instance Type | Num GPUs | Suitable for    |
+============================+===============+==========+=================+
| Azure                      | Standard_NV6  | 1        | Experimentation |
|                            +---------------+----------+-----------------+
|                            | Standard_NV12 | 2        | Experimentation |
|                            +---------------+----------+-----------------+
|                            | Standard_NV24 | 4        | Serious use     |
|                            +---------------+----------+-----------------+
|                            | Standard_NC6  | 1        | Experimentation |
|                            +---------------+----------+-----------------+
|                            | Standard_NC12 | 2        | Experimentation |
|                            +---------------+----------+-----------------+
|                            | Standard_NC24 | 4        | Serious use     |
+----------------------------+---------------+----------+-----------------+


Installing the Azure Instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. Log in to your Azure portal at https://portal.azure.com, and click the **Create a Resource** button.

2. Search for and select  **H2O DriverlessAI** in the Marketplace. 

 .. image:: ../images/azure_select_driverless_ai.png
    :align: center

3. Click **Create**. This launches the H2O DriverlessAI Virtual Machine creation process.

 .. image:: ../images/azure_search_for_dai.png
   :align: center

4. On the **Basics** tab:

  a. Enter a name for the VM.
  b. Select the Disk Type for the VM. Use HDD for GPU instances.
  c. Enter the name that you will use when connecting to the machine through SSH. 
  d. Enter and confirm a password that will be used when connecting to the machine through SSH.
  e. Specify the Subscription option. (This should be Pay-As-You-Go.)
  f. Enter a name unique name for the resource group.
  g. Specify the VM region.

  Click **OK** when you are done.

 .. image:: ../images/azure_basics_tab.png
   :align: center

5. On the **Size** tab, select your virtual machine size. Specify the HDD disk type and select a configuration. We recommend using an N-Series type, which comes with a GPU. Also note that Driverless AI requires 10 GB of free space in order to run and will stop working of less than 10 GB is available. We recommend a minimum of 30 GB of disk space. Click **OK** when you are done.

 .. image:: ../images/azure_vm_size.png
   :align: center

6. On the **Settings** tab, select or create the Virtual Network and Subnet where the VM is going to be located and then click **OK**.

 .. image:: ../images/azure_settings_tab.png
   :align: center

7. The **Summary** tab performs a validation on the specified settings and will report back any errors. When the validation passes successfully, click **Create** to create the VM.

 .. image:: ../images/azure_summary_tab.png
    :align: center

8. After the VM is created, it will be available under the list of Virtual Machines. Select this Driverless AI VM to view the IP address of your newly created machine. Then open a terminal window and ssh into the machine running the VM. Optionally run ``pwd`` to retrieve your current location in the VM, and optionally run ``nvidia-smi`` to verify that the NVIDIA driver is running.

9. If you selected a GPU machine, then enable persistence of the GPU. Note that this only needs to be run once. Refer to the following for more information: http://docs.nvidia.com/deploy/driver-persistence/index.html.

 :: 

   sudo nvidia-persistenced --user <USER>
   sudo nvidia-smi -pm 1

10. Use the following command to retrieve the latest Driverless AI version.

 ::

   wget dai-docker-centos7-x86_64-1.4.0-9.0.tar.gz

11. Set up the data, log, and license directories on the host machine:

 ::

    # Set up the data, log, license, and tmp directories on the host machine
    cd /etc/h2oai
    mkdir data
    mkdir log
    mkdir license
    mkdir tmp

12. At this point, you can copy data into the data directory on the host machine using ``scp``. For example:

 ::

   scp <data_file>.csv <username>@<vm_address>:/etc/h2oai/data

 The data will be visible inside the Docker container.


13. Load the Driverless AI Docker image

 ::

  docker load < dai-docker-centos7-x86_64-1.4.0-9.0.tar.gz


14. Start the Driverless AI Docker image:

 :: 

    # Start the Driverless AI Docker image
    nvidia-docker run \
        --pid=host \
        --init \
        --rm \
        --shm-size=256m \
        -u `id -u`:`id -g` \
        -p 12345:12345 \
        -v `pwd`/data:/data \
        -v `pwd`/log:/log \
        -v `pwd`/license:/license \
        -v `pwd`/tmp:/tmp \
        h2oai/dai-centos7-x86_64:1.4.0-9.0


 Driverless AI will begin running::

  --------------------------------
  Welcome to H2O.ai's Driverless AI
  ---------------------------------
       version: 1.4.0

  - Put data in the volume mounted at /data
  - Logs are written to the volume mounted at /log/20180606-044258
  - Connect to Driverless AI on port 12345 inside the container
  - Connect to Jupyter notebook on port 8888 inside the container

15. Connect to Driverless AI with your browser:

 ::

    http://Your-Driverless-AI-Host-Machine:12345


Stopping the Azure Instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Azure instance will continue to run even when you close the Azure portal. To stop the instance: 

1. Click the **Virtual Machines** left menu item. 
2. Select the checkbox beside your DriverlessAI virtual machine. 
3. On the right side of the row, click the ... button, then select **Stop**. (Note that you can then restart this by selecting **Start**.) 

.. image:: ../images/azure_stop_vm.png
   :align: center


.. include:: upgrade-azure-image.rst
