Life Of Navin

Random Musings, Random Bullshit.

kc

Deep Learning Setup QuickStart on AWS EC2

TL;DR: Use this gist and you're all set! The remainder of this post is a step-by-step for a newbie to Deep Learning/AWS

The Deep Learning ecosystem has matured tremendously over the last few months or so. I've been playing around with some of these applications over the same time period as well, and it's amazing how much the field has moved ahead in such a short time. Today, terms like Word2Vec, CNN and LSTMs have became part of the lingo of nearly every researcher, hobbyist or otherwise.



And of course, AWS makes running deep-learning applications possible at almost no cost. Especially if you lack a good GPU on your personal system, AWS is a godsend.  I've been working with some of these amazing frameworks so thought it might be good to automate the process of setting up a brand new EC2 instance with everything required to get up and running with deep learning. This includes:
So, let's get started:

1) Get yourself an AWS EC2 instance.
Go ahead and get yourself a new instance with an Ubuntu AMI (14.04/16.04 should be fine). Since we obviously we want to use the GPU instances, pick either g2.2xlarge or g2.8xlarge instance type. (Lost?)

2) SSH into the machine and either:
a) Download this zip file and extract it into the machine using:
$ curl "http://link_to_zip" -o dl_setup.zip 
and unzip the file using
$ unzip dl_setup.zip
b) Simply create the 3 files and copy the contents from the gist using your favorite editor. The 3 files are:

i) deep_learning_bootstrap.sh

This is a shell script which installs all the required dependencies and libraries required.


ii) test_install.sh

This is a shell script which tests to ensure that the install is successful.


iii) theano_test.py

This is a small python script which tests to ensure Theano is using the GPU for it's computations.


3) Next up run the following to ensure the shell scripts are executable:
chmod +x *.sh
4) Run the bootstrap script using:
./deep_learning_bootstrap.sh
 This will take some time (~5-10 minutes) to download and install all the dependencies.

If a pink screen pops up mentioning "A new version of /boot/grub/menu.lst is available", choose "Keep local version" and select OK.

Once everything is done, you should see the following message:
Reboot System (sudo shutdown -r 0) and run ./test_install.sh
5) Follow the instruction and run:
sudo shutdown -r 0
Your SSH connection will disconnect while your machine reboots. Wait for ~30 seconds and SSH back into the machine. You should see the prompt changed to:
ubuntu@D33P_L34RN $
6) Now run the test script to ensure everything has correctly installed:
./test_install.sh
Just look for the messages in green and ensure the output matches it.

And... that's it! You're all set to start developing your own deep learning applications on AWS EC2. Here's a set of examples you can get started with.

Happy coding! :)


Notes: Why both Theano and Tensorflow? Because choice. Honestly, thanks to Keras, using either as a backend is as simple as a string change. Also, most early to mid level posts in the field use one of the two with no strong monopoly, so it simply made sense to have both of them.  

Waldeinsamkeit.

Someday, I really want to use *Waldeinsamkeit* in a conversation. The word itself is nearly as beautiful as the emotion it represents. :)Sometimes, these perfect moments make you remember 
what an amazing journey you're on!
P.S. Thank you.
(Source)

Love (to Hate) Thy Neighbour!

Whoever, by words, either spoken or written, or by signs, or by visible representation, or otherwise, brings or attempts to bring into hatred or contempt, or excites or attempts to excite disaffection towards, the Government established by law in India, shall be punished with imprisonment for life, to which fine may be added, or with impris­onment which may extend to three years, to which fine may be added, or with fine.Honestly though, I think the sedition law was an archaic law for the period the movie was based in.
Yes, archaic... even in 1947.

To Hack Or Not To Hack?

Another weekend, another hackathon attended. But again, as has become common with the last few ones I've been to, something felt wrong. It's difficult to say what exactly, but something definitely felt off. End of the day, I returned home halfway through the hackathon, following my gut (or rather my team's gut), as always.

For those who don't know, a hackathon is an event where teams of coders developers hackers* sit for periods ranging from 12-48 hours and work on coding something cool from scratch. Hackathons are awesome, because they present a good way to test how well you can apply what you know in a small timeframe. The word hack itself, which today unfortunately generates a negative connotation, actually implies "an appropriate application of ingenuity".

your typical hackathon... hoodies + laptop stickers included

I've been participating in different hackathons for about 4 years now, and have been lucky enough to have been part of some of the best hackathons in the country. Especially over the last 8-10 months, we (Myself, Baka, Bhatta and CEO ... You either know them or you don't :P) have been super active on the Bangalore hackathon scene, having won quite a few big shot hackathons as well. In fact, IIIT-Bangalore (my M.Tech college) students are extremely active on the scene, and you'd be hard pressed to find a hackathon with zero representation from there.

