Can GPU be used in docker version of Dolfinx?

Hello, recently I used dolfinx in docker version 0.4.1.
When I increase the mesh size the program will restart and stop working.
Now I am not using GPU. I was wondering if the fenicx docker is compatible with GPU or any other solution to overcome the problem?
thanks

Dolfinx uses MPI to parallelize the code (over cpus). By executing the code with mpirun -n 3 python3 test.py the data will be distributed and executed. Using three processes.

You should Also consider using iterative solvers to speed up your problem.

Without aa code reproducing this behavior it is hard to give further guidance.

thanks for your response.

this is my code:

!export HDF5_MPI=“ON”
!export CC=mpicc
!export HDF5_DIR=“/usr/lib/x86_64-linux-gnu/hdf5/mpich/”
!pip3 install --no-cache-dir --no-binary=h5py h5py meshio
!apt-get install -qq xvfb
!pip install pyvista panel -q

import dolfinx
print(dolfinx.version)
import meshio
import h5py
from mpi4py import MPI
from dolfinx.io import XDMFFile
from dolfinx.fem import (Constant, dirichletbc, Function, FunctionSpace, assemble_scalar,
form, locate_dofs_geometrical, locate_dofs_topological)
from ufl import (SpatialCoordinate, TestFunction, TrialFunction,
dx, grad, inner)
from petsc4py.PETSc import ScalarType
from dolfinx.fem.petsc import LinearProblem
from dolfinx.plot import create_vtk_mesh
import pyvista
import numpy as np
import sys

def create_mesh(mesh, cell_type, prune_z=False):
cells = mesh.get_cells_type(cell_type)
print(len(cells))
print(len(mesh.points))
cell_data = mesh.get_cell_data(“gmsh:physical”, cell_type)
points = mesh.points[:,:2] if prune_z else mesh.points
out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={“name_to_read”:[cell_data]})
return out_mesh

proc = MPI.COMM_WORLD.rank
mesh_name = “electrode_box_1”
if proc == 0:
# Read in mesh
msh = meshio.read(“mesh_file/{}.msh”.format(mesh_name))
# Create and save one file for the mesh, and one file for the facets
quad_mesh = create_mesh(msh, “quad”, prune_z=False)
tetra_mesh = create_mesh(msh, “tetra”, prune_z=False)
meshio.write(“generated_XDMFs/quad_mesh_{}.xdmf”.format(mesh_name), quad_mesh)
meshio.write(“generated_XDMFs/tetra_mesh_{}.xdmf”.format(mesh_name), tetra_mesh)

with XDMFFile(MPI.COMM_WORLD, “generated_XDMFs/quad_mesh_{}.xdmf”.format(mesh_name), “r”) as xdmf:
subdomains = xdmf.read_mesh(name=‘Grid’)
ct = xdmf.read_meshtags(subdomains, name=“Grid”)

I don’t know how can I upload my .msh file.

Please use markdown syntax, i.e.

```python
def f(x):
    return x[0]
```

to encapsulate your code.
as your mesh is generated with gmsh, could you upload your geo file or the script used to generate the mesh?

this is the updated code

!export HDF5_MPI=“ON”
!export CC=mpicc
!export HDF5_DIR=“/usr/lib/x86_64-linux-gnu/hdf5/mpich/”
!pip3 install --no-cache-dir --no-binary=h5py h5py meshio
!apt-get install -qq xvfb
!pip install pyvista panel -q

