This guide describes how to download and install a full matlab instance inside a singularity image.
This will allow forwarding of x server so gui will appear. Note this may be specific to centos
sudo docker run -it --privileged --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" centos:6.8
cd /tmp
yum install -y wget
wget --user=USER --password=PASSWORD https://sds.vuse.vanderbilt.edu/SDS-SSL/MATLAB/R2017a/unix/R2017a_glnxa64_dvd1.iso && wget --user=USER --password=PASSWORD https://sds.vuse.vanderbilt.edu/SDS-SSL/MATLAB/R2017a/unix/R2017a_glnxa64_dvd2.iso
Install utilites for mount command
yum install -y util-linux-ng
Mount matlab iso
mkdir matlab
mount -t iso9660 -o loop R2017a_glnxa64_dvd1.iso /tmp/matlab/
First install libraries which make gui work (note gedit must contain a lot of dependencies to make gui applications work)
yum install -y dejavu-lgc-sans-fonts gedit libXt
This fixes some X issue
dbus-uuidgen > /var/lib/dbus/machine-id
Install
sh matlab/install
Hit “ctrl+z” to background the installer. Unmount first dvd.
umount /tmp/matlab/
Mount second one
mount -t iso9660 -o loop R2017a_glnxa64_dvd2.iso /tmp/matlab/
Type “fg” to bring stopped job to foreground. Then hit continue. Activate matlab. Test out matlab.
matlab
Remove isos when finishes
rm -f R2017a_glnxa64_dvd*.iso
Unmount iso
umount /tmp/matlab/
Clear command history
history -c
DO NOT EXIT CONTAINER UNTIL IT HAS BEEN COMMITTED OR ALL CHANGES WILL BE LOST!!!
- Open another terminal and find out the CONTAINER ID. Hopefully you only have a single centos:6.8 container running, then it will be easy to find
- Commit the docker container
sudo docker commit
- Push to docker hub
sudo docker login
sudo docker push
- This might take a little bit of time… also the docker container becomes “frozen” during this time
- Also note you can run this matlab directly on another machine if you spoof the mac addres with the –mac-address option in docker run
- We want to be able to run this on the cluster with singularity. In order to do this we will need to use the cluster license
- First, convert the docker container to a singularity container. I had to run this as root for some reason. It may also take a while…
sudo -i
mkdir /tmp/centos_with_matlab
cd /tmp/centos_with_matlab
export SINGULARITY_DOCKER_USERNAME=
export SINGULARITY_DOCKER_PASSWORD=
singularity -vvv build --writable centos_with_matlab.simg docker:DOCKER IMAGE TAG
- Copy over to cluster – might take a little bit, its ~20 gigs
scp centos_with_matlab.simg USER@HOST:DIRECTORY
- Test on cluster
ssh @
ml GCC Singularity
singularity shell /tmp/centos_with_matlab.simg
Singularity centos_with_matlab.simg:~> matlab -c
- Hopefully matlab should start
https://github.com/baxpr/connprep
https://github.com/baxpr/example-spm-singularity-spider
This option is probably only useful to OSX users: https://github.com/baxpr/mcrsing-docker
A couple of tips to make figures come out right when generated by Matlab on ACCRE. This is a starting point and could be wrong.
For the figure itself
- 'Units', 'inches'
- 'Position', [0.5 0.5 7.5 10] (For US letter in guide)
- 'PaperPosition', [0.5 0.5 7.5 10] (Critical for correct size when printing. Again, this for US letter)
For axes, text boxes, etc
- 'Units', 'normalized' So they will resize appropriately on screen
- 'Font', 'default' Probably helps avoid resizing issues
- 'FontUnits', 'normalized' Avoids resizing issues. Size is specified relative to height of parent axes/text box so it takes some fiddling to get right.
% Figure out screen size
ss = get(0,'screensize');
ssw = ss(3);
ssh = ss(4);
ratio = 8.5/11; % Width/height ratio. Should match the position settings described above
if ssw/ssh >= ratio
dh = ssh;
dw = ssh * ratio;
else
dw = ssw;
dh = ssw / ratio;
end
f = openfig('figure_file.fig','new');
% Fit the figure on the screen. Change units to pixels - if we leave at inches, we have memory trouble.
set(f,'Units','pixels','Position',[0 0 dw dh]);