Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Sunday, January 28, 2024

Can you make a useful student terminal using a Raspberry Pi 5 ?


Executive summary

Yes, you can. And not only it is doable, but it is actually good fun! The Pi’s are fully useable as student terminals, allowing students to do much more than just ssh-ing to the servers : they have a fast and responsive local environment with chromium, libreoffice, molecular graphics, any programming language they want, R & R-studio, etc. Having said that, the students using them must not be in fear of doing some system administration now and then (but with a carefully prepared image for the microSD card, even this will be very rare). All-in-all, this is a loud and clear go from my side (and at the present time).

The Pi at full throttle. Overview of four workspaces shown with
molecular graphics, libreoffice writer, a tmux session, and a browser. 

The long story

Introduction

So, I decided to buy a Raspberry Pi 5. Not sure why. Probably to have a new toy to play with during the Christmas vacation. This turned-out to be a good choice: the Pi is very good fun, and I still enjoy fiddling with its settings and making it look like a proper linux machine. There were some minor issues, like a difficulty in finding suitable adaptor for micro HDMI, or -the several- issues with Wayland/Xwayland (more on that later), but the final verdict is very positive : Pi is nice and useful as a desktop environment, the hardware looks stable and the software dependable (but it is too early to say), and at 3W power consumption at idle (and 12W under full load), it will make the university happier. Actually it is so nice and the desktop experience so smooth and responsive, that I am seriously thinking about moving it to my desk at the office.

Hardware things

Not much to say here. The things I should mention are : (a) The Pi’s micro HDMI port is a bit difficult to work with, and you have to think whether you want to buy an adaptor or a fixed cable. (b) The official Pi.com case is not very good at cooling the Pi, maybe the official ‘active cooler’ is better and cheaper. There are also these ‘cases’ with double heat sinks and double fans for the fanatics. (c) It would be nice if your monitor comes with speakers, otherwise you will need either a USB- or a bluetooth-based set of speakers/headset/earbuds. (d) The ‘disk’ is a microSD card. My understanding is that this is the weak link hardware-wise. MicroSDs are not made for 24/7, you probably need a high-end model and properly scheduled backups to be on the safe side.

Software things

The Pi comes with Debian 12 (Bookworm), so everything works out of the box, except Wayland/Wayfire. I suffered considerably with the move away from X11, but in retrospect most of it was due to the complete absence of any familiarity from my side with the configuration of wayland and friends. Eventually we did reach an equilibrium and I am happy (for now ?), but note that some things like camera support and video-conferencing have not been tested. The Xwayland part (offering support for pure X11, non-wayland, apps) is not exactly a true substitute for a proper X11 server, and I even ended-up re-writing some code for two of my ancient programs which were using Ygl (an IrisGL-like X11-based substitute for GL) to make them run as fast as they do under X11. Having said all that, I do not regret staying with wayland : I learned things, and wayland appears to be faster and smoother and ‘fancier’ that X11. There are things that bug me, like the absence of a focus-follows-mouse setting (you need to find/build the extra plugins for wayfire to make this work), but all-in-all it looks good now. I suppose that someone with fewer preconceived ideas and expectations could have used the defaults happily and never experience any issues, but this was definitely not the case with me.

Tests in a ‘production’ environment

The Pi passed what I consider to be an acid test for a new desktop machine : log-in onto it, and try to work normally while using it for dealing with whatever happens to come along during a typical day at the office. I have been happily using it for several days now, and only occasionally did something needed to be installed/configured. The general feeling I got is that of using a normal fully-setup modern linux machine on a hardware that is up to the task.

A workspace with too many windows open.
This is from an analysis performed remotely via ssh.

Cost estimates

It looks like you are better off buying a kit and then add to it if needed, instead of buying the parts one-by-one. For example : buying separately the 8G model + the official Pi case + the official power supply costs 123.90 euros (incl. VAT). Buying this kit costs 124.90 euros, and you get (for the same price) the 8G model + the official active cooler + the official power supply + a HDMI ⇒ MicroHDMI cable + the (cheap-ish) ABS case + a Sandisk Ultra 32GB MicroSD (with pre-installed the OS). If 32G is not enough, you only have to buy a larger/better MicroSD card, attach a keyboard and a mouse, and you are good to go.

So, even if I add 30 euros for an extra MicroSD card + a set of wireless keyboard/mouse, we reach a total of ~155 euros for a complete ready-to-go Pi box. Add ~90 euros for a cheap 23" monitor with speakers, and you end-up with a grant total of ~250 euros for a complete Pi-based student terminal. Now : For 190 euros, you can buy a cheap chromebook with 11" display, two cores, and a 32G disk. But I can hardly imagine running e.g. pymol on a 11" display. I am writing this on a chromebook in vim and it is fine for that usage. But the chromebook is not a suitable device for molecular graphics, or having 5 windows open from an analysis of a molecular dynamics trajectory. To conclude this section : if you already have the monitor plus keyboard/mouse —and the 32G MicroSD is acceptable— you can buy a proper desktop machine with 125 euros, which is probably unbeatable. Even if you have to go for the full set, I doubt that you could find an as smooth and responsive machine with 250 euros.

Conclusions

The Raspberry Pi 5 is not a toy-like hardware suitable only for kids learning computing. It has sufficient resources to make a useful everyday terminal for college students as well. The Pi is ideal for writing code, testing it, and then deploying it to the servers for the production run. With the 8G model, you can easily have 4 workspaces loaded with a browser, a local tmux session, a remote session with X11 apps running an analysis, a local diary/journal for taking notes, etc., and with all those apps running, the responsiveness of the Raspberry remains essentially unaffected. You will, of course, not do your heavy computing on the Pi, but this is also true for all terminals we currently use. And with a price tag of 97€ for the 8G model, replacing a broken terminal comes as close to a walk in the park as you’ll ever get. Add the 3W power consumption at idle, and there you have it : a functional solution for light academic computing that is also light on the budget and also light with its environmental footprint. The way I see it, the only thing remaining to be seen concerns the robustness of the Pi : our classical PC-based student terminals can easily pass the 5 year mark, and we have several that have passed the 10 year mark. For the Pi to be useful, it should at least approach the 5 year mark. Replacing MicroSD cards every couple of months would definitely take the fun out of it. Time will show …


Update [April 2025] : Not only the Pi is still my main desktop machine (and I'm happy with it), but we have actually moved ahead and installed three devices for the students' office. The photo says it all :



Saturday, May 13, 2023

The joy of WSL2

 And just like that, there is no reason to fight with building native windows executables any longer. Install WSL2 on win11, and be done with it : all Linux graphical apps work out of the box, and at near native speeds. The screenshot below is from a molecular dynamics simulation analysis with carma / grcarma / stride / rasmol / evince / ..., all visibly working. 


Monday, December 30, 2019

Illustrating transitions between conformers using circos plots


A new tutorial  is available for preparing a circos plot illustrating the transitions between stable conformers identified from e.g. a folding molecular dynamics simulation.



Friday, July 26, 2019

Switching to a tiling window manager (i3)



Switching over to i3. First impressions are good : much less mouse herding, easier to focus, much lighter on resources, no bloating. Few issues with programs whose windows must remain floating (like the ccp4i stuff), but they are fixable through some elementary configuration. All-in-all this is very promising.




Even with tiled windows, ccp4i is still functional (and definitely more tidy) :




Tuesday, June 18, 2019

Fish & FZF


The combination of fish shell with fzf is outstanding. For example, you mistype a filename, hit <CTRL-T>, fzf finds it, and then with <CTRL-S> you can also examine the contents (with syntax highlighting with bat). Add z, fd, bd and rg to the soup and you have a whole new shell.




Thursday, October 18, 2018

Running dropbox on old linux machines


Dropbox recently changed the linux system requirements. This may be a meaningful choice from the company's perspective, but I am not prepared to give-up on some of my old machines which have software that I find it hard to move to newer hardware. So, I was looking for a software solution that could work with ubuntu 10.04, ubuntu 11.04 and a relatively new centos machine which uses xfs instead of ext4. First I will describe the technical steps for the procedure I'm currently using, then I will discuss the shortcomings.


Technical steps (based on rclone and inotifywait)

[1] Install rclone as described in https://rclone.org/downloads/ . Surpisingly, this may be the hardest part of the procedure due to old versions of curl not being compatible with the server-side ssl. On both of my machines I had to install openssl from source and then install curl again from source (using the newest ssl libraries). Expect suffering at this stage.

[2] Configure rclone as described in https://rclone.org/dropbox/ . This is easy.

[3] Do a dry run to confirm that rclone is working as expected (change 'mydropbox' and 'user'):

rclone --dry-run sync -u mydropbox: /home/user/Dropbox


[4] Install inotify-tools if you don't have them already.

[5] If you reached this stage, you are practically done :


(a) Prepare a hidden file in your home directory (for example /home/user/.dropboxwatch.sh) containing the following bash script :


#!/bin/bash
while true; do

inotifywait -e modify,create -r /home/user/Dropbox && \
 pgrep rclone > /dev/null || rclone copy -u /home/user/Dropbox mydropbox:

done
exit

Make this file executable (with chmod 755 /home/user/.dropboxwatch.sh).


(b) Edit your crontab and insert the following two lines :


@reboot      /home/user/.dropboxwatch.sh >& /dev/null
*/30 * * * * pgrep rclone > /dev/null || rclone sync -u mydropbox: /home/user/Dropbox


(c) Add the following to your .bashrc :

alias dropboxfetch='pgrep rclone > /dev/null || rclone copy -u mydropbox: /home/user/Dropbox'


(d) Reboot the machine and confirm that .dropboxwatch.sh is running.



What you get from all that

(a) When you add a file to the dropbox directory of the local (old) machine, it will be immediately transferred to the dropbox servers (and, thus, to all of your other machines).

(b) When you modify the dropbox directory from other (non-old) machines, the changes in the old machines will appear at the time interval defined in the crontab (every 30 minutes in the example above). If you want to immediately fetch new files from dropbox to the local (old) machines use the dropboxfetch alias.

(c) You can not push file deletions from the old machines to dropbox. Dropbox files can only be deleted from newer machines that run the real dropbox daemon. The deletions will appear at the crontab specified interval. Think what you may, but this is a great precaution (and do note that at no point do we do a sync from the old machine to dropbox, which is the definition of better-safe-than-sorry).

Things can definitely go wrong. Notice for example these pgrep's ? These are to avoid some obvious race conditions that arise if you end-up having two rclone jobs running simultaneously. But I bet (especially with dropboxfetch) you can still get artifacts. The thing is that in the absence of a sync from the old machine to dropbox, the worst case scenario is that some files you thought you deleted, may end-up being well and alive. (famous last words I hear you say).




Wednesday, May 30, 2018

Primitive cluster monitoring for the desktop


Combine warewulf, a tiny cgi perl script and conky, and there it is, a primitive cluster monitoring tool for the desktop without ssh :





Sunday, April 23, 2017

Monday, September 23, 2013

A new method for quantifying convergence of biomolecular simulations.


We have developed a new probabilistic method for quantifying convergence of molecular dynamics simulations. The essence of our method is the following : We treat the molecular dynamics trajectory as a finite sample of “molecular species” (clusters of similar structures) taken from an underlying distribution containing an unknown number of such molecular species. The observed frequencies of molecular species in the sample are calculated, and the Good-Turing formalism is applied to these frequencies allowing us to estimate the total probability of unseen (i.e. as yet unobserved) species. The result is the answer to the following question: "What is the probability that a molecular configuration with an RMSD (from all other already observed configurations) higher than a given threshold has not actually been observed?".

A paper containing a full description of the method is available from JCIM.

A program implementing the method is available via the github repository.


Friday, September 13, 2013

grcarma on the cover of JCC


The program grcarma written by Panagiotis Koukos made the cover story of the latest issue of the Journal of Computational Chemistry. Well done Panagiotis !



Wednesday, October 24, 2012

Web-based service for GraphEnt

This is a fully automated web-based interface to the program GraphEnt which aims to simplify the calculation of maximum entropy protein electron density maps. The service is located at http://orion.mbg.duth.gr/graphent






Monday, February 20, 2012

Console screensaver for computing cluster

Prepared a customized screensaver for the console of the computer cluster room. It is a modified form of cmatrix with the addition of periodically displayed cluster statistics (based on warewulf wwtop). Here are two screenshots :




Friday, October 28, 2011

Carma v.1.1

Update homepage to reflect the release of the newest carma version (1.1).