import dolfinx
print(dolfinx.**version**)
import meshio
import h5py
from mpi4py import MPI
from [dolfinx.io](http://dolfinx.io) import XDMFFile
from dolfinx.fem import (Constant, dirichletbc, Function, FunctionSpace, assemble_scalar,
form, locate_dofs_geometrical, locate_dofs_topological)
from ufl import (SpatialCoordinate, TestFunction, TrialFunction,
dx, grad, inner)
from petsc4py.PETSc import ScalarType
from dolfinx.fem.petsc import LinearProblem
from dolfinx.plot import create_vtk_mesh
import pyvista
import numpy as np
import sys

def create_mesh(mesh, cell_type, prune_z=False):
    cells = mesh.get_cells_type(cell_type)
    print(len(cells))
    print(len(mesh.points))
    cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
    points = mesh.points[:,:2] if prune_z else mesh.points
    out_mesh = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
    return out_mesh

proc = MPI.COMM_WORLD.rank 
mesh_name = "electrode_direction_copy"
if proc == 0:
    # Read in mesh
    msh = meshio.read("mesh_file/{}.msh".format(mesh_name))
    # Create and save one file for the mesh, and one file for the facets 
    tri_mesh = create_mesh(msh, "triangle", prune_z=False)
    tetra_mesh = create_mesh(msh, "tetra", prune_z=False)
    meshio.write("generated_XDMFs/tri_mesh_{}.xdmf".format(mesh_name), tri_mesh)
    meshio.write("generated_XDMFs/tetra_mesh_{}.xdmf".format(mesh_name), tetra_mesh)

with XDMFFile(MPI.COMM_WORLD, "generated_XDMFs/tetra_mesh_{}.xdmf".format(mesh_name), "r") as xdmf:
    subdomains = xdmf.read_mesh(name='Grid')    
    ct = xdmf.read_meshtags(subdomains, name="Grid")
#Create connectivity between given pair of dimensions, d0 -> d1. ???????????????
subdomains.topology.create_connectivity(subdomains.topology.dim, subdomains.topology.dim-1)
# subdomains.ufl_domain()
# for boundary condition
with XDMFFile(MPI.COMM_WORLD, "generated_XDMFs/tri_mesh_{}.xdmf".format(mesh_name), "r") as xdmf:
    # boundaries_mesh = xdmf.read_mesh(name='Grid')    
    ft = xdmf.read_meshtags(subdomains, name="Grid")

the error is at read_meshtags, which the kernel will die.
and this is my gmsh geo file

// Gmsh project created on Wed Aug 24 09:44:25 2022
SetFactory("OpenCASCADE");
//+
Mesh.CharacteristicLengthFactor = .2;
//+
Cylinder(1) = {-0, -0, 0, 4, 0, 0, .65, 2*Pi};
Cylinder(2) = {4, 0, -0, 1.5, 0, 0, .65, 2*Pi};
Cylinder(3) = {5.5, 0, 0, .5, 0, 0, .65, 2*Pi};
Cylinder(4) = {6, 0, 0, 1.5, 0, 0, .65, 2*Pi};
Cylinder(5) = {7.5, 0, 0, .5, 0, 0, .65, 2*Pi};
Cylinder(6) = {8, 0, 0, 1.5, 0, 0, .65, 2*Pi};
Cylinder(7) = {9.5, 0, 0, .5, 0, 0, .65, 2*Pi};
Cylinder(8) = {10, 0, 0, 0.85, 0, 0, .65, 2*Pi};
Sphere(9) = {10.85, 0, 0, 0.65, -Pi/2, Pi/2, Pi};//+
Rotate {{0, 0, 1}, {10.85, 0, 0}, -Pi/2} {
  Volume{9}; 
}
//+
BooleanUnion{ Volume{8}; Delete; }{ Volume{9}; Delete; }
//+
Box(9) = {-5, -10, -10, 20, 20, 20};
//+
BooleanFragments{ Volume{8}; Volume{7}; Volume{6}; Volume{5}; Volume{4}; Volume{3}; Volume{9}; Volume{2}; Volume{1}; Delete; }{ }

//+
Physical Volume("Brain Box", 33) = {9};
Physical Volume("shaft", 34) = {1};
Physical Volume("Insulation3", 35) = {3};
Physical Volume("Insulation2", 36) = {5};
Physical Volume("Insulation1", 37) = {7};
Physical Volume("Electrode4", 38) = {2};
Physical Volume("Electrode3", 39) = {4};
Physical Volume("Electrode2", 40) = {6};
Physical Volume("Electrode1", 41) = {8};
//+
//boundary conditions
Physical Surface("Brain Surface",42) = {5, 2, 3, 4, 1, 6};
Physical Surface("Active Contact 1",43) = {7,9};
Physical Surface("Active Contact 2",44) = {10};
Physical Surface("Active Contact 3",45) = {12};
Physical Surface("Active Contact 4",46) = {14};
//+

crashing happens while increasing mesh size. with low mesh size the code is running.

Can’t anybody answer to this problem?

I struggle with reproducing your error.

Could I suggest that you try using

dolfinx.io.gmshio.read_from_msh as shown here:

and
https://jorgensd.github.io/dolfinx-tutorial/chapter3/subdomains.html?highlight=read_from_msh#read-in-msh-files-with-dolfinx