I finally got around to getting Matlab 2007b (7.5) to work in Linux.
It’s not overly difficult, but it certainly isn’t the double-click the .exe we’re all used to 😉
For it to work in Ubuntu 7.10 (Gutsy), I had to do the following
sudo mkdir /usr/local/matlab75
sudo cp license.dat /usr/local/matlab75/license.dat
sudo sh /media/cdrom/install
tell it the location of your matlab dir
select arch and options
sudo sh /usr/local/matlab75/bin/scripts/matlab
It will now work if you’re using the metacity windows manager, but if you’re running compiz
gksudo gedit /usr/local/matlab75/bin/matlab
add the following line directly after the ‘#!/bin/sh’
note, java-6-sun is a symbolic link for java 1.6.0.03
add a shortcut that loads the following
I tested this by installing it on both my desktop (64bit) and laptop (32bit) and it worked perfectly.
Since previously I’d only been running matlab in Windows, I thought it would be a good oportunity to compare some benchmarks.
The built in matlab ‘bench’ is a terrible benchmark, and gets faster the more times you run it, so i decided to run a benchmark written by Jan Mandel, which tests matlab’s speed at LLU (local loop unbundling).
I decided to be fair, to compare my laptop running matlab natively in both Windows and Linux.
I also added my desktops scores for comparison, but it’s running different hardware, and the 64bit version of matlab, so we can’t compare with windows.
Specs are as follows for my laptop
Thinkpad T61 T7500 C2D 2.2Ghz
3GB 667 RAM
Santa Rosa chipset
Hitachi 5K160 HD
nVidia Quadro NVS 140M 128MB
(the rest of the specs don’t matter as they wouldn’t affect benchmark scores)
The results are measured in the amount of seconds it takes to complete the operation, so obviously the lower the better
Jan Mandel, December 2000
Last updated August 2004
Matlab version 188.8.131.528 (R2007b)
Linux x86 (32bit) Thinkpad T61
large LU: 0.205
small LU: 0.506
sparse : 0.133
Windows Vista x86 Thinkpad T61
large LU: 0.261
small LU: 0.664
sparse : 0.172
Here’s my desktop scores
large LU: 0.186
small LU: 0.507
sparse : 0.133
large LLU was 27% faster in linux
small LLU was 31% faster in linux
Sparse was 29% faster in linux
Considering the hardware is identical, that difference is HUGE. And all because of all the screwups Microsoft have made, Vista might well be the biggest! (I should really test Windows XP. I would guess it’s about 10-15% faster than Vista, but still 15% or more slower than Linux)
64bit saw marginal improvements of about 10%. Obviously Matlab isn’t optimized for 64bit 🙁
One thing of note is that recently, Mathworks added multi-threading optimisations to Matlab.
They give a hefty improvement on a dual/quad core machine. The improvement is fairly linear, ranging from 50-70% improvement when you double the cores, with my quad core being over 200% faster with multi-threading enabled. Multi-threading is, however, disabled by default because crash recovery is not yet possible, as information would be split across 4 cores and separate L2 caches.
In the screenshot the first benchmark was single, 2nd with quad, and 3rd in dual mode.
The benchmark named “AntonyJMbench.m was a modification I made of the above benchmark. The JMbench was written years ago when computers were much slower. A benchmark can’t be accurate when it takes a few hundred miliseconds to run, so I modified it so that the first test take 40 seconds on a decent single core machine.
note, the 3rd test works in an way that cannot be optimized for multiple cores.
below is the code for the benchmark should you want to compare your scores with mine.
% function jmbench
disp(‘Jan Mandel, December 2000’)
disp(‘Last updated August 2004’)
disp(‘updated by Antony Williams – December 2007’)
disp([‘Matlab version ‘,version])
fprintf(‘1. large LU: ‘)
for i=1:m,R=chol(A); end
fprintf(‘2. small LU: ‘)
fprintf(‘3. sparse : ‘)
disp(‘end of jmbench’)