PyMFEM icon indicating copy to clipboard operation
PyMFEM copied to clipboard

Up-to-date installation for parallel version?

Open dreamer2368 opened this issue 1 year ago • 7 comments

Installying PyMFEM with pip install mfem --install-option="--with-parallel" does not work any longer, since --install-option became deprecated due to the recent update. I tried to follow the other option of cloning the repo and using setup.py, but it also fails with the following message:

calling ... /usr/local/bin/swig -Wall -c++ -python -fastproxy -olddefs -keyword -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include/mfem -I/home/test/PyMFEM/external/mfem -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mpi4py/include blockmatrix.i
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/test/PyMFEM/setup.py", line 314, in make_call                                                                       
    raise subprocess.CalledProcessError(p.returncode,                                                                         
subprocess.CalledProcessError: Command '/usr/local/bin/swig -Wall -c++ -python -fastproxy -olddefs -keyword -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include/mfem -I/home/test/PyMFEM/external/mfem -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mpi4py/include dist_solver.i' returned non-zero exit status 1.
"""                                                                                                                                                                                                                                                         
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/test/PyMFEM/setup.py", line 1881, in <module>
    main()
  File "/home/test/PyMFEM/setup.py", line 1877, in main
    run_setup()                                                                                                                 
  File "/home/test/PyMFEM/setup.py", line 1865, in run_setup                                                                      
    setup(                                                                                                                      
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup                                                
    return distutils.core.setup(**attrs)                                                                                        
  File "/usr/lib/python3.10/distutils/core.py", line 148, in setup                                                                
    dist.run_commands()                                                                                                         
  File "/usr/lib/python3.10/distutils/dist.py", line 966, in run_commands                                                         
    self.run_command(cmd)                                                                                                       
  File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command                                                          
    cmd_obj.run()                                                                                                               
  File "/home/test/PyMFEM/setup.py", line 1662, in run                                                                            
    _install.run(self)                                                                                                          
  File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 72, in run                                            
    orig.install.run(self)                                                                                                      
  File "/usr/lib/python3.10/distutils/command/install.py", line 619, in run                                                       
    self.run_command('build')                                                                                                   
  File "/usr/lib/python3.10/distutils/cmd.py", line 313, in run_command                                                           
    self.distribution.run_command(command)                                                                                      
  File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command                                                          
    cmd_obj.run()                                                                                                               
  File "/usr/lib/python3.10/distutils/command/build.py", line 135, in run                                                         
    self.run_command(cmd_name)                                                                                                  
  File "/usr/lib/python3.10/distutils/cmd.py", line 313, in run_command                                                           
    self.distribution.run_command(command)                                                                                      
  File "/usr/lib/python3.10/distutils/dist.py", line 985, in run_command                                                          
    cmd_obj.run()                                                                                                               
  File "/home/test/PyMFEM/setup.py", line 1717, in run                                                                            
    generate_wrapper()                                                                                                          
  File "/home/test/PyMFEM/setup.py", line 1099, in generate_wrapper                                                               
    mp_pool.map(make_call, commands)                                                                                            
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 367, in map                                                            
    return self._map_async(func, iterable, mapstar, chunksize).get()                                                            
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 774, in get                                                            
    raise self._value                                                                                                         
subprocess.CalledProcessError: Command '/usr/local/bin/swig -Wall -c++ -python -fastproxy -olddefs -keyword -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/par/include/mfem -I/home/test/PyMFEM/external/mfem -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mfem/external/include -I/usr/local/lib/python3.10/dist-packages/mpi4py/include dist_solver.i' returned non-zero exit status 1.

What is the most up-to-date installation procedure for parallel PyMFEM?

dreamer2368 avatar Jul 13 '23 16:07 dreamer2368

An update: I tried to install the parallel version with

git clone https://github.com/mfem/PyMFEM.git
cd PyMFEM
python3 setup.py install --with-parallel

It seems to successfully build PyMFEM with the following output:

...
byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/mem_manager.py to mem_manager.cpython-310.pyc
byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/sort_pairs.py to sort_pairs.cpython-310.pyc
running install_egg_info
running egg_info
creating mfem.egg-info
writing mfem.egg-info/PKG-INFO
writing dependency_links to mfem.egg-info/dependency_links.txt
writing requirements to mfem.egg-info/requires.txt
writing top-level names to mfem.egg-info/top_level.txt
writing manifest file 'mfem.egg-info/SOURCES.txt'
reading manifest file 'mfem.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'external/README.txt'
adding license file 'LICENSE'
writing manifest file 'mfem.egg-info/SOURCES.txt'
Copying mfem.egg-info to /usr/lib/python3.10/site-packages/mfem-4.5.2.0-py3.10.egg-info
running install_scripts
test@9a0a7bde1732:~/PyMFEM$

However, importing it on python shell throws the following error:

test@9a0a7bde1732:~$ python3
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mfem
>>> mfem.__path__
['/usr/lib/python3.10/site-packages/mfem']
>>> import mfem.par as mfem
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/mfem/par.py", line 12, in <module>
    from  mfem._par.globals import *
  File "/usr/lib/python3.10/site-packages/mfem/_par/globals.py", line 10, in <module>
    from . import _globals
ImportError: libmfem.so.4.5.2: cannot open shared object file: No such file or directory

When I looked into /usr/lib/python3.10/site-packages/mfem, I could not find the libmfem.so.4.5.2 file.

dreamer2368 avatar Aug 04 '23 05:08 dreamer2368

Can you please post the entire log? Thank you.

sshiraiwa avatar Aug 04 '23 11:08 sshiraiwa

Attached is the entire log of the python command I tried above. It finished without any error, but having an import error within python as reported above. pymfem.log

dreamer2368 avatar Aug 04 '23 16:08 dreamer2368

Another update I was able to install parallel PyMFEM with the following command:

python3 setup.py install --with-parallel --user

The default command python3 setup.py install --with-parallel has a problem when run on Debian/Ubuntu. In the pymfem.log attached above, all the paths are set to dist-packages directory:

ext_prefix running external_install_prefix with the following parameters sys.argv : ['setup.py', 'install', '--with-parallel'] sys.prefix : /usr usersite : /root/.local/lib/python3.10/site-packages prefix : /usr ----configuration---- prefix /usr when needed, the dependency (mfem/hypre/metis) will be installed under /usr/local/lib/python3.10/dist-packages/mfem/external build mfem : Yes build metis : Yes build hypre : Yes build libceed : No build gslib : No call SWIG wrapper generator: Yes build serial wrapper: Yes build parallel wrapper : Yes hypre prefix /usr/local/lib/python3.10/dist-packages/mfem/external metis prefix /usr/local/lib/python3.10/dist-packages/mfem/external c compiler : cc c++ compiler : c++ mpi-c compiler : mpicc mpi-c++ compiler : mpic++ verbose : No SWIG : /usr/local/bin/swig

However, at the last steps of installation, the files are installed to site-packages directory:

byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/hash.py to hash.cpython-310.pyc byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/socketstream.py to socketstream.cpython-310.pyc byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/mem_manager.py to mem_manager.cpython-310.pyc byte-compiling /usr/lib/python3.10/site-packages/mfem/_ser/sort_pairs.py to sort_pairs.cpython-310.pyc running install_egg_info running egg_info creating mfem.egg-info writing mfem.egg-info/PKG-INFO writing dependency_links to mfem.egg-info/dependency_links.txt writing requirements to mfem.egg-info/requires.txt writing top-level names to mfem.egg-info/top_level.txt writing manifest file 'mfem.egg-info/SOURCES.txt' reading manifest file 'mfem.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'external/README.txt' adding license file 'LICENSE' writing manifest file 'mfem.egg-info/SOURCES.txt' Copying mfem.egg-info to /usr/lib/python3.10/site-packages/mfem-4.5.2.0-py3.10.egg-info running install_scripts

It seems that using --user unifies all the paths to site-packages, however not all the paths are set correctly when --user is not used.

I think there are some path mismatches in case of not using --user, particularly in _install_lib and _install_egg_info. Would it be possible to be fixed? We would want to not use --user so that PyMFEM is accessible to all users in the system.

dreamer2368 avatar Aug 11 '23 00:08 dreamer2368

@sshiraiwa , is it okay to invite me to this repo? I think I found a fix for this, but could not make a pull request due to permission issue.

dreamer2368 avatar Aug 11 '23 04:08 dreamer2368

Are there any updates on this? I can't get PyMFEM built with parallel on either Linux or MacOS right now. On Linux I'm having issues with CMake, but on MacOS, I execute python3 setup.py install --with-parallel and it breaks with:

Failed when calling command: /usr/local/opt/[email protected]/bin/python3.11 generate_lininteg_ext.py
Traceback (most recent call last):
  File "/Users/lyons/src/PyMFEM/setup.py", line 1894, in <module>
    main()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1890, in main
    run_setup()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1878, in run_setup
    setup(
  File "/usr/local/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
    super().run_command(command)
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1675, in run
    _install.run(self)
  File "/usr/local/lib/python3.11/site-packages/setuptools/command/install.py", line 82, in run
    orig.install.run(self)
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/install.py", line 697, in run
    self.run_command('build')
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
    super().run_command(command)
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
    self.run_command(cmd_name)
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
    super().run_command(command)
  File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1730, in run
    generate_wrapper()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1058, in generate_wrapper
    update_integrator_exts()
  File "/Users/lyons/src/PyMFEM/setup.py", line 1011, in update_integrator_exts
    make_call(command1)
  File "/Users/lyons/src/PyMFEM/setup.py", line 319, in make_call
    raise subprocess.CalledProcessError(p.returncode,
subprocess.CalledProcessError: Command '/usr/local/opt/[email protected]/bin/python3.11 generate_lininteg_ext.py' returned non-zero exit status 1.

When I re-execute the offending command, I get:

>/usr/local/opt/[email protected]/bin/python3.11 generate_lininteg_ext.py
WhiteGaussianNoiseDomainLFIntegrator
    def __init__(self, seed_=0):

Traceback (most recent call last):
  File "/Users/lyons/src/PyMFEM/mfem/common/generate_lininteg_ext.py", line 30, in <module>
    assert False, "No recipt for this pattern "
AssertionError: No recipt for this pattern 

I can open a separate issue if necessary.

bclyons12 avatar Feb 05 '24 19:02 bclyons12

I see now that the above error is being addressed by #208

bclyons12 avatar Feb 05 '24 21:02 bclyons12