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

Error when creating and exporting plots in gr() backend: 'GetTempFileName failed: The file exists' #699

Closed
PedroSapichu opened this issue Feb 23, 2017 · 9 comments

Comments

@PedroSapichu
Copy link

Hello all,

I cannot visualize or save png plots with gr().

I've been working with some pretty big datasets, generating thousands of plots, reason why I use the gr() backend, since it's pretty fast. Everything had worked just perfect yesterday with the exact same code. Today I keep getting the same error each time I create even the simplest plot. I cannot even visualize the plot, and that's a bummer since the alternative I have is pyplot() and is significantly slower in generating that amount of plots.

Here I attach the type of plot I've been generating. Left is pyplot(), right is gr().

example

I've tried all the obvious fixes (not a CS background, actually a biologist), like rebooting julia, Jupyter, modifying the syntax, etc. I just can't visualize a simple "plot(rand(10)" in the gr() backend, it gives the same error.

Thank you all! I just discovered Julia, and the Plots.jl is a monster for generating great visualizations!,
Pedro.

@PedroSapichu PedroSapichu changed the title Error when creating and exporting plots in gr() backend: 'GetTempFileName: the file exists' Error when creating and exporting plots in gr() backend: 'GetTempFileName failed: The file exists' Feb 23, 2017
@tbreloff
Copy link
Member

tbreloff commented Feb 23, 2017 via email

@PedroSapichu
Copy link
Author

Yes, it is windows. It just suddenly stopped working. Hope it has a way around, gr() saves me hours of waiting. Thanks!

@ma-laforge
Copy link
Contributor

Very odd... maybe there is an issue with your temporary file directory.
I would run the following at the Julia prompt:

tempname()
  • Does it always return the same file name?
  • Can you create files in the directory returned by this statement (Do you have write access? Did your OS lock this directory?, ...)?

As a side note: Have you tried using backend inspectdr()? I ask because it should also be fast with large datasets - but I am curious of real-world performance & how it compares to gr().

@PedroSapichu
Copy link
Author

I solved this by uninstalling everything, and now is working great. I'm still not sure what was the problem, but my best guess is that some wierd temporary file storage in windows was causing the problem in the computer I was using at the time, since my laptop and other independent computer were working just fine with the same settings/code. Thanks!

@PedroSapichu
Copy link
Author

UPDATE1

Both me and a colleague have been struggling with this same error, using the script I wrote, that saves a png through each iteration in a for loop, with a unique filename in each loop.

We both are using a Windows machine, that belongs to the university. This might prevent us to access some temp file system (?), I actually don't know how to check this @ma-laforge (could you elaborate a bit more in this, whenever I type 'tempname()' I get the same result. This is odd, since the script had been working for a few days, and then suddenly it keeps throwing the same error. I've uninstalled everything and reinstalling, and that fixes the problem for a little while, but it appears again.

  • I repeat, this happens just with gr(), as pyplot() works fine, but it's significantly slower to produce thousands of plots.

I'd appreciate any further help on this, thank you!

@PedroSapichu PedroSapichu reopened this Feb 27, 2017
@ma-laforge
Copy link
Contributor

ma-laforge commented Feb 28, 2017

Sure thing...

tempname() is a built-in Julia function. As far as I know: It is supposed to generate unique names every time you call it. On Windows, it seems to call GetTempFileNameW

You can take a look at the code implementing this function:

Julia> @edit tempname()

In Windows, it calls a C? function GetTempFileNameW. I am not sure where this function is implemented, exactly, though.

If you say you are not getting unique names when this bug occurs, I would appreciate it if you raised an issue on Julia's own Github page: https://github.com/JuliaLang/julia.

EDIT: I don't believe this should happen (my guess is that you should not run out of temporary file names with thousands of runs). There might be a bug in this function. If not, the base Julia guys might know what would cause this event.

@ma-laforge
Copy link
Contributor

As a temporary solution:

The gr() backend glue code is implemented here:
[user dir]/.julia/v0.5/Plots/src/backends/gr.jl

Workaround 1
In this situation (non-ideal), I might try to implement my own version of tempname() (say, gr_tempname()) that would create a unique file name using some simple algorithm that, hopefully will never collide with existing names.

Workaround 2
Until this issue is resolved (please submit an issue to the Julia repo), you can also try a different backend that does not rely on tempname() - and is fast enough for your needs. Again, I suggest you try inspectdr() in this case (my own backend). I developped it for speed/large datasets in mind.

Of course, you can always temporarily switch over to pyplot() until things get corrected... you simply have to wait longer for results.

Workaround 3
Anyone have other ideas???

@ma-laforge
Copy link
Contributor

@PedroSapichu: I have a side question:

I know you said that tempname() always returns the same result (sounds like the cause is known).

However:
Are you running your script multiple times "in parallel" (i.e. multiple instances of Julia)?

In this case: I could imagine tempname() might return the same file name for two parallel instances of Julia... causing this kind of issue.

@ma-laforge
Copy link
Contributor

One more possibility/question:

@PedroSapichu: Is your temp directory full when you look at it? i.e. is GR not deleting its temporary files as it is done with them?

That might be an issue to raise with the GR backend - and might be making the tempname() situation worse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants