Skip to content
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

GKS file open error: Too many open files #1723

Open
gzahl opened this issue Sep 5, 2018 · 6 comments

Comments

@gzahl
Copy link

@gzahl gzahl commented Sep 5, 2018

Generating many plots and saving them leads to an "Too many open files" error using the GR backend. I could not find any information on how to close a plot/file in the documentation. A minimal working example:

using Plots                                                                     
                                                                                
function mkplot(it)                                                             
  p = plot(1:it)                                                                
                                                                                
  numb = lpad(it,3,'0')                                                         
  fname = "plot_$(numb).png"                                                    
                                                                                
  println(fname)                                                                
  savefig(p,fname)                                                              
end                                                                             
                                                                                
                                                                                
for i=1:1000                                                                    
  mkplot(i)                                                                     
end                                                                             

I figured that the plot object should go out of scope and therefore be garbage collected if necessary. But is there any explicit way to close the plot/file?
"closeall()" did not work.
The error was raised for plot_514.png for me:

[..]
plot_504.png
plot_505.png
plot_506.png
plot_507.png
plot_508.png
plot_509.png
plot_510.png
plot_511.png
GKS: file open error (/home/hslxrsrv3/stnv053/.julia/packages/GR/ztzRc/src/../deps/gr/fonts/gksfont.dat)
open: Too many open files
plot_512.png
plot_513.png
plot_514.png
socket: Too many open files
GKS: can't connect to GKS socket application
Did you start 'gksqt'?

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
GKS: file open error (/tmp/juliadXi2wN.png)
open: Too many open files
ERROR: LoadError: SystemError: opening file /tmp/juliadXi2wN.png: No such file or directory
Stacktrace:
 [1] #systemerror#39(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:106
 [2] systemerror at ./error.jl:106 [inlined]
 [3] #open#293(::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Function, ::String) at ./iostream.jl:283
 [4] open at ./iostream.jl:275 [inlined]
 [5] #open#294(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::getfield(Base, Symbol("##258#259")){String}, ::String) at ./iostream.jl:367
 [6] open at ./iostream.jl:367 [inlined]
 [7] read at ./io.jl:297 [inlined]
 [8] _show(::IOStream, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.GRBackend}) at /home/hslxrsrv3/stnv053/.julia/packages/Plots/MnXMC/src/backends/gr.jl:1398
 [9] show(::IOStream, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.GRBackend}) at /home/hslxrsrv3/stnv053/.julia/packages/Plots/MnXMC/src/output.jl:201
 [10] png(::Plots.Plot{Plots.GRBackend}, ::String) at /home/hslxrsrv3/stnv053/.julia/packages/Plots/MnXMC/src/output.jl:8
 [11] savefig(::Plots.Plot{Plots.GRBackend}, ::String) at /home/hslxrsrv3/stnv053/.julia/packages/Plots/MnXMC/src/output.jl:123
 [12] mkplot(::Int64) at /hs/ws01/scratch/stnv053/julia/bug/test.jl:10
 [13] top-level scope at /hs/ws01/scratch/stnv053/julia/bug/test.jl:15 [inlined]
 [14] top-level scope at ./none:0
 [15] include at ./boot.jl:317 [inlined]
 [16] include_relative(::Module, ::String) at ./loading.jl:1038
 [17] include(::Module, ::String) at ./sysimg.jl:29
 [18] exec_options(::Base.JLOptions) at ./client.jl:229
 [19] _start() at ./client.jl:421
in expression starting at /hs/ws01/scratch/stnv053/julia/bug/test.jl:14

Thanks!

@aramirezreyes

This comment has been minimized.

Copy link

@aramirezreyes aramirezreyes commented Nov 19, 2018

Have the same problem when generating several animations that, in total represent 1000s of frames.

Julia Version 0.7.0
Commit a4cb80f3ed (2018-08-08 06:46 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Xeon(R) CPU E5-2698 v3 @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

@longqian95

This comment has been minimized.

Copy link

@longqian95 longqian95 commented Feb 13, 2019

Same problem after generating 1000 frames of animation with Julia1.1, Plots v0.23.0, GR v0.37.0, Ubuntu 18.04

@tamasgal

This comment has been minimized.

Copy link

@tamasgal tamasgal commented Mar 10, 2019

Yep, I have the same problem running a Julia script in background and producing plots. After a few hours (not sure how many iterations) I get a similar error.

@tamasgal

This comment has been minimized.

Copy link

@tamasgal tamasgal commented Mar 10, 2019

Are there any workarounds? I have difficulties getting the PyPlot backend running on our old monitoring machine with Scientific Linux 6...

@tamasgal

This comment has been minimized.

Copy link

@tamasgal tamasgal commented Mar 10, 2019

It seems that setting GR.inline("png") is a legit workaround (I found it here: jheinen/GR.jl#172). I made a quick test and successfully produced 100000 plots within a few minutes, without any errors.

@martinzh

This comment has been minimized.

Copy link

@martinzh martinzh commented Mar 21, 2019

It seems that setting GR.inline("png") is a legit workaround (I found it here: jheinen/GR.jl#172). I made a quick test and successfully produced 100000 plots within a few minutes, without any errors.

I had the same error generating a number of plots in a slurm cluster and I can confirm that adding GR.inline("png") solved the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.