Dear all,
I recently bought a new computer and installed fenicsx (0.6.0) on WSL2 (Ubuntu) through anaconda.
I tried to run some old code on my new computer (same version of fenicsx as before), and while the first time it ran, it ran fine, but the second time when I changed a variable in my fem.form (e.g. dt) I got an error. The code I used here to generate the error is just an adapted version of the heat equation tutorial (I know it can be done more efficiently as is done in the real tutorial, but I have the same error for code where both the bilinear and linear form are time-dependent so this is the easiest similar case I could come up with. Update: I also get the exact same error when completely copy-pasting the tutorial):
import numpy as np
from mpi4py import MPI
from petsc4py import PETSc
from dolfinx import fem, mesh, io, plot
# Define temporal parameters
t = 0 # Start time
T = 1.0 # Final time
num_steps = 50
dt = T / num_steps # time step size
# Define mesh
nx, ny = 50, 50
domain = mesh.create_rectangle(MPI.COMM_WORLD, [np.array([-2, -2]), np.array([2, 2])],
[nx, ny], mesh.CellType.triangle)
V = fem.FunctionSpace(domain, ("CG", 1))
# Create initial condition
def initial_condition(x, a=5):
return np.exp(-a*(x[0]**2+x[1]**2))
u_n = fem.Function(V)
u_n.name = "u_n"
u_n.interpolate(initial_condition)
# Create boundary condition
fdim = domain.topology.dim - 1
boundary_facets = mesh.locate_entities_boundary(
domain, fdim, lambda x: np.full(x.shape[1], True, dtype=bool))
bc = fem.dirichletbc(PETSc.ScalarType(0), fem.locate_dofs_topological(V, fdim, boundary_facets), V)
xdmf = io.XDMFFile(domain.comm, "diffusion.xdmf", "w")
xdmf.write_mesh(domain)
# Define solution variable, and interpolate initial solution for visualization in Paraview
uh = fem.Function(V)
uh.name = "uh"
uh.interpolate(initial_condition)
xdmf.write_function(uh, t)
import ufl
u, v = ufl.TrialFunction(V), ufl.TestFunction(V)
f = fem.Constant(domain, PETSc.ScalarType(0))
for i in range(num_steps):
t += dt
a = u * v * ufl.dx + dt*ufl.dot(ufl.grad(u), ufl.grad(v)) * ufl.dx
L = (u_n + dt * f) * v * ufl.dx
bilinear_form = fem.form(a)
linear_form = fem.form(L)
A = fem.petsc.assemble_matrix(bilinear_form, bcs=[bc])
A.assemble()
b = fem.petsc.create_vector(linear_form)
fem.petsc.set_bc(b, [bc])
b.assemble()
solver = PETSc.KSP().create(domain.comm)
solver.setOperators(A)
solver.setType(PETSc.KSP.Type.PREONLY)
solver.getPC().setType(PETSc.PC.Type.LU)
# Solve linear problem
solver.solve(b, uh.vector)
# Update solution at previous time step (u_n)
u_n.x.array[:] = uh.x.array
# Write solution to file
xdmf.write_function(uh, t)
xdmf.close()
The error I got out is the following:
INFO:root:running build_ext
INFO:root:building 'libffcx_forms_1790fb3e8ead4c2bdbfebd6a45e3be2c80395974' extension
INFO:root:/home/rsmeets/anaconda3/envs/fenicsx/bin/x86_64-conda-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -fPIC -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -march -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/rsmeets/anaconda3/envs/fenicsx/include -DNDEBUG -D_FORTIFY_SOURCE -fPIC -I/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/ffcx/codegeneration -I/home/rsmeets/anaconda3/envs/fenicsx/include/python3.10 -c libffcx_forms_1790fb3e8ead4c2bdbfebd6a45e3be2c80395974.c -o ./libffcx_forms_1790fb3e8ead4c2bdbfebd6a45e3be2c80395974.o -O2 -g0
x86_64-conda-linux-gnu-cc: error: unrecognized command-line option '-march'
Traceback (most recent call last):
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 185, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 1041, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn
raise DistutilsExecError(
distutils.errors.DistutilsExecError: command '/home/rsmeets/anaconda3/envs/fenicsx/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/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/cffi/ffiplatform.py", line 51, in _build
dist.run_command('build_ext')
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 88, in run
_build_ext.run(self)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run
self.build_extensions()
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions
self._build_extensions_serial()
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial
self.build_extension(ext)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 249, in build_extension
_build_ext.build_extension(self, ext)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension
objects = self.compiler.compile(
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/home/rsmeets/anaconda3/envs/fenicsx/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/rsmeets/coding/biolin/minworkexample.py", line 53, in <module>
bilinear_form = fem.form(a)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 176, in form
return _create_form(form)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 171, in _create_form
return _form(form)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/dolfinx/fem/forms.py", line 145, in _form
ufcx_form, module, code = jit.ffcx_jit(mesh.comm, form,
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/dolfinx/jit.py", line 56, in mpi_jit
return local_jit(*args, **kwargs)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/dolfinx/jit.py", line 204, in ffcx_jit
r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/ffcx/codegeneration/jit.py", line 186, in compile_forms
impl = _compile_objects(decl, forms, form_names, module_name, p, cache_dir,
File "/home/rsmeets/anaconda3/envs/fenicsx/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/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/cffi/api.py", line 725, in compile
return recompile(self, module_name, source, tmpdir=tmpdir,
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/cffi/recompiler.py", line 1564, in recompile
outputfilename = ffiplatform.compile('.', ext,
File "/home/rsmeets/anaconda3/envs/fenicsx/lib/python3.10/site-packages/cffi/ffiplatform.py", line 22, in compile
outputfilename = _build(tmpdir, ext, compiler_verbose, debug)
File "/home/rsmeets/anaconda3/envs/fenicsx/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/rsmeets/anaconda3/envs/fenicsx/bin/x86_64-conda-linux-gnu-cc' failed with exit code 1
I think the real error is in the third section and thus seems to have to do something with fem.form (I see these first two blocks almost always when there is an error with the third block). I have the same error with other code where I want to change parameters in fem.form. Has anyone encountered this problem before and/or knows how to solve it? I have tried deleting the environment with fenicsx and the package, and reinstalling but that did not work unfortunately.
Many thanks,
Robin