Error occuring in fem.form

I’ve also been having a similar issue, but I have no idea what is happening. Seems to have started with the installation of dolfinx v0.6.0 when I upgraded from v0.5.x

I’m running dolfinx in a conda environment (can provide full package list if it is helpful) and working in VSCode. I was able to reproduce your error message once, but then if I re-run the exact same script in “debug mode”, the error goes away for subsequent runs. How in the world does that happen? (I’ve seen this happen for a few different scripts):

INITIAL RUN ERROR MESSAGE:

(MY_ENV) (base) usr@MACHINE:~/DIR$ /home/usr/anaconda3/envs/MY_ENV/bin/python "/home/usr/DIR/MWEfrompreviouspost.py"
x86_64-conda-linux-gnu-cc: error: unrecognized command-line option '-march'
Traceback (most recent call last):
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
    self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
    spawn(cmd, dry_run=self.dry_run, **kwargs)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
    raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/home/usr/anaconda3/envs/MY_ENV/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/cffi/ffiplatform.py", line 51, in _build
    dist.run_command('build_ext')
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
    super().run_command(command)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
    cmd_obj.run()
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
    _build_ext.run(self)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
    self.build_extensions()
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions
    self._build_extensions_serial()
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
    _build_ext.build_extension(self, ext)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension
    objects = self.compiler.compile(
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 599, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command '/home/usr/anaconda3/envs/MY_ENV/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/usr/DIR/MWEfrompreviouspost.py", line 18, in <module>
    V = fem.FunctionSpace(domain, ("CG", 1))
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/dolfinx/fem/function.py", line 487, in __init__
    (self._ufcx_element, self._ufcx_dofmap), module, code = jit.ffcx_jit(
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/dolfinx/jit.py", line 56, in mpi_jit
    return local_jit(*args, **kwargs)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/dolfinx/jit.py", line 206, in ffcx_jit
    r = ffcx.codegeneration.jit.compile_elements([ufl_object], options=p_ffcx, **p_jit)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 144, in compile_elements
    impl = _compile_objects(decl, elements, names, module_name, p, cache_dir,
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 270, in _compile_objects
    ffibuilder.compile(tmpdir=cache_dir, verbose=True, debug=cffi_debug)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/cffi/api.py", line 725, in compile
    return recompile(self, module_name, source, tmpdir=tmpdir,
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/cffi/recompiler.py", line 1564, in recompile
    outputfilename = ffiplatform.compile('.', ext,
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/cffi/ffiplatform.py", line 22, in compile
    outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
  File "/home/usr/anaconda3/envs/MY_ENV/lib/python3.10/site-packages/cffi/ffiplatform.py", line 58, in _build
    raise VerificationError('%s: %s' % (e.__class__.__name__, e))
cffi.VerificationError: CompileError: command '/home/usr/anaconda3/envs/MY_ENV/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1

Subsequent runs AFTER RUNNING IN DEBUG MODE, do not throw this same error. Very weird.

I also have a more complicated package that seems to keep throwing a similar error. The error seems to show up with the assembly of the RHS petsc vector, regardless of what that form looks like and even for forms that are assembled in a similar “spaghetti code” and run without throwing this error.

The error seems to show up at the creation of the RHS petsc vector

#...... SOME CODE ABOVE
self.b=create_vector(form(self.L_form))
#MORE CODE.....
1 Like