In theory, hackathons have an unlimited upside:
  • You get to meet tonnes of like-minded people (Even in Bangalore, this is hard!)
  • You have a hard timeline (As a fresh graduate, I still suck at  doing things without timelines)
  • You get to work with cool stuff that interests you (Enuf said)
  • You get ideas/yourself validated (Judges are usually the who's who of the tech world)
  • Free food!! (Having to pay for stuff still feels weird :P)
  • And if you're looking for it, hackathons are a great place to find a job as well! 
...or is it?

Then what's wrong? Why that bad taste in the mouth in recent times. Well, I think it comes down to the following:

I am NOT here to do YOUR job
Picture this scene. Rising startup which aims to disrupt industry X raises capital. Couple weeks later, they have a hackathon, where the problem statements are very specific niches of industry X. While the team spends time mentoring participants, the actual participants do everything from design to coding. At the end, startup announces winners, but stakes claim to all the IP created during the hackathon. Winners walk away with T-shirts and the equivalent of a week of pay. Others walk away having coded for free. This sounds funny, but I could think of at least 2 hackathons that had the exact same terms (down to the T-shirts). In fact at one hackathon, I was requested by a senior developer to not use a NoSQL database for my hack because that's not what they use!

Mentoring session in progress!
Hackathons, Hackathons, Everywhere! 
One of the early hackathons I attended was Yahoo! OpenHack. And I must say, I have fond memories of the event. The grand scale, the quality of the hacks, the exclusivity, the bean bags (every participant walked away with a bean bag), everything. Once the event got over, you waited an entire year for an event like that. Nowadays though, hackathons have gotten extremely commercialized. You have entire companies centered around running hackathons on behalf of other companies (and a league as well for some reason). It's not odd to have multiple hackathons every weekend, differentiated only by the toppings on the pizza they serve for dinner. This has taken away from the actual spirit of hackathons because it's no longer about getting something done. In fact I overheard someone say recently "We can code at the hackathon next weekend, we should network this weekend"... Sigh. Not only do we have more hackathons than can be handled, but the prize money at stake has also grown exponentially. And we know what happens when that happens...

You tell em, Greek dude!
Cheater, Cheater, Pumpkin Eater 
Maybe it's just me, but the beauty of a hackathon hack is that you start with a completely clean slate and code something fun over the course of the hackathon. That something may involve simply bringing together different APIs, or figuring out a nice way to visualise stuff, or something more in depth. Sadly, as time goes on, I seem to be going into a stark minority. It's not an odd sight for people to show up to hackathons with complete running applications, which are then simply demoed at the end of the hackathon. Heck, I've even seen the exact same application being demoed (and winning!) at multiple hackathons by the same team. I'll give you an example of a recent hackathon I went to **. The Runner up team had a nice web app, where they took in some inputs, performed some magic(tm), and came out with some output. The output seemed too good to be true, which usually implies it is. Turns out, their output page was completely hardcoded. It didn't depend at all on the input. They got past this limitation during the demo by providing the only valid input which would generate the output page they had written. Given the format of the demo (3 minutes for demo + 1 minute for questions), no one realised this. And these guys are still not the worst offenders. The team that won had actually submitted the exact same app, with the exact same name, to another offline hackathon a week before this hackathon, and won there as well. And these guys are still not in the all-time hackathon offenders hall of fame. I know a team who has demoed the same application with the same name and the same story (the pitch, if you will) at at least 5 hackathons, and won prizes in at least 4 of them. This is definitely not what I signed up for and goes completely against the hacker spirit.

Pizza + Redbull + Coffee + Pizza =/= 10x Developer 
The first time I went to a hackathon, I was amazed at the fact there was free pizza and redbull... and unlimited coffee! What more could a code monkey ask for? And then it happened again, and again, and again. Until at one point, you simply realise that this may not be a way to live, let alone a way to live healthy. As time goes on, I seem to understand more and more what people mean by the term: healthy lifestyle. Sure, it sounds like an old fart trying to tell young people that it's wrong to "live fast and die young" or to "get rich or die trying" or the quintessential "YOLO", but after a point you really need a break. Maybe this ties back into the point of commercialization of hackathons, but attending too many of these things at a stretch can take a serious toll on your body. For sure, I enjoy nightouts spent coding, leaving aside all your worries for for a while, just as much as the next guy (what do you mean by go to bed?), but I'd much rather learn to respect by body before it decides to show me why I should!

Typical scenes 18-20 hours into a hackathon

Hackathons in Bangalore have a stirring resemblance to the EDM festivals in Goa in the sense that what started out as a bunch of people simply geeking out has today become a massive industry, and brought along with it lots of unwanted elements. How do we keep these elements out? I'm honestly not sure. I'm not even sure if we should keep these elements out, as this is what defines hackathons now. Perhaps there will soon be a indie scene for hackers to meet up and hack at. Or perhaps the only option left now is to hack the hackathon itself. But until something overtly dramatic happens, I can confidently say, we live to hack another day... maybe just not at this hackathon! :)



* hackers = Again, simply someone who associates himself/herself with the hacker culture, which does not mean they can gain access to your Facebook account
** No names because many of the people involved happen to be friends on the hackathon circuit. Kept details scant to avoid identifying traits.

Prologue

Finally after all these years, here's to the beginning of what was there, what is there and hopefully what will remain!! So here are my thoughts & words -Online!!

Blog Archive