setting up a linux Ubuntu system for EM image processing


Maofu Liao. created on 08/13/2017

(This is a beta version intended for collecting comments.
Please send your suggestions to, and help improving this document. Thanks!)


1. Install Ubuntu (Other version newer than 14.04 has not been fully tested)

1) Download Ubuntu 14.04 LTS (14.04.5 Desktop (64-bit)).



2) If you have a working Ubuntu system,

Burn the downloaded ISO file into a USB drive (>1 Gb) using “Startup Disk Creator” function;

    If you have only Windows, use Rufus ( to burn ISO.

3) Restart your computer and boot from USB drive to start installation.

4) If have a working Windows system and want to keep it, it is easy to do dual boot:

            a) Shrink or add hard drive disk to provide empty space for Ubuntu;

            b) Reboot and go to motherboard setting, by keep hitting Del or other key (computer specific).

                        Disable both “Secure boot” and “Fast boot”.

            b) Install Ubuntu as in step (3). During installation, select “Install alongside windows”.


2. Install Nvidia driver (only if you have Nvidia GPU card)

            1) If you cannot log in (the login screen keep cycling), hit Ctrl+Alt+F1 to command line and log in.

            2) In terminal, run the following commands:

                        sudo apt-get purge nvidia-*

                        sudo add-apt-repository ppa:graphics-drivers/ppa

                        sudo apt-get update

                        sudo apt-get install nvidia-375

                        (The 2nd command will tell you the current version of driver, in this case 375.

You can use this version, or an earlier version if you have a reason to do so.)

            3) Reboot. (If needed, hit Ctrl+Alt+F1 to switch to command line again.) Run these command:

                        sudo apt-get update && sudo apt-get upgrade

                        (If you get a message saying that a package was held back,

run the following command: sudo apt full-upgrade)

            4) Reboot. You should be able to log in and the GPU should be running. Test GPU by running:



3. Install CUDA GPU toolkit (only if you have Nvidia GPU card)

            1) Download CUDA (

Select “Linux – x86_64 – Ubuntu – 14.04 – runfile(local).

It is possible to install multiple versions of CUDA.

            2) Run the installation file using sudo. For example,

                        sudo sh

                        Note that you have to reject installing Nvidia driver! Only install CUDA toolkit.


4. Install libraries

            1) Install Synaptic:

sudo apt-get install synaptic

            2) Use Synaptic to install the following items, including any additional items Synaptic suggests.

                        (Input items in “quick filter” will show candidates. Some items are likely already installed.)

                        python-wxgtk2.8, python-imaging, python-numpy, python-scipy,

                        multilib (gcc-multilib, gfortran-multilib), gnuplot-x11,

                        build-essential, libx11-dev, csh, tcsh, vim

                        gnome-system-tools (only if you want to manage additional users and groups)


5. Install OpenMPI (I am using v1.6.4)

            1) Download and extract OpenMPI (

            2) Run the following commands:

                        sudo ./configure --prefix=/usr/local/openmpi

                        sudo make

                        sudo make install


6. Setup SAMUAL and SamViewer

            1) Copy three SAM directories to any folder (usually “~/programs/”): sam, sam_app and samviewer.

            2) Modify Python Image Library (PIL) setting to make it work with dm3 and MRC formats.

                        cd /usr/lib/python2.7/dist-packages/PIL

                        sudo gedit

                        (In this file, you will see a list of format plugins, add “Dm3ImagePlugin” and “MrcImagePlugin”)

                        sudo cp ~/programs/samviewer/ .

sudo cp ~/programs/samviewer/ .

sudo cp ~/programs/samviewer/ .


7. Setup Relion

            1) Follow the procedure in Relion Wiki page:


7. Modify .bashrc file (in your home directory)

            1) You can add similar lines to the end of current .bashrc file.

# =====================

#  Start of my settings

# =====================

alias ll='ls -l'

alias la='ls -A'

alias cp='cp -v'

alias rm='rm -i'

alias mv='mv -i'


export PATH=$PATH:/home/NAME/bin


# SAM setting

export PATH=/home/NAME/programs/sam/bin: /home/NAME/programs/samviewer:$PATH


# OpenMPI setting

export MPI_DIR=/usr/local/openmpi

export PATH=/usr/local/openmpi/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH


# CUDA setting

export PATH=/usr/local/cuda/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH


# Relion setting

export LD_LIBRARY_PATH=/home/NAME/programs/Relion/relion-2.0/build/lib:$LD_LIBRARY_PATH

export PATH=/home/NAME/programs/Relion/relion-2.0/build/bin:$PATH

# =====================

#  End of my settings

# =====================


            2) To apply the modification, save the file, and run

                        source ~/.bashrc