5735
Comment:
|
5115
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
= Page is under construction = |
|
Line 13: | Line 11: |
See the Matlab-Documentation in Matlab: Help - Product Help - Getting Started | Matlab has a lot of tutorials by its own. You can find them here: Help - Product Help - User Guides |
Line 15: | Line 13: |
== Matlab Compiler == | = Matlab Compiler = |
Line 17: | Line 15: |
* More info: See the Matlab-Documentation in Matlab: Help - Product Help - Matlab Compiler | * The advantage of a compiled matlab program is, that no matlab license is taken from the ETH-licenses. |
Line 21: | Line 19: |
* Standalone Applications executables don't need any Matlab Licences. | |
Line 28: | Line 25: |
Line 37: | Line 35: |
m |
|
Line 39: | Line 39: |
Important: When this programm is runned in a Linux-Terminal, we have to use the function str2num (string to number). Arguments are used as strings, thats why it has to be converted in a number. |
|
Line 40: | Line 42: |
* Compile the magicsqure function: | * Compile the magicsqure function (with the command: mcc): |
Line 46: | Line 48: |
* This generates you 2 files: magicsquare and magicsquare.sh * magicsquare is the main file of the application. * magicsquare.sh is the script to start the application. It sets up the MCR (MATLAB Compiler Runtime) environment for the current $ARCH and executes the specified command. |
|
Line 47: | Line 52: |
* To run the magicsquare programm we give the shell-script 2 arguments. The first is the path to the Matlab Compiler Runtime. The second is for the programm magicsquare itself. | |
Line 48: | Line 54: |
* enter magicsquare(5), and view the results. | {{{ ./run_magicsquare.sh /usr/pack/matlab-7.13r2011b-sd 5 ------------------------------------------ Setting up environment variables --- LD_LIBRARY_PATH is .:/usr/pack/matlab-7.13r2011b-sd/runtime/glnxa64:/usr/pack/matlab-7.13r2011b-sd/bin/glnxa64:/usr/pack/matlab-7.13r2011b-sd/sys/os/glnxa64:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64 |
Line 50: | Line 61: |
m = | |
Line 51: | Line 63: |
* Help on mcc: mcc -help or see Documentation in Matlab. | 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 |
Line 53: | Line 69: |
= Deutsch: Limitierte Anzahl Lizenzen = Die Anzahl der MATLAB-Lizenzen ist begrenzt. Um einen fairen und effizienten Gebrauch dieser Lizenzen in der gesamten ETH zu gewährleisten wurden folgende Maßnahmen getroffen: * Lizenzen werden zurückgegeben, wenn keine Nutzung seit 4 Stunden erfolgte * Die übermäßige Verwendung von Lizenzen wird überwacht und Benutzer werden aufgefordert wenn nötig Lizenzen zurückzugeben. |
}}} |
Line 58: | Line 71: |
== Was können Sie tun? == 1. Kompilieren Sie Ihr MATLAB-Programm. Der beste Ansatz, eine übermäßige Verwendung von MATLAB-Lizenzen zu vermeiden, ist die Kompilierung Ihres MATLAB-Programm. Die resultierende ausführbare Datei braucht keine einzige MATLAB-Lizenz! Dies befreit Sie von allen MATLAB Lizenzbeschränkungen und erlaubt Ihnen ausserdem Ihre ausführbare Datei an Nutzer ohne MATLAB Installation weiterzugeben. |
* More help on mcc: Enter on commandline: mcc -help * Or see the Matlab-Documentation in Matlab: Help - Product Help - Matlab Compiler |
Line 61: | Line 74: |
1. Beenden Sie MATLAB wenn Sie fertig sind. Nur dann werden alle verwendeten Lizenzen zurückgegeben. | = Matlab on the cluster = * Every Matlab-Job on the Cluster uses one license. Therefore its very important, to run only compiled Matlab-Applications on the cluster. * Set the variable MCR_CACHE_ROOT to a directory on your local computer. The NFS-Load on the Homeservers gets too big for the homedirectory. {{{ export MCR_CACHE_ROOT=/tmp }}} * Use the singleCompThread Option of mcc: {{{ mcc -R singleCompThread -mv magicsquare.m }}} |
Line 63: | Line 86: |
1. Registrieren Sie Zeiten in denen viele MATLAB-Lizenzen aufgrund eines MATLAB-Kurses benötigt werden. Mit dieser Registrierung im Voraus können wir Gegenmaßnahmen ergreifen und sicherstellen dass diese Lizenzen zur Verfügung stehen. 1. Kaufen Sie Ihre eigenen MATLAB Lizenzen falls Sie einen garantierten 24/7 Service benötigt oder falls Sie eine übermäßige Anzahl an Lizenzen verwenden müssen. == Matlab auf dem Cluster == * Jede Matlab-Instanz auf dem Cluster verbraucht eine Lizenz. Deshalb ist es wichtig, nach Möglichkeit nur kompilierte Matlab-Applikationen auf dem Cluster laufen zu lassen. == Wie weiss ich welche MATLAB Lizenzen ich verwende == * Der MATLAB Befehl "license('inuse')" listet die benutzten Lizenzen der aktuellen MATLAB Sitzung auf. == Wie weiss ich wer wieviele MATLAB Lizenzen verwendet? == * Sie können alle benutzten MATLAB Lizenzen mit dem folgenden Befehle auflisten. * Linux Terminal: lmutil lmstat -c $MATLAB/license.dat -a * Windows Terminal: * cd $MATLAB\etc\win{32|64} ($MATLAB\flexlm für Versionen vor 2010b) * lmutil lmstat -c license.dat -a (wobei $MATLAB das MATLAB Grundverzeichnis ist) = English: Limited amount of licenses = |
= Limited amount of licenses = |
Line 86: | Line 91: |
Line 88: | Line 92: |
Line 94: | Line 97: |
== Matlab on the cluster == * Every Matlab-Job on the Cluster uses one license. Therefore its very important, to run only compiled Matlab-Applications on the cluster. |
|
Line 101: | Line 101: |
* You can list all checked-out MATLAB licences with the following commands. * Linux: lmutil lmstat -c $MATLAB/license.dat -a * Windows command prompt: * cd $MATLAB\etc\win{32|64} ($MATLAB\flexlm for releases prior to 2010b) * lmutil lmstat -c license.dat -a (where $MATLAB is the root MATLAB directory) |
* You can list all checked-out MATLAB licences with the following command. * Linux: lmutil lmstat -c 1965@lic-matlab.ethz.ch -a | less |
Contents
Matlab
Matlab is a high-level language and interactive environment for numerical computation, visualization, and programming.
Start Matlab
- Start it on Linux: Applications - Accessories - Terminal. Then type: Matlab (Enter)
- Start it on Windows: Start - Matlab - Matlab
First Steps
Matlab has a lot of tutorials by its own. You can find them here: Help - Product Help - User Guides
Matlab Compiler
- mcc (both: UNIX and Windows) is the MATLAB Compiler. You can use the mcc command either from the MATLAB command prompt (MATLAB mode) or the command-line (standalone mode).
- The advantage of a compiled matlab program is, that no matlab license is taken from the ETH-licenses.
How to use Matlab Compiler on Linux
- This chapter describes how to use MATLAB Compiler to code and build standalone applications.
Magic Square Example
- A magic square is an array of integers arranged so that their sum is the same when added vertically, horizontally, or diagonally.
- Copy the following code in a text-file and save it as magicsquare.m
function m = magicsquare(n) %MAGICSQUARE generates a magic square matrix of the size % specified by the input parameter n. % Copyright 2003-2011 The MathWorks, Inc. if ischar(n) n=str2num(n); end m = magic(n); m
Important: When this programm is runned in a Linux-Terminal, we have to use the function str2num (string to number). Arguments are used as strings, thats why it has to be converted in a number.
- Start a Terminal (Applications - Accessoires - Terminal) and change to the directory where you stored magicsquare.m
- Compile the magicsqure function (with the command: mcc):
mcc -mv magicsquare.m
- This generates you 2 files: magicsquare and magicsquare.sh
- magicsquare is the main file of the application.
- magicsquare.sh is the script to start the application. It sets up the MCR (MATLAB Compiler Runtime) environment for the current $ARCH and executes the specified command.
- To run the magicsquare programm we give the shell-script 2 arguments. The first is the path to the Matlab Compiler Runtime. The second is for the programm magicsquare itself.
./run_magicsquare.sh /usr/pack/matlab-7.13r2011b-sd 5 ------------------------------------------ Setting up environment variables --- LD_LIBRARY_PATH is .:/usr/pack/matlab-7.13r2011b-sd/runtime/glnxa64:/usr/pack/matlab-7.13r2011b-sd/bin/glnxa64:/usr/pack/matlab-7.13r2011b-sd/sys/os/glnxa64:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/server:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64/client:/usr/pack/matlab-7.13r2011b-sd/sys/java/jre/glnxa64/jre/lib/amd64 m = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
- More help on mcc: Enter on commandline: mcc -help
- Or see the Matlab-Documentation in Matlab: Help - Product Help - Matlab Compiler
Matlab on the cluster
- Every Matlab-Job on the Cluster uses one license. Therefore its very important, to run only compiled Matlab-Applications on the cluster.
- Set the variable MCR_CACHE_ROOT to a directory on your local computer. The NFS-Load on the Homeservers gets too big for the homedirectory.
export MCR_CACHE_ROOT=/tmp
- Use the singleCompThread Option of mcc:
mcc -R singleCompThread -mv magicsquare.m
Limited amount of licenses
The number of MATLAB licences is limited. To ensure a fair and efficient usage of the licences throughout the ETH the following measures have been put in place:
- licences will be returned if not used for 4 hours
- excessive usage of licences will be monitored and users will be asked to return licences if needed
What can you do?
- Compile your MATLAB program. The best approach to avoid excessive usage of MATLAB licences is to compile your MATLAB program. The resulting executable does not need ANY MATLAB licence! This frees you from all MATLAB licence restrictions and also allows you to provide your executable to users without a MATLAB installation.
- Exit MATLAB when finished. Only then will all used licences be given back.
- Register the need for many MATLAB licences due to a MATLAB course By registering your need in advance, we can take countermeasures and ensure that these licences are available.
- Buy your own MATLAB licences if you must have a guaranteed 24/7 service or if you need to use an excessive amount of licences.
How do I know which MATLAB licences I use?
- The MATLAB command "license('inuse')" lists the licences checked out for the current MATLAB session.
How do I know how many MATLAB licences are used by whom?
- You can list all checked-out MATLAB licences with the following command.
Linux: lmutil lmstat -c 1965@lic-matlab.ethz.ch -a | less