Tuesday, December 1, 2015

Install a VNC Server on Ubuntu (x11vnc as alternative to tightVNC)

The goal of a VNC server is to remotely access the screen of another machine. In my case remotely is a room further down the hall on the same intranet, so at this stage I'm not worried about using encryption.

After having some trouble using the very popular tightvnc as a the tool of choice (I was getting errors running software which are based on the Qt framework; a similar bug has been reported here).
Because I'm quite dependent on this particular piece of software, I had to find a workaround. I chose to use x11vnc.

Because x11vnc relies on an actual X display, we need to make a virtual X display first. For this I use Xvfb. Both x11vnc and Xvfb are available in the Ubuntu repositories.
Additionally, I wanted to use the old Gnome-Fallback (a.k.a Gnome Classic) display, because I'm not a big fan of the current display and the 3D-effects make things go slower on a VNC connection. This can be installed using sudo apt-get install gnome-session-fallback. This is of course not a requirement to use x11vnc and Xvfb.

First generate a password for x11vnc:
x11vnc -storepasswd and store it to /home/yourusername/.vnc/passwd. The password is only a minimal security measure, the connection still won't be encrypted.

You need to first start the Xvfb display this way:
/usr/bin/xinit /usr/bin/gnome-session --session=gnome-fallback --disable-acceleration-check -- /usr/bin/Xvfb :20 -screen 0 1680x1050x24
This will open an Xvfb display on X display number 20 with the given resolution (1680x1050) and color depth (24bit). If you don't want to use the classic gnome desktop remove the --session=gnome-fallback argument.

Next start x11vnc:
/usr/bin/x11vnc -display :20 -loop -rfbport 5901 -rfbauth /home/yourusername/.vnc/passwd -o /var/log/x11vnc.log
This will forward X display number 20 (where the Xvfb display is) to port 5901. Make sure that argument -rfbauth points to your password you created in the first step.

You can now connect to your machine on port 5901 using a VNC client such as RealVNC. Make sure that your firewall allows access to port 5901. You can of course also change the port using the -rfbport argument in x11vnc.

If everything works we can use a service to start these two programs automatically at every upstart.
As sudo create a text file at /etc/init/x11vnc.conf. Include following commands (make sure to replace yourusername with your actual username):
start on login-session-start
echo Start x11vnc at `date` >> /var/log/x11vnc.log
su - yourusername -c "/usr/bin/xinit /usr/bin/gnome-session --session=gnome-fallback --disable-acceleration-check -- /usr/bin/Xvfb :20 -screen 0 1680x1050x24" &
su - yourusername -c "/usr/bin/x11vnc -display :20 -forever -loop -rfbport 5901 -rfbauth /home/yourusername/.vnc/passwd -o /var/log/x11vnc.log" >> /var/log/x11vnc.log
end script

This script will be run on every startup or by using sudo service x11vnc start.

Run I-Tasser in parallel mode using SGE

I-TASSER (http://zhanglab.ccmb.med.umich.edu/I-TASSER/) is a popular protein structure prediction software that can also be installed locally as a stand alone program.

In order to make use of the parallelization capabilities of I-TASSER you first must install a batch-queuing system, for which I chose SGE (Sun Grid Engine). I followed these instructions to set it up on my Ubuntu multi core server: https://scidom.wordpress.com/2012/01/18/sge-on-single-pc/
The setup is comparatively straight-forward (or at least similar confusing as other systems such as Torque or SLURM) and the necessary binaries are available through Ubuntu's repositories.

After successful setup of SGE and some tests, I was ready to setup I-TASSER to use SGE. It's advisable to run I-TASSER in the serial mode first, to check that everything is in order, e.g. the database is in the right place, all the right software is installed etc. If the serial mode works, we're ready to change the starting script such that it works using SGE.
The starting script is called runI-TASSER.pl and located in the I-TASSERmod folder. I made a copy of this script and called it runI-TASSER_SGE.pl.

Change following lines:
Line 840: change
$bsub=`qsub -e $errfile -o $outfile -l $walltime -N $tag $jobname`;
$bsub=`qsub -cwd -S /usr/bin/perl -e $errfile -o $outfile -N $tag $jobname`;

Line 1661: change
$bsub=`qsub $datadir/$tagnames{$i}`;
$bsub=`qsub -cwd -S /usr/bin/perl $datadir/$tagnames{$i}`;

This seems to do the trick. You can now use runI-TASSER_SGE.pl using the -runstyle parallel option and I-TASSER will submit the tasks to the SGE queue.