Issue running MATLAB in AWS via terminal

Viewed 570

On AWS I have a matlab stack running. Via remote desktop the matlab runs (via a gui). However via ssh I would like to run the matlab via terminal as part of a bash pipeline with no gui popping up. However, when I try and run a simple matlab script via terminal using ssh

/usr/local/MATLAB/R2019a/bin/matlab -batch 'run simpleScript.m'

I get this error:

MATLAB is selecting SOFTWARE OPENGL rendering.
terminate called after throwing an instance of '(anonymous namespace)::DisplayError'
  what():  No display available.

I'm wondering if anyone has any work around for this? Is this just a limitation to using matlab on aws?

cheers for any help!

2 Answers

I spent a long time finding out what's wrong and at last, I fixed it.

Wish this solution can help you too!

First-Before Install

in the installer_input.txt I haven't set # enableLNU=yes to valid

then I use sudo bash install -v -inputFile installer_input.txt to install MATLAB

Second-After Install

If you have activated the license, it's ok. Or you should have a GUI window to do some steps. I recommend VcXsrv Windows X Server.

then you should input vi ~/.bashrc and add follows at the bottom:

> export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
> export LIBGL_ALWAYS_INDIRECT=1

then start XLaunch in your windows

run matlab to activate your license (I think you have added matlab in your PATH)

Third-After All

If you have activated license, you can use matlab -nodisplay to run matlab without XLaunch, and I guess this may also work through ssh if you have set right export DISPLAY=

When you try to open MATLAB via terminal, MATLAB tries to open the licensing window to get your credentials and authenticate you. The window fails to open (because you are in the terminal), and thus you see the error.

To get things working, you can either:

  • Deploy the license manager stack and upload your license there. Then, re-deploy the MATLAB stack and specify the license manager as one of the parameters. This way MATLAB will always talk to the license manager (regardless of whether it's in desktop or terminal), and you won't see any issues

  • Place your license file in the MATLAB licenses folder, so MATLAB will always pick it up

  • Place your license file somewhere on disk and start MATLAB with the -c flag to point to the file

Related