-
Notifications
You must be signed in to change notification settings - Fork 211
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
Error only while debugging in VSCode #3171
Comments
Hm… I use VS Code all the time …
? |
thank you for replying, here is the output from the environment that I run the code in:
I'm able to set breakpoints and debug the code for all of the other Julia code that I run - I'm also able to run the quick start example when I run the julia script I only get the error I shared above while setting breakpoints for the quick start example I have installed Oceananigans in editable/dev mode - the debugger does refer to the installed package - I get the same error even when I install Oceananigans via thank you for helping me! |
And you said outside VS Code things seem fine? Can you post the same output there? |
it runs as expected even when I run the script in VSCode, the output is:
I only get the error when I insert breakpoints in the quick start example and try to step through the code:
I've shared the exact line that throws the error in my original question greatly appreciate your help! |
Oh I see. Just to make sure I understand, you are saying:
I have never used the debugger of VS Code I must admit... Just want to ensure that 2 is OK but 3 is not. |
that's exactly right - 2 is ok, 3 is not also, 3 is ok for any non-Oceananigans Julia code using the debugger with VScode on the quick start example should reproduce the error thank you again! |
hm... OK, I see. Let me try playing around then. Where can I find some info about the VS Code's debugging mode? But also I wanted to point out that you have a lot of unrelated packages installed in the same environment like Oceananigans (eg, conda, dagger, ScikitLearn, DifferentialEquations,...) Just to ensure that this is not any sort of incompatibility between various deps versions, can you create an empty environment, just have Oceananigans there and try to do 3. and confirm that you get the same issue? |
this source has detailed info on using the VSCode debugger with Julia: https://www.julia-vscode.org/docs/stable/userguide/debugging/ if you use VSCode to run Julia, everything should already be set up I'll create a new environment and check and get back thank you again! |
no worries! |
I can confirm that I'm getting the same error in a new environment with just Oceananigans installed looks like this error occurs on the lines of code where a mutable function is called that returns such as
here: |
By "mutable" function you mean one that modifies its args? But don't they all return nothing? Seems you are getting down to the bottom it yourself... Perhaps try writing a simple code of your own then and running the debugger there? E.g. function my_own_function!(a)
a = 2a
return nothing
end
a = 17
my_own_function!(a)
b = 10a or something like that and see if you get the same error? |
the debugger works fine on the code snippet you shared - it also works fine on all other Julia libraries where I step through the code by inserting breakpoints - today is the first time I've gotten this error while trying to step through the Oceananigans codebase by using the quick start example |
OK, I'll try to reproduce it myself then. Not sure if I'll find time to do that today -- I'll let you know! Anyone else with ideas feel free to chime in. |
just as a follow-up in case it's helpful - I spent some time on this - it's the boundary condition "nothing" that seems to make the debugger think it has encountered an exception - the function |
Just a wild guess, but could it have to do with KernelAbstractions? Have you tried the debugger on other packages that use KernelAbstractions? This smells like a problem with the debugger rather than an Oceananigans-specific issue. But maybe there is something we can change in the source code to help. |
thank you for replying - I've never tried the debugger on any package that uses KernelAbstractions I've opened an issue on the julia-vscode extension github repo (linked above) - I'll open an issue on the KernelAbstractions github repo to get their feedback thank you for helping me - I'll spend some more time on this |
I guess you're hitting a problem with this function Oceananigans.jl/src/BoundaryConditions/fill_halo_regions.jl Lines 220 to 230 in 92791a9
which calls there's a grid = RectilinearGrid(size=(128, 128), x=(0, 2π), y=(0, 2π), topology=(Periodic, Periodic, Flat)) @sophia-wright-blue you could try changing the above line to grid = RectilinearGrid(size=(128, 128, 1), x=(0, 2π), y=(0, 2π), z=(0, 1), topology=(Periodic, Periodic, Bounded)) if you want to specifically check the |
thank you so much for sharing that @glwagner after making the change you suggested, I'm getting the exact same error please let me know if there's any other change I could test - thank you again |
I ran through the code step by step after changing the grid as per your suggestion, this time, it is this line of code that threw the boundary_condition_nothing error:
leads to this line: https://github.com/CliMA/Oceananigans.jl/blob/main/src/Utils/kernel_launching.jl#L97 which then throws the error |
True! You could also try calling c1 = CenterField(grid)
c2 = CenterField(grid)
tracers = (; c1, c2)
fill_halo_regions!(tracers) and see if you get an error. PS if you use the permalinks then the code will be displayed inline in the github issue (like in my comment above --- I changed one of yours to illustrate) |
thank you for sharing the code snippet - I get the exact same error even when I run just the snippet you shared please let me know if there is anything else I can try - thank you again |
I'm not sure if this is helpful, but I manually executed this line:
and then this line: Oceananigans.jl/src/Simulations/run.jl Line 122 in 92791a9
throws the following error, related to looks like the value |
Ok, can you reproduce the error by trying to loop over a simple kernel that returns |
sure - I was able to repro the error by using the basic example on the https://juliagpu.github.io/KernelAbstractions.jl/dev/quickstart/
this is the error the author of the JuliaGPU/KernelAbstractions.jl#405 I'm not sure if that's helpful, but I have only experienced this issue with the I've also opened an issue on the julia-vscode extension repo, but have not received a response yet: julia-vscode/julia-vscode#3349 please let me know if there's anything else I can try - thank you again for helping me with this issue |
Yes, it seems there is some bad interaction between KernelAbstractions and the debugger. It seems likely that fixing it will requiring some development of the debugger (but possibly also KernelAbstractions). Once that's resolved, I think it's likely the debugger will work with Oceananigans. Hopefully you can still have a productive development workflow in the meantime! Let us know if there is any way we can help. I think the bright side of this situation is that Julia has a lot of powerful built-in features for code introspection and interactive usage, a lot of which overlap with the features provided by a traditional debugger (as I understand it). Are you planning to contribute to Oceananigans development or just to interact with Oceananigans as a user? |
my eventual objective is to understand enough about the models used in Oceananigans and the package to be able to contribute to Oceananigans development :) |
Great! You're already well on your way! |
@sophia-wright-blue is this still outstanding issue? |
Hi @navidcy - it is still outstanding, but there's been some progress lately: JuliaDebug/JuliaInterpreter.jl#574 (comment) julia-vscode/julia-vscode#3349 (comment) I will update this thread as soon as it's resolved - hope that sounds good - thank you |
Sounds great! I was just wondering -- no rush! |
Hi @navidcy - you have great timing - it looks like the most recent release of the julia-vscode extension fixed the issue - I have tested it on a basic Oceananigans script and the debugger seems to be working now the core issue here was with JuliaInterpreter.jl which was fixed and updated in the julia-vscode extension, which then fixed the issue thank you so much for your help and patience! |
I'm closing this issue with this note in case it helps anyone: using the julia-vscode debugger is pretty slow - I'm not sure how if this can be resolved in the near term someone was kind enough to release this repo to debug Pluto notebooks with vscode in case it helps: |
hello - I'm able to run the basic example in the docs under Quick start, but when I try to run the same code in VSCode by setting breakpoints in debug mode, I get the following error:
the line:
model = NonhydrostaticModel(; grid, advection=WENO())
leads to the function
update_state!()
in the scriptupdate_nonhydrostatic_model_state.jl
https://github.com/CliMA/Oceananigans.jl/blob/main/src/Models/NonhydrostaticModels/update_nonhydrostatic_model_state.jl
where it gets to Line 21 -
foreach(mask_immersed_field!, model.tracers)
after which I get the following error:the debugger opens up this file:
which then throws this error:
I'm trying to step through the code to understand the code better, but I'm not able to figure out why I only get this error when I insert breakpoints.
I'd greatly appreciate any help understanding this better, thank you
The text was updated successfully, but these errors were encountered: