Setting up DeepLearning Machine and fast.ai on Azure
In this post, I will go through the happy path for setting up a deep learning machine in Microsoft Azure. This will be beneficial for people who want to set up a deep learning machine easily on Azure(Without going through all the graphics driver, CUDA, and deep learning libraries installation).The latter part of this post will be targeted for setting up fast.ai course content and libraries on Azure. I am part of the fastai deep learning 2017 course as an international fellow. This course content will be available to the general public early 2018 as a MOOC.
Deep Learning Virtual Machine
Virtual machine images contain all the required environment for various tasks. One can deploy them and get up and running straight away. Amazon AWS has AMI for this purpose. Similarly Azure offers virtual machine images.
The one we are interested in is Azure Deep Learning Virtual Machine(DLVM) part of the Azure Data Science Virtual Machines(DSVM). It was released mid-2017. Please go to the below page to get an idea of what it offers.
The Deep Learning Virtual Machine (DLVM) is a specially configured variant of the Data Science Virtual Machine(DSVM) to…azuremarketplace.microsoft.com
In short, it has almost all the tools required to get you started in deep learning. We will refer it as VM for the rest of the article.
Visual Studio Subscription
If you have a visual studio subscription then I have a good news for you. At the time of this writing, you can enable the benefit of monthly Azure credits. You can use those credits for your VM costs. You have to select this subscription while creating your virtual machine.
Please visit this link for more details and how to activate the benefit.
- Create an Azure account at https://portal.azure.com.
- Follow the steps listed in this official document. It should take only 5 mins if NC series machines are already enabled for your account. I will cover the important fields below.
- OS Type: Windows and Linux variants are available. I am using the Linux variant. All the information on this post is based on my Linux variant VM.
- Subscription: Select the subscription on which you want to be billed. For people with visual studio subscription, if you want to use your monthly credits for this VM make sure you select your visual studio subscription for this field.
- Location: Only some regions have NC6 machines. So you need to pick one of the regions listed in the official document that suits your requirement.
- In the next step, you will need to choose one of the NC series models.NC6 is the cheapest one in NC series and it costs around 0.90 $ /hour (Linux variant) in EastUS region.
- If you find out that NC series are greyed out and not available to select, Please refer the below section on how to enable them.
Note: Virtual machine pricing depends on region and instance types. You are advised to refer here for proper pricing information.
Enabling NC Series
1. Azure Deep Learning Virtual Machines can be only deployed on Azure NC series virtual machines. By default, it’s not enabled( at least for me). So one needs to raise a support request to get them enabled on your ID.
2. Please note this is only needed if you observe the NC series options are greyed out during the process of our deployment. You might see a message like “Not available for the current subscription”
3. It may take some time depending on the availability of NC series machines.
4. Once NC series are enabled on your ID, you can easily create your VM.
Dealing with the VM
You can manage your machines from the virtual machines tab.
You can then select the VM you want, to open a detailed view of that VM.
Using the above tab, you can control your VM. “Connect” will show the details required for SSH login to your instance. “Start” will help to boot up your VM whenever you want to use it. And make sure you use “Stop” when you are not using it. You will be billed for the time your VM is in running state.
Connecting to your instance
You can connect to your instance using ssh with the below command.
ssh -L 8888:127.0.0.1:8888 username@ip
-L 8888:127.0.0.1:8888 is used for SSH tunneling which helps us to connect to our jupyter notebook server on our remote VM from our local browser.
username@ip replace this with your details from “Connect” tab which was shown in the previous image.
You will be prompted for the password. Upon completion, you will have the terminal of your VM. You can play and move around to see the examples and tutorials this VM is loaded with to get you started.
Launching Jupyter Notebooks
As jupyter is already installed in our VM. You can straight away run the jupyter server to serve you notebooks. To start the jupyter server, you can run the following command.Note that instead of running the server from notebooks you can run from any folder location from which you want your notebooks to be served.
You should see something like the below image on the screen.
Copy the URL+Token from the command line and enter in your local browser to view the jupyter notebooks. You can play with the sample notebooks which are already present.
That’s it for the setup and should be enough to get you going :)
Note: All the above information is what I observed at the time of writing this post. These things might change in future and some of them may be wrong. You are advised to always refer to the official documents.
Setting up fast.ai
- The official readme has the instructions required to set up the fastai.
- Follow the steps listed on your VM and activate your fastai environment.
- Once activated you can install the appropriate kernel by the following command. More information on this here.
pip install ipykernel
python -m ipykernel install — user — name fastai — display-name “Python (fastai)”
4. You can keep any name you like for the kernel instead of “Python (fastai)”.
5. The above steps would add fastai kernel to jupyter notebooks.
6. You can change the kernels of your notebook as shown in the following image.
7. With the above kernel, you will be able to run your fastai notebooks.
9. Launch jupyter notebook from there as explained earlier and change your kernel to fastai kernel. You can then run all the lessons notebooks and experiment with them.
The fastai library is also available through pip. And you can install it using “pip install fastai” as mentioned in the official readme. This will help if you want use fastai as a library in any of your environments or projects.
Update for fast.ai 2018 course
All the above mentioned steps remain same except for fast.ai installation.The github readme has updated instructions.
Happy Deep Learning :)