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)]]