This is being written to address the current "bug" or malfunction in promo code generation for AWS Educate credits. Overall, the functionality of both the AWS and Azure instances are equivalent. There are a couple differences that result from the architectures for both services varying, but most of the work has been done to ensure that nothing tedious is left up to the student.
Make sure that you run through the GPU and non-GPU instance setup once (although the GPU instance should only be created once it is needed as you only have 250 hours of metered usage). The GPU instance will be used solely for training as it has significantly higher costs to run than the non-GPU instance. As with the AWS setup, instances must be completely freed (terminated) and not just stopped as they charge you for the apportionment and not just the processing (hence the "Pay-As-You-Go" scheme).
Finally, Azure has a strict one VM allocation quota. In practice, this means that you will need to juggle between the GPU and non-GPU instance creation in order to properly satisfy all of the project requirements. To make sure you do not lose data, make sure that you do not terminate the instance before committing and pushing your work to the remote using git. Finally, be aware that the GPU instance is only required for the final parts of this project where training occurs. Before then, you are free to use the non-GPU instance to do all of your work.
Follow the steps in the AWS process for the Github student pack as the promo code it generates is still required for this process.
After querying for the promo code, click on the link from Microsoft and register for an Azure student account (Follow the Activate Now button on the Azure for students page. Note that since Azure is a subscription-based service, you will only be able to access your student account for a year from when you registered. At that time, any apportionment made towards your account (VMs/Storage/etc.) will either be deleted or transferred to another Azure service account.
After you are done with the sign-up process (it does not take too long and does not require any CC info unlike AWS), you may use the portal link to access your account once signed in. You may want to bookmark this page as there isn't really an efficient way of getting to the portal without going through the student sign-up page and waiting for the redirect.
This part is largely taken from the AWS instance connection page. Like I said, there is pretty much almost no difference between the way you connect to the instance if you set it up other than the lack of the need to provide the SSH key. the reason for this is because once a user generates a key pair, the assumption is that the user will automatically place the private key in a place where the SSH agent can see it upon secure connection.
Unix users have it easy for this section of the setup. Since ssh and scp are provided by default on all Linux distributions and OSX, there is no need for a specialized FTP/SSH program. In order to access the server directly, you will need to keep note of either the public IPv4 DNS or the public IPv4 IP address. Either one can be used as a means of connecting to your machine, but the public DNS makes it obvious what instance you are trying to access. To access the server interactively through the terminal, run the following command while replacing the bracketed parts with what is expected to be there:
ssh [user]@[public IPv4 address/DNS] For the Azure instance, you will need to use the username (and password, if not using the SSH key) that you chose for either instance. If you are unsure what the public IPv4 address is for the instance, navigate to the "Virtual Machines" section of the Azure panel, and select the name of the instance which you would like to access. On the top bar, you will see a "Connect" button that when selected will bring up a pane with the appropriate ssh command using the IPv4 address. It should look as follows:
Of course, all of this is done with the assumption that IF you used an SSH key pair, then it should be located within your ssh key folder (usually ~/.ssh/). For convenience, most guides recommend that you generate the SSH key pair within that folder so all that needs to be done is to upload the public key.
On Windows, you must use either PuTTY or MobaXterm in order to access your instance (unless you have pre-installed the GNU toolset via some terminal emulator). Here, I will cover the instructions for installation for both briefly. The reason is because this setup is quick for either option. Note that when using MobaXterm you will also be able to transfer files directly onto the instance. So, if you are planning to move files back and forth without using Git, it may be a good idea to use MobaXterm anyway. To start, open the connect pane using the method shown above. Then, using the username and IPV4 address...
In order to connect to an Azure instance via MobaXterm, you can either start the terminal emulator and use the ssh command found in the Linux section immediately above this one, or create a new connection using the top left new session button. Use the following image as an example session configuration given the connection pane shown above...
Be aware that if you used the SSH key method, then you must select the "Use private key" box and provide the proper private key file to MobaXterm. Be aware that the program requires the key in a specific format, so a file generated by PuTTYgen may not necessarily be in the correct format.
On the other hand, if you would like to use PuTTY in order to ssh into the server, then you may use the following settings in order to do so:
Like with MobaXterm, if an SSH key pair wasn't used, then you can simply ignore the process of adding it. When not using an SSH key pair, the connection will simply prompt you for the password which you created during the instance creation.
At the portal page, dismiss all of the tutorial dialog boxes and navigate to the "Virtual machines" section of the pane. In the center should be a "Create virtual machine" button. You will be taken to a pane with a bunch of settings that are required before being able to use the instance. The subscription entry should be pre-filled with the "Azure for Students" account. In the sub-selection under "Resource Group", create a new resource group and call it whatever you like. Preferably, you would want to give it a name where it would be easy to identify as a GPU instance. When terminating the instance, deleting the resource group will be the easiest way to deallocate all of the VM's resources.
In the next section, you will be filling out the details of the instance being used. This will allow you to choose the server location, redundancy options, drive image, and allocation size. Feel free to name the instance whatever you like (as long as you can differentiate between the GPU/non-GPU instance). Set the server location to (US) West 2. Then, set the image to the Ubuntu Server 18.04 LTS (This is usually the default). Next, change the instance size to the NC6_Promo type. You can search for the instance type through the Change Size button under the currently selected size. That is all that is needed for this section.
Under the administrator account portion, you are free to choose whether you would like to use an SSH key or regular password for access to the server. You are free to choose whatever username you like as well, but just know that the default is ubuntu. Note that unlike the AWS instance which provides you with the private key and sets up the public key beforehand, it is up to the user to generate an SSH key and paste the public key counterpart into the SSH public key entry. If you decide to go for the SSH route on Windows, then you will need to use PuTTYgen in order to generate the SSH key.
Finally, the last section allows you to set up some basic network inbound exceptions for your provision. Allow some inbound ports by selecting the "Allow selected ports" option and then enabling the SSH port, 22.
Now click "Next" and change the OS disk type to "standard SSD" if it has defaulted the the premium setting. This should lower some of the operating costs of the system. This is all that needs to be configured. Click on the "Review + Create" button and check to make sure that everything looks as the following image displaying the final setup page. If everything is fine, you may create your GPU provision. Provision creation usually takes about 5 minutes or less, but it does vary depending on the general load on Azure and can take up to 20 minutes on a bad day.
After some work, a script has been created that automatically manages all of the packages required! The script can be found in the project repository page under the /setup/azure/ directory. The bash script contained within this folder can be easily executed in the bash shell once students have ssh access. For more information on how to ssh into an instance, consult the above section. After accessing the terminal remotely through SSH...
In general, the process would include cloning the origin repository on the provisioned instance:
git clone https://github.com/ProjectInABox/face-recognitionAfter which, the bash script within the proper directory will be executed as follows:
cd face-recognition/setup/azure/./azure_nvidia_install.shFeel free to look at the script. Note that a success would result in a final call to Python to test for the GPU. If the final output is a "1", then the installation has successfully taken place. If you have any questions regarding whether or not the process succeeded or not, feel free to ask the tutor in charge. I suggest removing the generic project repository afterward as you will need to clone your own repository as well. The instructions regarding the rest of the project can be found in the main Face Recognition page. Simply skip all of the AWS section!
Given that the instructions for the non-GPU instance usage are almost exactly the same as that of the GPU instance except for two instances, I will simply write down the differences in this section. In the first page regarding instance details, make sure to use a resource name and instance name that makes it obvious that it is the non-GPU instance. The exceptions are as follows:
After the changes are made feel free to select "Review + Create" and check that all the settings look as intended. If not, go back and change it. Note that the hourly cost for this network allows for about 1500 hours of continuous execution, or about 62.5 days, given the initial $100 credit. This means that you will likely be fine running this server constantly, but DO NOT forget that the server is running or you will be unable to use the credits for a future project!
NOTE: There's a mistake in the right-hand image! The destination port in this case should be PORT 8080!
Unfortunately, the non-GPU instance also requires a bit of setup before it can be used. However, we are lucky given since there is no GPU that is needed; that is, the installations should all be readily available in the software repositories provided by Ubuntu and pip because of the lack of specialized hardware. So, run the following commands in order to acquire all the necessary Python modules and software (Note that you should be using Python 3 whenever possible as Python 2 will no longer be actively maintained soon.):
sudo apt-get updatesudo apt install -y python3-pip libxrender1 libsm6 libxext6sudo pip3 install keras tensorflow opencv-python flask flask_corsAnd that's it! You should be able to properly setup the server on the non-GPU server and train the network on the GPU server now. Like I said before, since you are only limited to 100 hours with Azure (effective 2/3 credits compared to AWS), you will need to be adept and use Git to store any files that you may need for the next launch. Since the non-GPU instance is fairly cheap, you can leave the instance on for a couple days or weeks (but don't forget about it!).
Once students have finished to use a specific instance, it is highly recommended that the instanced be completely terminated. The reason for this is that the fees for using the instance continue to accrue regardless of whether the instance is in use and on, or not in use (even off!). Clearly, that is something that should be taken care of given that the GPU instance costs upwards of $.40 per hour. There is much more than 250 hours of time in the next three months, and failures to terminate the instance could result in a failure to complete the project. (Basically, you are on your own if you have to consult with the Azure CS team in order to acquire more credits as a result of a user mistake.)
Luckily, the process for instance termination is just as simple as it is in AWS EC2. On the management panel, select the "Resource groups" button to open the resource groups pane. In this new pane, select the resource group name that you used for the instance's creation. Once you have found and selected the instance's resource group name, you can then use the top bar's "Delete resource group" button to delete the resource group. Note that since this option is irreversible, it will ask you to type the resource name out before you can select the "Delete" button. The picture as follows shows the step before deletion:
Like instance creation, deletion can take a while. The average time for instance deletion is about 5 minutes, although it can vary depending on the size of the disk that was allocated (by default it is 15GB-50GB depending on the instance type).
This is the end of the Azure usage section. You can say that Azure is effectively an alternative to AWS EC2, but the difference is that Microsoft offers different "subscriptions" that give the users different permissions/quotas when using their service. It is perfectly fine for basic usage, but student usage is quite limited as a result of this subscription + pay-as-you-go service design.
Should you run into any problems or have some questions regarding this process, make sure to bring them up on Piazza!
This marks the end of this sub-tutorial. Please navigate back to the main Face Recognition page in order to complete the rest of the tasks...