{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Setting up stat-nlp-book on Microsoft Azure\n", "\n", "It's exciting to live in future where you can create your own virtual machine (VM) far away from you, somewhere in a remote server farm, and make it do your bidding, like setting up an environment to have your own private stat-nlp-book. This is exactly what we're going to do with this short tutorial.\n", "\n", "But first:\n", "\n", "## DISCLAIMER\n", "\n", "This setup is NOT required\n", "Be careful when registering with Microsoft Azure. As UCL students you have \\$25 per month to spend there, but to register you need to provide your card number. Be 100% sure you know what you're doing as we're not responsible if you manage to spends too much money there. The free \\$25 should be enough for your standard usage. We're trying to make this tutorial as easy as possible, but interfaces might change, as well as the procedure, so be wary of any deviations and proceed at your own responsability.\n", "\n", "\n", "\n", "## Registering for your monthly credit (UCL students only)\n", "\n", "Head to [my.visualstudio.com](https://my.visualstudio.com):\n", "\n", "![](../img/azure_tutorial/1.png)\n", "\n", "...where you will enter your UCL mail of form ucxxxxx@ucl.ac.uk and click on **Continue**. Microsoft will recognise the UCL e-mail doman and greet you with a personalised UCL background:\n", "\n", "![](../img/azure_tutorial/2.png)\n", "\n", "...where you should enter your password and **Sign in**.\n", "You should be inside the Visual Studio Dev Essentials now:\n", "\n", "![](../img/azure_tutorial/3.png)\n", "\n", "There you will proceed to activate your £20 monthly credit for 1 year on Azure by clicking on **Activate**. In the following screen you will be greated with a request for personal info, including credit card info. Please study this in detail- your credit card should not be charged for this offer unless you explicitly remove the spending limit. However, please re-check everything as we are not responsible if you spend your own money on Azure.\n", "\n", "If you are fine with proceeding, after you input your data, agree to the usage agreement, and click on **Purchase**.\n", "\n", "![](../img/azure_tutorial/4.png)\n", "\n", "After entering your data, you will have to wait a few minutes until Microsoft Azure gets set up (grab some fresh air, Tweet about how you're setting up Azure or check the static stat-nlp-book so you stay on top of everything). When the setup finishes, click on **Start managing my service >** and in a moment you should be seeing Microsoft Azure dashboard.\n", "\n", "![](../img/azure_tutorial/5.png)\n", "\n", "## Virtual machine setup\n", "\n", "The previously shown Microsoft Azure dashboard (later easily available via [https://portal.azure.com](https://portal.azure.com)) is the place where we will set up our VM:\n", "\n", "\n", "### Choosing a machine\n", "\n", "Click on the **green + sign**, then **Compute**, and select **Ubuntu Server 16.04 LTS** as shown here:\n", "\n", "\n", "\n", "You are also free to experiment with Windows Server 2012 if you wish, and remotely connect to it, but we won't do that in this tutorial.\n", "\n", "On the following screen, select **Resource Manager** as deployment model and click on **Create**:\n", "\n", "\n", "\n", "On the following screen, we need to configure some standard settings, grouped in 4 groups - Basics, Size, Settings, and Summary\n", "\n", "On **Basics** you should set the options like this:\n", "- **Name** - name of your VM (e.g. stat-nlp-book)\n", "- **VM disk type** - disk type, HDDs are cheaper\n", "- **User name** - user name you will use to log in, we'll refer to this as **USER_NAME**\n", "- **Authentication type** - it's easier to go with **Password**, but go with **SSH public key** if you know what you're doing\n", "- **Password** - your login password\n", "- **Subscription** - should be set to **Developer Program Benefit** (your free UCL stuff)\n", "- **Resource group** - create a new one, name it whichever way you want (e.g. stat-nlp-book, ucl-stuff, komputrz...)\n", "- **Location** - having a Developer Program Benefit, you are limited to specific locations. **West Central US** should give you cheapest option.\n", "\n", "\n", "\n", "Once you enter your data, click **OK** to go to the next sub-menu, **Size**, where you will need to pick your machine size. By clicking **View all**, you can see all the available machines. You will need a machine with at least 3GB of disk space.\n", "\n", "\n", "\n", "By clicking ok on **Select** you will be brought to the **Settings** sub-menu. You can leave the values there as given by default and click on **OK**.\n", "\n", "The final, **Summary** sub-menu gives you a summary of your chosen options. If you agree with the following, click on **OK**.\n", "\n", "The dashboard will submit your request and deploy the machine in a matter of minutes. When this is done, you should see your machine up and running like this:\n", "\n", "![](../img/azure_tutorial/10.png)\n", "\n", "However, before installing the stat-nlp-book, we need to ensure that we can access Jupyter notebooks by permitting incoming connections on Jupyter's standard port (8888).\n", "\n", "\n", "### Setting up the firewall\n", "\n", "Click on your newly deployed VM to get to the overview menu:\n", "\n", "\n", "\n", "Over there, first remember your Public IP address (as in the image). We'll refer to it as IP_ADDRESS.\n", "Then click on the name of your resource group (stat-nlp-book in the image) to get to the resource group menu:\n", "\n", "\n", "\n", "In the resource group menu, click on your Network security group (stat-nlp-book-nsg in the image above):\n", "\n", "\n", "\n", "In the Network security group menu, click on Inbound security rules, and click on **Add**.\n", "\n", "\n", "\n", "On the following screen you need to set the following properties:\n", "- **Name** (e.g. Jupyter)\n", "- **Priority** (you can leave this as is)\n", "- **Source** (Any)\n", "- **Protocol** (TCP)\n", "- **Port range** (8888)\n", "- **Action** (Allow)\n", "\n", "as this:\n", "\n", "\n", "\n", "Click on **OK**, wait until the rule is set, and go back to your VM overview.\n", "\n", "Your machine is now running and waiting for you to install the stat-nlp-book.\n", "\n", "\n", "### Installing stat-nlp-book\n", "\n", "Connect to your virtual machine with ssh:\n", "\n", "```\n", "ssh USER_NAME@IP_ADDRESS\n", "```\n", "\n", "Follow the instructions from [here](https://github.com/uclmr/stat-nlp-book) with a few twists:\n", "\n", "Git is already installed, so you can clone the stat-nlp-book repository:\n", "\n", "```\n", "git clone https://github.com/uclmr/stat-nlp-book.git\n", "cd stat-nlp-book\n", "```\n", "\n", "Install docker:\n", "\n", "```\n", "sudo apt install docker.io\n", "```\n", "\n", "and proceed with pulling the docker container, with a twist: when calling docker, always call it through sudo:\n", "\n", "```\n", "sudo docker pull riedelcastro/stat-nlp-book\n", "```\n", "\n", "When that is done, download data required by the book:\n", "\n", "```\n", "sudo docker run -p 8888:8888 -v $PWD:/home/jovyan/work riedelcastro/stat-nlp-book scripts/download_data.sh \n", "```\n", "\n", "and finally run the book:\n", "\n", "```\n", "sudo docker run -p 8888:8888 -v $PWD:/home/jovyan/work riedelcastro/stat-nlp-book \n", "```\n", "\n", "\n", "Connect to Jupyter on your VM by typing IP_ADDRESS:8888 in your browser...and voila:\n", "\n", "\n", "\n", "The book is up an running. Now you have your own (temporary) dedicated machine for stat-nlp-book-ing, how awesome is that? :)\n", "\n", "\n", "### Shutting down your machine\n", "\n", "In order to release unused computational power, and save some credits/money, when you're done with your computation, just go back to your VM overview, and stop your machine by pressing the **Stop** button. BEWARE: any unsaved data WILL BE LOST! Be 100\\% sure that you saved all the changes you made.\n", "\n", "And that's it, happy coding!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.0" } }, "nbformat": 4, "nbformat_minor": 0 }