2017-12-03 216 views
0

试图使用Saver保存会话。而遇到了一个错误:Tensorflow Saver.Save(),FailedPreconditionError,重命名失败:...进程无法访问文件,因为它正在被另一个进程使用

FailedPreconditionError (see above for traceback): Failed to rename: ./Language_model_lab3-0.data-00000-of-00001.tempstate15754770084434331914 to: ./Language_model_lab3-0.data-00000-of-00001 : The process cannot access the file because it is being used by another process. 
; Broken pipe 
    [[Node: save/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/SaveV2/tensor_names, save/SaveV2/shape_and_slices, model/Variable/_121, model/embedding, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias/_123, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/_125, model/softmax_b/_127, model/softmax_w/_129)]] 

下面是代码:

saver.save(session, "./Language_model_lab3", global_step=i) 

这里是报告全文:

saver.save(session, "./Language_model_lab3", global_step=i) 
error: Failed to rename: ./Language_model_lab3-0.data-00000-of-00001.tempstate15754770084434331914 to: ./Language_model_lab3-0.data-00000-of-00001 : The process cannot access the file because it is being used by another process. 
; Broken pipe 
    [[Node: save/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/SaveV2/tensor_names, save/SaveV2/shape_and_slices, model/Variable/_121, model/embedding, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias/_123, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/_125, model/softmax_b/_127, model/softmax_w/_129)]] 

Caused by op 'save/SaveV2', defined at: 
    File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_launcher.py", line 78, in <module> 
    vspd.debug(filename, port_num, debug_id, debug_options, run_as) 
    File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_debugger.py", line 2483, in debug 
    exec_file(file, globals_obj) 
    File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 111, in exec_file 
    exec_code(code, file, global_variables) 
    File "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_util.py", line 87, in exec_code 
    exec(code_obj, global_variables) 
    File "C:\Users\zhaoy\documents\visual studio 2015\Projects\TestTf\TestTf\ML120\PTB\Lab3-LangugageModel.py", line 277, in <module> 
    saver = tf.train.Saver() 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1218, in __init__ 
    self.build() 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1227, in build 
    self._build(self._filename, build_save=True, build_restore=True) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 1263, in _build 
    build_save=build_save, build_restore=build_restore) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 748, in _build_internal 
    save_tensor = self._AddSaveOps(filename_tensor, saveables) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 296, in _AddSaveOps 
    save = self.save_op(filename_tensor, saveables) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\saver.py", line 239, in save_op 
    tensors) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 1162, in save_v2 
    shape_and_slices=shape_and_slices, tensors=tensors, name=name) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper 
    op_def=op_def) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2956, in create_op 
    op_def=op_def) 
    File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1470, in __init__ 
    self._traceback = self._graph._extract_stack() # pylint: disable=protected-access 

FailedPreconditionError (see above for traceback): Failed to rename: ./Language_model_lab3-0.data-00000-of-00001.tempstate15754770084434331914 to: ./Language_model_lab3-0.data-00000-of-00001 : The process cannot access the file because it is being used by another process. 
; Broken pipe 
    [[Node: save/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/SaveV2/tensor_names, save/SaveV2/shape_and_slices, model/Variable/_121, model/embedding, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/bias/_123, model/rnn/multi_rnn_cell/cell_0/basic_lstm_cell/kernel/_125, model/softmax_b/_127, model/softmax_w/_129)]] 

回答

0

我搜索这个网站,唯一的答案与Dropbox相关,我没有运行Dropbox。由语义反病毒,Mircosoft Onedrive和谷歌备份/同步。没有帮助。

我试图使用“进程探索”来搜索哪个进程已锁定文件/文件夹,找不到任何。

所以我在“immediated窗口”尝试这样做:(一招,所以我可以测试而无需重新启动该程序的东西)

和它的工作。

saver.save(session, "./Language_model_lab3/", global_step=i) 
'./Language_model_lab3/-0' 

如果我添加一个文件名:

saver.save(session, "./Language_model_lab3/Model.ckpt", global_step=i) 
'./Language_model_lab3/Model.ckpt-0' 

所以我解决它通过使用特定的子文件夹我的代码。不知道为什么。 :)

我张贴在这里,因为我无法在网上找到类似的解决方案。

相关问题