article

News & Interesting sites…

Posted by admin on September 29, 2010
article / Comments Off

I had a day off today and ended up spending most of it surfing. Here are some interesting sites I found:

The following site has a great dissection of the Logitech 9000 pro camera, one of the best hi-def webcams for Linux: LINK.

Nanonote: a tiny $99 laptop that can run linux but has very limited conectivity (no WiFi, no ethernet, no host USB). Interesting concept though.

Openmoko are the creators of the FreeRunner, a linux mobile phone, which is very hackable.

The new Arduino Uno has been released. LadyAda has a great page on it. I love the idea that an Arduino can easily be converted to a custom keyboard. Now I need to buy one of these new boards!

And, finally, Shapeways, a Dutch company specialising in custom 3D printing. Funnily enough, I found them through Ponoko.com .

Playing with Python in the wild Amazon (elastic cloud)

Posted by admin on April 05, 2010
Python, article, examples / Comments Off

This Easter bank holiday, I spent some time working on a little problem I have at work with a simulation I’m writing in Python.

It’s basically a Monte-Carlo simulation which is performing billions of calculations. To be more exact, the simulation is a script that performs about half a million of calculations and it has to run a few hundreds of thousands of times. In other words, a lot of number crunching… And as my bosses are a bit impatient, it has to be done quickly, i.e. in hours as opposed to days.

I was running benchmarks at work with various machines (an old G5, a new intel duo laptop and and old P3 desktop). Based on my benchmarks, the old P3 desktop would need approx 10 days to complete the required calculations and it became clear that, if I want to complete these calculations within a reasonable amount of time, I will need a significant amount of processing power.

Over the weekend, I decided to try and quantify/benchmark the performance of Amazon’s EC2 service. I used the m2.4xlarge option (”High-Memory Quadruple Extra Large Instance 68.4 GB of memory, 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each” per Amazon’s description), 1690 GB of local instance storage, 64-bit platform”) which gives the highest computing power. To my surprise, the python script was running on this virtual machine just slightly faster than when it was running on my laptop. After having a look at the monitoring service Amazon offers, I realised that less than 20% of the computing power of this VM was used while running the model…

After a bit of searching/googling/reading, I found that
- My python script was essentially only using one of the cores of the VM machine, in other words 1/8th of it’s capacity.
- To use many processors efficiently one could use the multiprocessor package which is available in version 2.6, but this really complicates things and introduces new levels of complexity on my project.
- I also tried Parallel Python, but I didn’t see any significant changes in the CPU usage.
- A very interesting video on this issue (Python GIL) from David Beazley can be found here.

After reading all this and spending a lot of time experimenting, I took a step back and tried to think this through. As far as my project was concerned and due to the way a Monte Carlo simulation works, my 50 billion calculations were actually 100,000 repetitions of half a million calculations,but these repetitions were independent of each other. In other words, they could run concurrently.

In the end, a simple bash script solved this problem:

#!/bin/bash

for i in {0..1000}
do
python 50M.pyx &
done

In the above script, I was running 1,000 times a simple script (50M.pyx) which contains a loop of 100 iterations of my main set of calculations (half a million calculations). In other words, (1,000 x 100 x 500,000 = ) 50 billion calculations.
The ampersand at the end of the python line indicates that the shell should not wait for the command to finish before it moves on. As a result, it practically launches 1,000 simultaneous instances of the 50M.pyx script. With this simple method, the powerful VM server is working to the max:

max_cpu_usage

It ended up taking 9 hours 13 mins to run 50 billion calculations on this machine. On an old P3 Dell desktop this would take approx 10 days, so the lesson is that, if we use many python instances that run concurrently and a (much much) better machine, there is a significant improvement in performance. Am I stating the obvious? :)

When my simulation is ready, I will probably use 10 instances to get the calculations finished in less than 1 hour.

Tags: , , , ,

Turnkey Linux Fileserver

Posted by arkadian on March 18, 2010
Linux, article / Comments Off

One of the great things about linux is its versatility. Ironically, this is one of its problems too…

What do I mean by that? Simple. If I download a standard linux distribution with the purpose of setting up a file server, I will probably end up spending the better part of a weekend setting it up.
- Which packages should I include?
- Which should I exclude?
- How should I set up the security / firewall etc?
- Setting up samba from scratch?
- Setting up some sort of backup system?
- What about remote access?

I used to just install everything from whatever distribution I had in hand and spend a lot of time tweaking.

Turnkey Linux (http://www.turnkeylinux.org/) provides a great solution. Instead of downloading the standard ubuntu DVD, you download a small distribution that’s already customised to do exactly what you want. There are many different appliance to choose from: LAMP servers, File servers, domain controller appliance, etc etc… The images are tiny (around 100-200MB) compared to the full-blown DVD image and they are also supplied as VM images! In other words you can just download one and run it on VirtualBox or any other VM system!

Turnkey Linux appliances are based on Ubuntu, which means that there are thousands of packages you use to customise your appliance.

My file server at home is now powered by Turnkey Linux.

Tags: ,

Multiple computers on a desk…

Posted by arkadian on March 18, 2010
article, examples / 2 Comments

At work, I have been working with two computers over the past few years. That involved having two screens, two mice and two keyboards on my desk. I wasn’t very pleased but I could live with it.

When I realised I would have to get a third computer, it became apparent that I needed a better solution to manage them all while maintaining my sanity…

I got a stand from allcam.biz (http://www.allcam.biz). I got the longer side arms (optional extra) and attached two 17″ on the two sides (portrait) and a 19″ in the middle (landscape).

TFT stand

By effectively removing two monitor stands, I saved a lot of desk real estate. This stand does not swivel freely (you need to unscrew the bolts if you want to adjust the monitors), but this is not a big issue for me.

Then I had to solve the problem with the keyboards & mice. At first, I thought I will have to go for a hardware solution (either a kvm box from which I will only use the key & mouse inputs/outputs) or a simple usb switch that allows you to share usb devices across different computers.

But, after a bit of searching, I found that there is a free software solution to this problem: Synergy. This is a fantastic little program, that allows you to seamlessly use the same mouse and keyboard across as many computers as you want. What’s even better, you can move from one computer screen to another by just moving the mouse past the side border of one screen and into the other screen. In other words, in the same way as if the two screens are attached to the same graphics card! This is achieved by sending the keystrokes and mouse coordinates via ethernet. It works so well that, unless you were told, you wouldn’t know that the mouse is not physically connected to all three machines. And to make things even better, you can mix-and-match windows, linux and osx machines and you can copy and paste text across different machines! Amazing!

At that point, I had to get a wireless keyboard and mouse. I got the Logitech Cordless Desktop S520 from Amazon for about £30:
Logitech S520
This is a great solid keyboard: it has a standard shape (I can’t work with curvy keyboards), an armrest that is actually part of the keyboard, a low battery indicator both on the mouse and the keyboard and the Caps Lock and Num Lock lights on the usb receiver (which means you don’t waste any battery for them). The laser mouse is one of the best I’ve used.

By removing the multiple keyboards, mice, cables and monitor stands, I have saved a lot of space. I even have space for a couple more computers now! :)

Tags: , ,

Arduino/Ikea Lamp – 4,000 views…

Posted by admin on October 02, 2009
Arduino, article / Comments Off

40 days ago, I added here a post about a “hacked” IKEA lamp; a simple lamp, fitted with 20 RGB leds, an arduino board and a push-to-make switch which I built as a gift to the 2 year old daughter of a good friend of mine.
combination

Now, the lamp has appeared on the front page of the blog of the :MAKE magazine, the video had over 4,000 views recorded on Vimeo and I’m still getting many hits every day.

The most important thing: my friend’s daughter loves this lamp! :)

Tags: , , , ,

About Amazon Web Services…

Posted by admin on August 04, 2009
Web App, article / Comments Off

AWS (Amazon Web Services) has been around for a while, but I never thought I was the target audience for it, so I never really looked into that.

Last weekend, I had the following problem to solve: I’m working on a model, that realistically needs approx 1,000 “normal” PCs in order to run within an hour. This is a simulation running on Processing I’ve been working on.

Realistically, I won’t be able to persuade my boss to buy me a cluster of servers with the processing power of 1,000 machines for this.

Here is where AWS saves me. AWS allows you to rent any number of machines for any number of hours. Well, sort of… You don’t actually rent real machines, you get virtual machines, runnning on clusters I suppose. The beauty of this service is that you can select either a pre-defined image or build and use your own. There are many pre-defined images to select from, including Fedora, Ubuntu, Suse, Debian and of course all the Windows Servers.

You have full control of the firewall and you can attach IPs and storage (at a price) if you like on your loaded image.

I created an account and started playing around and I was actually pretty impressed with the service.

You are getting charged by the hour; if, for example, you are using a smallish linux server for 1 hour, you will pay $0.10 which is not actually that bad. In my case, if I need to use 1,000 machines for 1 hour, I’ll have to pay $100, which is pretty acceptable. There are other charges for storage and traffic, but again these are pretty low too.

Even if you don’t need 1,000 machines, it’s always great to be able to have a virtual linux machine ready to be used as a sandbox for just 10 cents an hour.

I think Google offers a similar service, but, Google’s service is more about running a program on their servers rather than a program on a virtual machine that you have full (root) control, like AWS

Link: Amazon Web Services

Tags: ,