openFrameworks on EC2

May 17 2013

For quite some time I’ve been trying to get an openFrameworks app running on a non-GPU server. I had been thinking that it would be necessary to get something like Mesa 3D running within oF for off-screen software rendering, but it turns out that this isn’t the case.

  • Stream video from an oF app via ffmpeg

##How?

If you’ve never used EC2 before, you’ll probably want to read some kind of introduction.

  1. Launch an EC2 instance with Ubuntu 12.04.2 LTS (Precise Pangolin).

    I recommend launching an “m1.large” instance ($0.240 per Hour/2 cores/4 ECUs), or, at the very least, an m1.medium ($0.120 per Hour/1 core/2 ECUs). Anything smaller will be SUPER slow, and even tends to run out of memory while doing the most basic oF stuff.

  2. Note your Public DNS address. It will look something like ec2-XX-XXX-XX-XX.compute-X.amazonaws.com. It should be listed when you click on the instance name and show details.
  3. Now we need to install a bunch of stuff, so SSH into your instance

     ssh -i my-keypair.pem ubuntu@ec2-XX-XXX-XX-XX.compute-X.amazonaws.com
    
  4. Since we are using Ubuntu Server, it doesn’t come with graphical desktop stuff by default, so the first thing we need to do is install it. This takes quite a while, so be patient. WTF is this “DEBIAN_FRONTEND=noninteractive” stuff?

     sudo apt-get install -y build-essential
     export DEBIAN_FRONTEND=noninteractive
     sudo -E apt-get update
     sudo -E apt-get install -y ubuntu-desktop
    
  5. Install FreeNX server on your instance. This is supposedly better than VPN for remote desktoping.

     sudo add-apt-repository ppa:freenx-team/ppa
     sudo apt-get update
     sudo apt-get install -y freenx freenx-server
    
  6. Get a FreeNX configuration file

     wget https://bugs.launchpad.net/freenx-server/+bug/576359/+attachment/1378450/+files/nxsetup.tar.gz
     tar zxvf nxsetup.tar.gz
     sudo mv nxsetup /usr/lib/nx/nxsetup
     sudo chown root:root /usr/lib/nx/nxsetup
    
  7. I’m not exactly sure why you have to “install” FreeNX again – isn’t that what we did in step 5? Anyway, you will be asked if you wish to generate a new user key. Type “N”

     sudo /usr/lib/nx/nxsetup --install
     sudo echo -e "\n#Use unity 2d for client sessions\nCOMMAND_START_GNOME='gnome-session --session=ubuntu-2d'" | sudo tee -a /etc/nxserver/node.conf
    
  8. By default, the EC2 server is set up to only allow public key connections, but the FreeNX connection will happen over SSH, so we need to enable SSH password authentication. But before we do that, set a password for your account.

     sudo passwd ubuntu
    
  9. Enable password login

     sudo nano /etc/ssh/sshd_config
     [Set PasswordAuthentication to "yes" where it says "no", then save and exit.]
     sudo /etc/init.d/ssh restart
    
  10. Get the NoMachine 4 Preview. This will install both NoMachine Server and NoMachine Player. We are only interested in the Player…
  11. Launch NoMachine Player and connect to your server. Hint: Make sure “Use NoMachine Login” is selected

Image 01 Image 02 Image 03

  1. Once you’re logged in, you can launch Firefox and head to http://www.openframeworks.cc/download/, get the code::blocks (64 bit) version of oF, and go through the install process

##Limitations

  • Shaders

##Resources