Debugging of julia modules lead to errors while evaluating not

Hi,

I often would like to debug the code of some julia modules i.e. DiffEqFlux or Flux to better understand what is going on, but some how I get error messages during debugging, which I don´t get when I just evaluate the code. Can somebody explain me what is the reason for this? Has it something to do with macros or multithreading? Is there a workaround or special way to enter the debug mode for this cases? I just use Juno@enter ....

Best regards
Volker

This is hard to do without specifics, ie at least the error messages and ideally an MWE that shows what exactly you are debugging and how you are doing it.

For me it is a quite general thing, because I face it so often. Therefore I thought, that I´m not the only one, who faced it. But here one example, the following code lead to this error message during debbuging

Juno.@enter Flux.train!(loss, ps, data, opt)
debug> ERROR: UndefVarError: progress not defined

using Flux

feat = 6
batch_size = 256
num_batches = 100
seq_len = 20

X = [[rand(Float32, feat, batch_size) for i in 1:seq_len] for batch in 1:num_batches];
Y = [rand(Float32, batch_size, seq_len) ./ 10  for batch in 1:num_batches];

gpu_or_cpu = gpu

X = X |> gpu_or_cpu;
Y = Y |> gpu_or_cpu;
data = zip(X, Y);

opt = ADAM(0.001, (0.9, 0.999))

function loss(X,Y)
    Flux.reset!(model)
    mse_val = sum(abs2.(Y .- Flux.stack(model.(X), 2)))
    return mse_val
end

model = Chain(LSTM(6, 70), LSTM(70, 70), LSTM(70, 70), Dense(70, 1, relu)) |> gpu_or_cpu
ps = Flux.params(model)
Flux.reset!(model)

@time Flux.train!(loss, ps, data, opt)

Hi, I just wanted to highlight it again, because I think, it would help me a lot to understand some libraries and I really guess, that I´m not the only one with this problem

I suspect that particular issue has been fixed with https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/442.

2 Likes

Now I´m getting no error, but it doesn´t stop on a breakpoint

Where did you set the breakpoint? Did you make sure to disable “Compiled Mode”?

1 Like

I have ensured it. “Compiled Mode” is disabled.

The breakpoint is on line 102 of train.jl of Flux v0.11.2.
grafik