radiasoft / download

Install scripts for "curl | bash"
Apache License 2.0
3 stars 5 forks source link

Add python support to ImpactX build #680

Closed moellep closed 3 months ago

moellep commented 3 months ago

We'll need the "impactx" python library as well. I think that gets added with -DImpactX_PYTHON=ON.

moellep commented 3 months ago

Also double check that the python bindings works after the build - some people haven't been able to get it to work when building locally.

cchall commented 3 months ago

I had tried building with Python enabled on jupyter and got an error on import:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[15], line 1
----> 1 import impactx

File ~/.pyenv/versions/py3/lib/python3.9/site-packages/impactx/__init__.py:20
     17             os.add_dll_directory(p_abs)
     19 # import core bindings to C++
---> 20 from . import impactx_pybind as cxx
     21 from .extensions.ImpactXParIter import register_ImpactXParIter_extension
     22 from .extensions.ImpactXParticleContainer import (
     23     register_ImpactXParticleContainer_extension,
     24 )

ImportError: /home/vagrant/.pyenv/versions/py3/lib/python3.9/site-packages/impactx/impactx_pybind.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZN5amrex12FabArrayBase20m_alloc_single_chunkE

The impactx executable worked fine though.

ax3l commented 3 months ago

Hi @cchall, can you point me to the build script? I think this might just be a small version mismatch of some kind in dependencies.

My suspicion is:

The solution might be as easy as removing any old build directory if present.

ax3l commented 3 months ago

Also double check that the python bindings works after the build - some people haven't been able to get it to work when building locally.

@moellep oh no, let me know where people got stuck please.

I will reduce the info in the ImpactX readme file to avoid duplication. The recommended install docs are:

cchall commented 3 months ago

@ax3l I just followed the developer build commands

cmake -S . -B build -DImpactX_PYTHON=ON cmake --build build -j 4

I tried repeating this after clearing out build. It looks like amrex version 24.04 is should be used, which I think was released right after the commit you pointed to. I noticed that previously the impactx import was not pointing to the version in build/. However, I still get the same error:

In [3]: import impactx
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 import impactx

File ~/jupyter/repos/impactx/build/lib/site-packages/impactx/__init__.py:20
     17             os.add_dll_directory(p_abs)
     19 # import core bindings to C++
---> 20 from . import impactx_pybind as cxx
     21 from .extensions.ImpactXParIter import register_ImpactXParIter_extension
     22 from .extensions.ImpactXParticleContainer import (
     23     register_ImpactXParticleContainer_extension,
     24 )

ImportError: /home/vagrant/jupyter/repos/impactx/build/lib/site-packages/impactx/impactx_pybind.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZN5amrex12FabArrayBase20m_alloc_single_chunkE

I've attached the full log. It's also certainly possible that there might be an older version of amrex in our environment that is being grabbed. impactx.log

ax3l commented 3 months ago

Hi @cchall ,

I think I see what this does from #677 now.

You want to add something like

codes_dependencies common
codes_dependencies amrex
codes_dependencies pyamrex
...
codes_cmake2 \
  -DCMAKE_INSTALL_PREFIX="${codes_dir[prefix]}" \
  -DImpactX_amrex_internal=OFF  \
  -DImpactX_pyamrex_internal=OFF

to disable the ImpactX superbuilds and rely on a shared external amrex library. https://impactx.readthedocs.io/en/latest/install/cmake.html#compile

Also, a pyamrex package will be needed that also depends on amrex.

ax3l commented 3 months ago

Just FYI, this is the BLAST Exascale software stack. Elements on top depend on elements below them. image

If you only deploy ImpactX, ignore in situ visualization, ABLASTR, PICSAR-QED, and Lin. Alg. for now. FFT (FFTW on CPU, CUDA/HIP ship cuFFT/rocFFT for GPU) will be part of the ImpactX dependencies in 24.06+ (for our IGF Poisson solver).

If it is easier for you to read other package managers, here are our conda recipes:

(see also the conda build and test scripts in the same directories)

ax3l commented 3 months ago

I added some suggestions in #682, but I do not know how to test this (help welcome :) )

e-carlin commented 3 months ago

Fixed by https://github.com/radiasoft/download/pull/682