slimgroup / JUDI.jl

Julia Devito inversion.
https://slimgroup.github.io/JUDI.jl
MIT License
96 stars 29 forks source link

Failed to run `modeling_basic_2D` example (JUDI 3.1.4) #129

Closed kerim371 closed 2 years ago

kerim371 commented 2 years ago

Hi,

When simply trying to run modeling_basic_2D example an error is arised:

ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/kerim/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError('object.__new__() takes exactly one argument (the type to instantiate)')
  File "/home/kerim/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/pysource/models.py", line 172, in __init__
    initialize_damp(self.damp, self.padsizes, abc_type=abc_type, fs=fs)
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/parameters.py", line 249, in wrapper
    result = func(*args, **kwargs)
  File "/home/kerim/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/pysource/models.py", line 106, in initialize_damp
    op = damp_op(damp.grid.dim, padsizes, abc_type, fs)
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/tools/memoization.py", line 33, in __call__
    value = self.func(*args)
  File "/home/kerim/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/pysource/models.py", line 83, in damp_op
    return Operator(eqs, name='initdamp')
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/operator/operator.py", line 146, in __new__
    kwargs = parse_kwargs(**kwargs)
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/operator/operator.py", line 977, in parse_kwargs
    kwargs['compiler'] = configuration['compiler'].__new_with__()
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/arch/compiler.py", line 190, in __new_with__
    return self.__class__(suffix=kwargs.pop('suffix', self.suffix),
  File "/home/kerim/Documents/Colada/d/python-install/lib/python3.9/site-packages/devito/arch/compiler.py", line 615, in __new__
    obj = super().__new__(cls, *args, **kwargs)

Stacktrace:
  [1] pyerr_check
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/exception.jl:62 [inlined]
  [2] pyerr_check
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/exception.jl:66 [inlined]
  [3] _handle_error(msg::String)
    @ PyCall ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/exception.jl:83
  [4] macro expansion
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/exception.jl:97 [inlined]
  [5] #107
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 [inlined]
  [6] disable_sigint
    @ ./c.jl:458 [inlined]
  [7] __pycall!
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:42 [inlined]
  [8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}, Tuple{Int64, Int64}, PyCall.PyObject}, nargs::Int64, kw::PyCall.PyObject)
    @ PyCall ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:29
  [9] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Tuple{Float64, Float64}, Tuple{Float64, Float64}, Tuple{Int64, Int64}, PyCall.PyObject}, kwargs::Base.Iterators.Pairs{Symbol, Union{Nothing, Real}, NTuple{5, Symbol}, NamedTuple{(:fs, :nbl, :space_order, :dt, :dm), Tuple{Bool, Int64, Int64, Float64, Nothing}}})
    @ PyCall ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:11
 [10] (::PyCall.PyObject)(::Tuple{Float64, Float64}, ::Vararg{Any, N} where N; kwargs::Base.Iterators.Pairs{Symbol, Union{Nothing, Real}, NTuple{5, Symbol}, NamedTuple{(:fs, :nbl, :space_order, :dt, :dm), Tuple{Bool, Int64, Int64, Float64, Nothing}}})
    @ PyCall ~/Documents/Colada/d/julia-1.6/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86
 [11] devito_model(model::Model, options::JUDIOptions, dm::Nothing)
    @ JUDI ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/Utils/auxiliaryFunctions.jl:31
 [12] time_modeling(model_full::Model, srcGeometry::GeometryIC{Float32}, srcData::Matrix{Float32}, recGeometry::GeometryIC{Float32}, recData::Nothing, dm::Nothing, op::Symbol, options::JUDIOptions)
    @ JUDI ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/Modeling/time_modeling_serial.jl:33
 [13] propagate(F::judiDataSourceModeling{Float32, :forward}, q::judiVector{Float32, Matrix{Float32}})
    @ JUDI ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/Modeling/propagation.jl:9
 [14] run_and_reduce(func::Function, #unused#::Nothing, nsrc::Int64, arg_func::JUDI.var"#196#197"{judiDataSourceModeling{Float32, :forward}, judiVector{Float32, Matrix{Float32}}})
    @ JUDI ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/Modeling/propagation.jl:37
 [15] multi_src_propagate(F::judiDataSourceModeling{Float32, :forward}, q::judiVector{Float32, Matrix{Float32}})
    @ JUDI ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/Modeling/propagation.jl:66
 [16] *
    @ ~/Documents/Colada/d/julia-1.6/.julia/packages/JUDI/jk3ff/src/TimeModeling/LinearOperators/operators.jl:172 [inlined]
 [17] afoldl
    @ ./operators.jl:533 [inlined]
 [18] *(a::judiProjection{Float32}, b::judiModeling{Float32, :forward}, c::JUDI.jAdjoint{judiProjection{Float32}}, xs::judiVector{Float32, Matrix{Float32}})
    @ Base ./operators.jl:560
 [19] top-level scope
    @ ~/Documents/Colada/d/julia-1.6/.julia/dev/JUDI/examples/scripts/modeling_basic_2D.jl:123

I believe this happen on the line dobs = PrFadjoint(Ps)*q

JUDI 3.1.4 PyCall 1.93.1 Ubuntu 20.04

mloubout commented 2 years ago

It looks like you have some custom compiler setup that devito doesn't like (CC, CFLAGS, DEVITO_ARCH,....) can you check your environment for oddities?

kerim371 commented 2 years ago

@mloubout yes that is right.

I have GCC-9.4.0 compiler that comes by default with Ubuntu 20.04 And also I have GCC-11.3.1 compiled from source and located in /home/kerim/gcc/11/bin/gcc.

Then to work with my C++ project and GCC-11 I have set some env vars to .bashrc:

# run CMake with gcc-11 by default
export CC=/home/kerim/gcc/11/bin/gcc
export CXX=/home/kerim/gcc/11/bin/g++

# add GCC11 and GCC12 GLIBCXX_... to be able to compile and link with those compilers
export LD_LIBRARY_PATH=/home/kerim/gcc/11/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/kerim/gcc/12/lib64:$LD_LIBRARY_PATH

Earlier I used to work with JUDI when GCC-9.3 (or 9.4) was active compiler and there were no CC or CXX env vars and it used to run smoothly.

I believe in such situation I have an option either to work with the default GCC-9.4 or to struggle with this issue. Just to take a chance, what may be my first step to make Devito work with GCC-11?

mloubout commented 2 years ago

Devito works with gcc-11 but you need to use DEVITO_ARCH=custom if you wanna use those CC/CXX.

You can also make a symlink to your gcc-11 in your path and set DEVITO_ARCH=gcc-11 . If that one not working may need a tiny patch in devito feel free to open an issue there

kerim371 commented 2 years ago

You can also make a symlink to your gcc-11 in your path and set DEVITO_ARCH=gcc-11 . If that one not working may need a tiny patch in devito feel free to open an issue there

Adding gcc-11 symlink to bin dir (that is my path) and setting DEVITO_ARCH=gcc-11 worked, thank you!

P.S. I deleted two my posts as they were unrelated to JUDI and arised because of my carelessness