# Debugging of julia modules lead to errors while evaluating not

**URL:** <https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036>\
**Category:** General Usage\
**Tags:** debug\
**Created:** [November 12, 2020, 8:52am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036 "2020-11-12T08:52:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [November 12, 2020, 8:52am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/1 "2020-11-12T08:52:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 12, 2020, 10:24am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/2 "2020-11-12T10:24:57Z")

</div>

> [@Volker](#):
>
> 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?

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.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [November 12, 2020, 10:33am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/3 "2020-11-12T10:33:38Z")

</div>

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [November 23, 2020, 8:32am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/4 "2020-11-23T08:32:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [November 23, 2020, 9:05am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/5 "2020-11-23T09:05:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [November 24, 2020, 8:09am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/6 "2020-11-24T08:09:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [November 24, 2020, 10:37am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/7 "2020-11-24T10:37:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [November 25, 2020, 8:10am UTC](https://discourse.julialang.org/t/debugging-of-julia-modules-lead-to-errors-while-evaluating-not/50036/8 "2020-11-25T08:10:19Z")

</div>

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

The breakpoint is on line 102 of train.jl of Flux v0.11.2.  
 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/c/3/c36dbe7013100483c0d90e23ce23d89415adcb33.png)
