-
Notifications
You must be signed in to change notification settings - Fork 233
NetCDFWriter scalar indexing error on GPU #4397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Do you mind pasting your whole script if possible? It will help to be able to reproduce the error! |
Thanks Greg! The code is attached below. It likely doesn't give any meaningful results - this is just a demonstration to show how the setup works.
|
@xiaozhour do you still get this error if you don't have the background field? |
Yep @glwagner |
Probably same problem over here: #4433 @xiaozhour it might help if you confirm the Oceanangians version and julia version you're using. |
Thanks, @glwagner. Oceananigans is v0.96.3 and Julia is 1.10.9. |
Not sure it'd make a difference, but can you try running the latest Oceananigans version? |
@tomchor Updating to v0.96.21 didn't help |
Hi all, |
It's likely the change from 0.95 to 0.96 that broke this case. If you can confirm it might help. I am somewhat puzzled --- isn't NetCDFWriter tested on GPU? |
It is: Oceananigans.jl/test/test_netcdf_writer.jl Lines 2729 to 2777 in fa62396
|
It has to do with the stretched dimension. Probably when writing the grid metrics somewhere. Here's a MWE for the record: using Oceananigans
using NCDatasets
L = 1
N = 4
grid = RectilinearGrid(GPU(); size = (N, N, N),
x = (0, L),
y = (0, L),
z = 1:N+1)
model = NonhydrostaticModel(; grid)
simulation = Simulation(model, Δt=1, stop_time=1)
NetCDFWriter(model, model.velocities;
filename = "mwe",
schedule = TimeInterval(1),
overwrite_existing = true) |
@xiaozhour as a side note, whenever you encounter an issue like this, it's best to keep removing things from your code until you reach a minimal working example (MWE, or more correctly called MRE). If you do that, generally one of two things happen. You either:
I think for me I end up finding out I need to fix my own code more often than not 😆 |
Hi all,
I got a weird error on a simple output line with NetCDFWriter on GPU. Switching to JLD2Writer removes the error. Any insights would be appreciated!
The error massage is the following:
ERROR: Scalar indexing is disallowed.
Invocation of getindex resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations do not execute on the GPU, but very slowly on the CPU,
and therefore should be avoided.
If you want to allow scalar iteration, use
allowscalar
or@allowscalar
to enable scalar iteration globally or for the operations in question.
Stacktrace:
The text was updated successfully, but these errors were encountered: