When running a job that requires a CAD instance (eg. Lumerical Script, Python API, or LumOpt), you will need to have a graphics environment (even if it is hidden). On compute clusters consider running scripted workflows on nodes with visualization capabilities (GUI interface) then modifying the resource configuration to distribute the workload or submitting jobs from the terminal to the headless nodes.
Important
- Having a graphical interface is our supported workflow. Running API and scripts from the CAD/GUI with a desktop/graphical connection like VNC or X11 forwarding on Linux.
- This work around process is not supported on all Linux installations and is provided as is without further support.
- When running a simulation using the script, the resource configuration settings in the 'Lumerical product preference.ini' file will be used to run the simulation called by the script.
- Ensure that you have the Lumerical product preference.ini file on your "local folder" to run your simulation with virtual display.
Using virtual display (Xvfb)
- Install Xvfb and tmux (consult your operating systems documentation for proper instructions).
eg. (installation on RHEL/CentOS)
$ sudo yum install xorg-x11-server-Xvfb tmux
- Open a "tmux" session and a virtual display by:
tmux
Xvfb :## &
export DISPLAY=:## - eg.
tmux
Xvfb :99 &
export DISPLAY=:99 - Run your Lumerical script with Xvfb:
xvfb-run --auto-servernum /opt/lumerical/[[verpath]]/bin/fdtd-solutions -nw -run your_script.lsf
xvfb-run --auto-servernum python lum_script.py
Notes
- You only need to run the "Xvfb :## &" command once on your "tmux" session. Unless you want to use a different display number.
- You can check the Xvfb display used by:
ps -ef | grep Xvfb
- You should get the output of the display numbers used for Xvfb.
username 1639 1 0 12:00 ? 00:00:00 Xvfb :99
username 1732 1 0 12:03 ? 00:00:00 Xvfb :10
username 1796 1748 0 12:09 pts/2 00:00:00 grep --color=auto Xvfb - From the above, we have Xvfb using display :99 and :10.
- Run the export DISPLAY command every time you enter into a "tmux" session.
export DISPLAY=:##
Running scripts
Starting with 2023 R1, you can run Lumerical scripts (.lsf) from Terminal using 'fdtd-solutions-batch'. This will run the script while "hiding" the CAD/GUI on Linux.
/opt/lumerical/[[verpath]]/bin/fdtd-solutions-batch {script_file.lsf}
Or set the environment variable "QT_QPA_PLATFORM" to "offscreen":
#RHEL/CentOS/Rocky Linux example
export QT_QPA_PLATFORM=offscreen
python3 {api_script_file.py}
See also
Lumerical scripting >> Running Simulations >> Resource Configuration - Ansys Optics