# IO error message while training an LSTM model but no operation on a file is being performed

**URL:** <https://discourse.julialang.org/t/io-error-message-while-training-an-lstm-model-but-no-operation-on-a-file-is-being-performed/110040>\
**Category:** VS Code\
**Tags:** error, flux, vscode, lstm, io\
**Created:** [February 10, 2024, 6:58pm UTC](https://discourse.julialang.org/t/io-error-message-while-training-an-lstm-model-but-no-operation-on-a-file-is-being-performed/110040 "2024-02-10T18:58:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Post date:** [February 10, 2024, 6:58pm UTC](https://discourse.julialang.org/t/io-error-message-while-training-an-lstm-model-but-no-operation-on-a-file-is-being-performed/110040/1 "2024-02-10T18:58:24Z")

</div>

I am currently getting an IO error message (see below), and I don’t understand why.

This error has popped up haphazardly as I run a function I wrote to train an LSTM model with `Flux.jl`. The function reshapes the data into the appropriate format and feed it into the training stage. After training, the model is used for prediction, and a series of prediction quality metrics are computed and returned.

I should say that there is no attempt to perform an operation on a file (opening it, reading it, or writing to it.) whatsoever in the code. Therefore, I don’t know how the error happened with `check_open` from `stream.jl`.

I also think I should mention that I have run this code successfully before, but now I am rerunning it for a more “restricted” LSTM. I have decreased the learning rate to 10^{-6} and have allowed the training to go on for at most 500 epochs. Before, when the learning rate was 10^{-5} and the number of epochs were 250 at most, I didn’t run into this error. Lastly, no plots are being made or saved, and no parallelism is employed.

**Has anyone run into this before? Is there any chance that running the code is taking a large chunk of the systems resources and making it crash? (This is what I get in a Windows computer running this code in VSCode).**

```julia
ERROR: IOError: stream is closed or unusable
Stacktrace:
 [1] check_open
   @ .\stream.jl:388 [inlined]
 [2] uv_write_async(s::Base.PipeEndpoint, p::Ptr{UInt8}, n::UInt64)
   @ Base .\stream.jl:1074
 [3] uv_write(s::Base.PipeEndpoint, p::Ptr{UInt8}, n::UInt64)    
   @ Base .\stream.jl:1037
 [4] flush(s::Base.PipeEndpoint)
   @ Base .\stream.jl:1133
 [5] write_transport_layer(stream::Base.PipeEndpoint, response::String)
   @ VSCodeServer.JSONRPC c:\Users\hsd36\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\JSONRPC\src\core.jl:69
 [6] macro expansion
   @ c:\Users\hsd36\.vscode\extensions\julialang.language-julia-1.66.2\scripts\packages\JSONRPC\src\core.jl:106 [inlined]
 [7] (::VSCodeServer.JSONRPC.var"#1#3"{VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}})()
   @ VSCodeServer.JSONRPC .\task.jl:514

```

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [February 12, 2024, 9:50pm UTC](https://discourse.julialang.org/t/io-error-message-while-training-an-lstm-model-but-no-operation-on-a-file-is-being-performed/110040/2 "2024-02-12T21:50:39Z")

</div>

Based on the stacktrace, this looks like an issue with the custom REPL the VSCode Julia extension uses. First step would be to run your code in a normal terminal instead of the VSCode one and see what happens there. I suspect you’ll want to ask for help in one of the channels for VSCode instead of in the #Machine Learning category.

---

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Post date:** [February 13, 2024, 7:09pm UTC](https://discourse.julialang.org/t/io-error-message-while-training-an-lstm-model-but-no-operation-on-a-file-is-being-performed/110040/3 "2024-02-13T19:09:58Z")

</div>

As suggested by @ToucheSir, I ran the file in the standalone Julia REPL, not the VSCode REPL, and the problem vanished. I still don’t know why it happened in the first place, though.

Any thoughts on that are appreciated.
