A multi-GPUs test for Oceananigans #4791
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
I could be wrong but I don't think you need to manually set the visible devices. With two processes you will use device 0 and 1 by default anyways? Since the segmentation fault occurs at bᵢ(x,y,z) = ...so I am not sure what the problem is. But one way to test this is to use |
Beta Was this translation helpful? Give feedback.
-
|
Hi, I have got a similar problem. How did you fix it? Thanks! using CUDA
using Oceananigans
using Oceananigans.Units: minute, minutes, hours
using Oceananigans.Units: GiB, MiB, KiB
using Statistics
using Oceananigans.TurbulenceClosures: viscous_flux_uz
using CairoMakie
using MPI
if !MPI.Initialized()
MPI.Init()
end
child_architecture = GPU()
architecture = Distributed(child_architecture)
const H=15 #/m
grid = RectilinearGrid(architecture, size=(128,128,128), extent=(π*H, π*H/2, H),halo = (4,4,4))
const u★=0.01 #friction velocity
const g_Earth = 9.81 # m/s
Fx(x,y,z,t)=u★^2/H #forcing
z₀ = 0.01 # m (roughness length)
κ = 0.4 # von Karman constant
z₁ = grid.Lz+znodes(grid, Center())[1] # Closest grid center to the bottom
cᴰᵇ = (κ / log(z₁ / z₀))^2 # Drag coefficient
@inline drag_u(x, y, t, u, v, p) = - p.cᴰᵇ * √(u^2 + v^2) * (u)
@inline drag_v(x, y, t, u, v, p) = - p.cᴰᵇ * √(u^2 + v^2) * (v)
drag_bc_u = FluxBoundaryCondition(drag_u, field_dependencies=(:u, :v), parameters=(; cᴰᵇ))
drag_bc_v = FluxBoundaryCondition(drag_v, field_dependencies=(:u, :v), parameters=(; cᴰᵇ))
u_bcs = FieldBoundaryConditions(bottom = drag_bc_u)
v_bcs = FieldBoundaryConditions(bottom = drag_bc_v)
T_bcs = FieldBoundaryConditions(top=FluxBoundaryCondition(0.0),
bottom=FluxBoundaryCondition(0.0))
S_bcs = FieldBoundaryConditions(top=FluxBoundaryCondition(0.0),bottom=FluxBoundaryCondition(0.0))
model = NonhydrostaticModel(; grid,
advection = WENO(order=9),
timestepper = :RungeKutta3,
tracers =(:T,:S),
buoyancy = SeawaterBuoyancy(),
closure = AnisotropicMinimumDissipation(),
boundary_conditions = (u=u_bcs,v=v_bcs,T=T_bcs,S=S_bcs),
forcing=(u=Fx,))
Ξ(z) = randn()*exp(z/4)
uᵢ(x, y, z) = u★ * 1e-2 * Ξ(z) + 0.21
wᵢ(x, y, z) = u★ * 1e-2 * Ξ(z)
vᵢ(x, y, z) = u★ * 1e-2 * Ξ(z)
Tᵢ=290 #K
Sᵢ=35 #PSU
set!(model)
simulation = Simulation(model, Δt=0.4, stop_time=24hours)
wizard = TimeStepWizard(cfl=0.8, max_change=1.1, max_Δt=0.1minute)
simulation.callbacks[:wizard] = Callback(wizard, IterationInterval(10))
using Printf
function progress(simulation)
u, v, w = simulation.model.velocities
## Print a progress message
msg = @sprintf("i: %04d, t: %s, Δt: %s, umax = (%.5e, %.5e, %.5e) ms⁻¹, wall time: %s\n",
iteration(simulation),
prettytime(time(simulation)),
prettytime(simulation.Δt),
maximum(abs, u), maximum(abs, v), maximum(abs, w),
prettytime(simulation.run_wall_time))
@info msg
return nothing
end
simulation.callbacks[:progress] = Callback(progress, IterationInterval(50))
run!(simulation) |
Beta Was this translation helpful? Give feedback.



it might be that your cuda-aware MPI is not enabled. I see that you are using openmpi. You can try doing
if the output is false, then it means that cuda-aware MPI is not active. You can find more information here https://juliaparallel.org/MPI.jl/stable/knownissues/#CUDA-aware-MPI