Python API on Cluster

I am using FDTD solutions. I have a Python script that I have written on my local computer. When I try to create an FDTD object on the cluster,

fdtd = lumapi.FDTD()

I receive an error message:

module 'lumapi' has no attribute 'FDTD'

I do not see this message on my local machine where my code works fine. I’ve looked at help(lumapi) on both my local machine and the cluster. It seems that many of the attributes I need are not available on the cluster. What may be the cause of this?

Thank you in advance for your help.

Hi @holdman,

Our apologies for the long wait! It might be a version problem. Can you check what version of our products is installed on the cluster?
The initial version of our Python API used lumapi.open() to open a session and was fairly limited. In any case, we would suggest to update to the latest version (2019a) that was released a few weeks ago.

No problem! I hope you had a nice holiday.

On the cluster, the Lumerical API version is 1.15.1 (found from print(lumapi.__version__)). The FDTD Engine is running version 8.19.1466 Linux 64-bit (the output of opt/.../fdtd-engine -v).

I also noticed that the command opt/.../fdtd-solutions -v produced a blank output, rather than printing the version number. There were no errors, just a new line. Does this mean the GUI is not installed? Or is it because I don’t have a graphical connection to the cluster? Perhaps I need a graphical connection to use Python?

Thanks, I had very nice holidays! :slight_smile: I hope you as well!

Ok, the version on the cluster is quite old (2018a release from Nov 2017). It won’t hurt to update it. That said, I don’t think it’s the main cause of the issue.
As you supposed, the fdtd-solutions exec requires a graphical connection to work. So the Python API won’t be able to start a FDTD() session. I was expecting this to give an error, but maybe the absence of graphical connection prevents the API to load all the attributes.

Ah, that all makes sense. I’m assuming that means I also need a graphical connection to use a lsf script ? I have an iterative optimization algorithm that runs an fsp file and updates the objects in the file based on the results. It then reruns the file until a convergence condition is reached. As far as I know I need to use a script for that. I’ll see if I can get a graphical connection to the cluster, and if not maybe there’s some other workaround.

I will also suggest that the team update the lumerical version.

Thank you for your help!

That is correct: lsf scripts are run by the user interface, so a graphical connection is required. This can be tricky on a cluster although there is often at least 1 interactive node with graphic interface.

You can possibly do this via a lsf script, but also via a Python script. Basically, all Lumerical Script Commands are available as Python Session Methods so with some adaptation, if you have a lsf script, you can do the same with Python.

You are most welcome! :slight_smile:

A post was split to a new topic: Issue with port forwarding whem using Python API

I think the task can be splited into several steps:
a) creaste the fsp files(through lsf ) in local machine with FDTDsolutions GUI (or any machine with GUI )
b) transport fsp files to node on cluster (linux nfs,network file system).
c)run the simulation without GUI
b) transport fsp files to machine with gui
d) get result and generate new fsp files (through lsf script)
e)go back to b)

Hi @wenqiang.wang,

Absolutely, this can be done, it is a bit more complex as, for an optimization, you need the results of 1 generation to get the parameters for the next.
For a parameter sweep, it is way easier, as you just need to generate all the simulation files, submit them to the cluster and then load the results when all simulations are done.