2017-12-03 75 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' 

所以我解決它通過使用特定的子文件夾我的代碼。不知道爲什麼。 :)

我張貼在這裏,因爲我無法在網上找到類似的解決方案。

相關問題