Delete tensorflow checkpoint and event files after training










0















After training and evaluating a custom tensorflow estimator, I would like to delete all the files that it saves - the checkpoint files, the event files, the eval folders, etc. - from within the same script. I am trying to do this by using shutil.rmtree on the directory that holds all the files; however, it keeps throwing this error:



Traceback (most recent call last):
File "C:Users____AppDataLocalContinuumanaconda3libweakref.py", line 548, in call
return info.func(*info.args, **(info.kwargs or ))
File "C:Users____AppDataLocalContinuumanaconda3libtempfile.py", line 797, in _cleanup
_shutil.rmtree(name)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 391, in _rmtree_unsafe
os.rmdir(path)



OSError: [WinError 145] The directory is not empty: 'C:Users____AppDataLocalTemp4tmpfuioqj79search_1fold_1eval'



My understanding is that shutil.rmtree will remove the directory and all of its contents, and, when I use shutil.rmtree from a separate script after the script that creates and trains the models is finished, it works fine. Therefore, my I'm guessing that tensorflow is still using the files/directory. I cannot find anything in the estimator or saver documentation that would suggest I need to manually close something after training with the estimator implementation.



Anyone have any idea how to delete these files from the same script that performs the training and evaluation?



Edit: After looking through all the files that are being used by python processes, it looks like it's only the event files, not the checkpoint files, that are still in use.










share|improve this question
























  • You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

    – Recessive
    Nov 15 '18 at 4:22











  • @Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

    – phil510
    Nov 15 '18 at 17:13











  • Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

    – Recessive
    Nov 15 '18 at 23:41















0















After training and evaluating a custom tensorflow estimator, I would like to delete all the files that it saves - the checkpoint files, the event files, the eval folders, etc. - from within the same script. I am trying to do this by using shutil.rmtree on the directory that holds all the files; however, it keeps throwing this error:



Traceback (most recent call last):
File "C:Users____AppDataLocalContinuumanaconda3libweakref.py", line 548, in call
return info.func(*info.args, **(info.kwargs or ))
File "C:Users____AppDataLocalContinuumanaconda3libtempfile.py", line 797, in _cleanup
_shutil.rmtree(name)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 391, in _rmtree_unsafe
os.rmdir(path)



OSError: [WinError 145] The directory is not empty: 'C:Users____AppDataLocalTemp4tmpfuioqj79search_1fold_1eval'



My understanding is that shutil.rmtree will remove the directory and all of its contents, and, when I use shutil.rmtree from a separate script after the script that creates and trains the models is finished, it works fine. Therefore, my I'm guessing that tensorflow is still using the files/directory. I cannot find anything in the estimator or saver documentation that would suggest I need to manually close something after training with the estimator implementation.



Anyone have any idea how to delete these files from the same script that performs the training and evaluation?



Edit: After looking through all the files that are being used by python processes, it looks like it's only the event files, not the checkpoint files, that are still in use.










share|improve this question
























  • You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

    – Recessive
    Nov 15 '18 at 4:22











  • @Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

    – phil510
    Nov 15 '18 at 17:13











  • Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

    – Recessive
    Nov 15 '18 at 23:41













0












0








0








After training and evaluating a custom tensorflow estimator, I would like to delete all the files that it saves - the checkpoint files, the event files, the eval folders, etc. - from within the same script. I am trying to do this by using shutil.rmtree on the directory that holds all the files; however, it keeps throwing this error:



Traceback (most recent call last):
File "C:Users____AppDataLocalContinuumanaconda3libweakref.py", line 548, in call
return info.func(*info.args, **(info.kwargs or ))
File "C:Users____AppDataLocalContinuumanaconda3libtempfile.py", line 797, in _cleanup
_shutil.rmtree(name)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 391, in _rmtree_unsafe
os.rmdir(path)



OSError: [WinError 145] The directory is not empty: 'C:Users____AppDataLocalTemp4tmpfuioqj79search_1fold_1eval'



My understanding is that shutil.rmtree will remove the directory and all of its contents, and, when I use shutil.rmtree from a separate script after the script that creates and trains the models is finished, it works fine. Therefore, my I'm guessing that tensorflow is still using the files/directory. I cannot find anything in the estimator or saver documentation that would suggest I need to manually close something after training with the estimator implementation.



Anyone have any idea how to delete these files from the same script that performs the training and evaluation?



Edit: After looking through all the files that are being used by python processes, it looks like it's only the event files, not the checkpoint files, that are still in use.










share|improve this question
















After training and evaluating a custom tensorflow estimator, I would like to delete all the files that it saves - the checkpoint files, the event files, the eval folders, etc. - from within the same script. I am trying to do this by using shutil.rmtree on the directory that holds all the files; however, it keeps throwing this error:



Traceback (most recent call last):
File "C:Users____AppDataLocalContinuumanaconda3libweakref.py", line 548, in call
return info.func(*info.args, **(info.kwargs or ))
File "C:Users____AppDataLocalContinuumanaconda3libtempfile.py", line 797, in _cleanup
_shutil.rmtree(name)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 384, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 393, in _rmtree_unsafe
onerror(os.rmdir, path, sys.exc_info())
File "C:Users____AppDataLocalContinuumanaconda3libshutil.py", line 391, in _rmtree_unsafe
os.rmdir(path)



OSError: [WinError 145] The directory is not empty: 'C:Users____AppDataLocalTemp4tmpfuioqj79search_1fold_1eval'



My understanding is that shutil.rmtree will remove the directory and all of its contents, and, when I use shutil.rmtree from a separate script after the script that creates and trains the models is finished, it works fine. Therefore, my I'm guessing that tensorflow is still using the files/directory. I cannot find anything in the estimator or saver documentation that would suggest I need to manually close something after training with the estimator implementation.



Anyone have any idea how to delete these files from the same script that performs the training and evaluation?



Edit: After looking through all the files that are being used by python processes, it looks like it's only the event files, not the checkpoint files, that are still in use.







python tensorflow shutil






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 17:48







phil510

















asked Nov 15 '18 at 4:09









phil510phil510

115




115












  • You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

    – Recessive
    Nov 15 '18 at 4:22











  • @Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

    – phil510
    Nov 15 '18 at 17:13











  • Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

    – Recessive
    Nov 15 '18 at 23:41

















  • You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

    – Recessive
    Nov 15 '18 at 4:22











  • @Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

    – phil510
    Nov 15 '18 at 17:13











  • Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

    – Recessive
    Nov 15 '18 at 23:41
















You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

– Recessive
Nov 15 '18 at 4:22





You're right it may just be because the files are still in use. Is your code the clears the directory outside of your " with session as sess: "? Because if it is inside it those files will still be being used I'm fairly sure

– Recessive
Nov 15 '18 at 4:22













@Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

– phil510
Nov 15 '18 at 17:13





@Recessive I'm using the estimator API, so I don't explicitly create the session. The call to train or evaluate handles that, so the session should be closed when I call shutil.rmtree. I'm starting to think it might be the Saver object that is still using the files.

– phil510
Nov 15 '18 at 17:13













Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

– Recessive
Nov 15 '18 at 23:41





Yeh, you should try del saver. Sorry, my tensor flow experience is only so much, just thought I'd give a suggestion in case it was right

– Recessive
Nov 15 '18 at 23:41












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312308%2fdelete-tensorflow-checkpoint-and-event-files-after-training%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312308%2fdelete-tensorflow-checkpoint-and-event-files-after-training%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto