Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run MPI compatible applications from Jupyter notebooks?

So I have a trobule with gmsh.

Direct execution works fine:

!gmsh -3 -algo meshadapt tmp_0.geo -o SFM.msh

While execution from code fails:

try:
    out = subprocess.check_output(
            ["gmsh", "gmsh -3 -algo meshadapt tmp_0.geo -o SFM.msh"],
            stderr=subprocess.STDOUT
            ).strip().decode('utf8')
except subprocess.CalledProcessError as e:
    out = e.output
print(out)

with:

b"--------------------------------------------------------------------------\n[[23419,1],0]: A high-performance Open MPI point-to-point messaging module\nwas unable to find any relevant network interfaces:\n\nModule: OpenFabrics (openib)\n Host: 931136e3f6fe\n\nAnother transport will be used instead, although this may result in\nlower performance.\n--------------------------------------------------------------------------\n\x1b[1m\x1b[31mFatal : Can't open display: (FLTK internal error)\x1b[0m\n--------------------------------------------------------------------------\nMPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD \nwith errorcode 1.\n\nNOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.\nYou may or may not see output from other processes, depending on\nexactly when Open MPI kills them.\n--------------------------------------------------------------------------\n"

So how to emulate ! execution in jupyter from Python 3 code?


@Hristo:

_=/opt/conda/bin/jupyter SHLVL=1 PATH=/opt/conda/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=931136e3f6fe HOME=/root LC_ALL=C.UTF-8 PWD=/ JPY_PARENT_PID=1 LANG=C.UTF-8 TERM=xterm-color CLICOLOR=1 PAGER=cat GIT_PAGER=cat MPLBACKEND=module://ipykernel.pylab.backend_inline env DISPLAY=:0 gmsh -3 -algo meshadapt tmp_0.geo -o SFM.msh

@Gilles: Same result.

like image 427
DuckQueen Avatar asked Sep 15 '17 13:09

DuckQueen


1 Answers

It seems the root cause is the $DISPLAY environment variable is not set.

first make sure $DISPLAY is set when your Jupyter notebook starts. you might also have to direct mpirun to export it to all the MPI tasks.

starting from Open MPI 3.0.0, you can achieve this with export OMPI_MCA_mca_base_env_list=DISPLAY before starting your Jupyter notebook

By the way, should your application need to open the X display ? If it does not do any graphics, then it could be adjusted to work correctly when no display is available.

[ADDENDUM]

An other possibility is that gmsh thinks a display is available since DISPLAY is set, so it tries to open it and fails. You can try to unset this environment variable, and see how things go, both from the command line (e.g. interactive mode) and via the notebook (e.g. batch mode)

like image 189
Gilles Gouaillardet Avatar answered Nov 12 '22 23:11

Gilles Gouaillardet