tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
186.61k stars 74.34k forks source link

PermissionDeniedError when save model #13120

Closed zzeric closed 6 years ago

zzeric commented 7 years ago

System information

here is the code ` def fit(self, training_iters =1e2, learning_rate = 1e-4, optimizer_epsilon = 1e-10, max_gard_norm = 50, display_step = 5, save_path = None, restore_path = None):

    self._sess.run(tf.global_variables_initializer())
    self._variables_saver = tf.train.Saver()
    if restore_path is not None and os.path.exists(restore_path):
        self._variables_saver.restore(self._sess, restore_path)
        print ('restore ok')

    if self._batch_size == self._mini_batch_size:
        for scope in range(np.int(training_iters)):
            _, loss, acc, tp1, tp2 = \
            self._sess.run([self._train_step, self._cost, self._accuracy, self._pondering_cost, self._rnn_cost],
                           feed_dict = {self._inputs:self._tmp_inputs, self._targets:self._tmp_targets})

            if scope % display_step == 0:
                print (scope, '  loss--', loss, '  acc--', acc, '  pondering_cost--',tp1, '  rnn_cost--', tp2)
                if save_path is not None:
                    self._variables_saver.save(self._sess, save_path)`

and exception logs `--------------------------------------------------------------------------- PermissionDeniedError Traceback (most recent call last) d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, args) 1326 try: -> 1327 return fn(args) 1328 except errors.OpError as e:

d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in _run_fn(session, feed_dict, fetch_list, target_list, options, run_metadata) 1305 feed_dict, fetch_list, target_list, -> 1306 status, run_metadata) 1307

d:\anaconda3664\lib\contextlib.py in exit(self, type, value, traceback) 88 try: ---> 89 next(self.gen) 90 except StopIteration:

d:\anaconda3664\lib\site-packages\tensorflow\python\framework\errors_impl.py in raise_exception_on_not_ok_status() 465 compat.as_text(pywrap_tensorflow.TF_Message(status)), --> 466 pywrap_tensorflow.TF_GetCode(status)) 467 finally:

PermissionDeniedError: Failed to create a directory: e:. [[Node: save_5/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save_5/Const_0_0, save_5/SaveV2/tensor_names, save_5/SaveV2/shape_and_slices, act_core/act_output_linear/b/_939, act_core/act_output_linear/b/RMSProp/_941, act_core/act_output_linear/b/RMSProp_1/_943, act_core/act_output_linear/w/_945, act_core/act_output_linear/w/RMSProp/_947, act_core/act_output_linear/w/RMSProp_1/_949, act_core/halting_linear/b/_951, act_core/halting_linear/b/RMSProp/_953, act_core/halting_linear/b/RMSProp_1/_955, act_core/halting_linear/w/_957, act_core/halting_linear/w/RMSProp/_959, act_core/halting_linear/w/RMSProp_1/_961, global_step, lstm/b_gates/_963, lstm/b_gates/RMSProp/_965, lstm/b_gates/RMSProp_1/_967, lstm/w_gates/_969, lstm/w_gates/RMSProp/_971, lstm/w_gates/RMSProp_1/_973, lstm_1/b_gates/_975, lstm_1/b_gates/RMSProp/_977, lstm_1/b_gates/RMSProp_1/_979, lstm_1/w_gates/_981, lstm_1/w_gates/RMSProp/_983, lstm_1/w_gates/RMSProp_1/_985, lstm_2/b_gates/_987, lstm_2/b_gates/RMSProp/_989, lstm_2/b_gates/RMSProp_1/_991, lstm_2/w_gates/_993, lstm_2/w_gates/RMSProp/_995, lstm_2/w_gates/RMSProp_1/_997)]]

During handling of the above exception, another exception occurred:

PermissionDeniedError Traceback (most recent call last)

in () 3 display_step = 1, 4 save_path="e:./dnc_model_171.ckpt", ----> 5 restore_path="e:./dnc_model_17.ckpt" 6 ) 7 D:\PyTrade\DNCore.py in fit(self, training_iters, learning_rate, optimizer_epsilon, max_gard_norm, display_step, save_path, restore_path) 135 136 if save_path is not None: --> 137 self._variables_saver.save(self._sess, save_path) 138 139 d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py in save(self, sess, save_path, global_step, latest_filename, meta_graph_suffix, write_meta_graph, write_state) 1472 model_checkpoint_path = sess.run( 1473 self.saver_def.save_tensor_name, -> 1474 {self.saver_def.filename_tensor_name: checkpoint_file}) 1475 model_checkpoint_path = compat.as_str(model_checkpoint_path) 1476 if write_state: d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata) 893 try: 894 result = self._run(None, fetches, feed_dict, options_ptr, --> 895 run_metadata_ptr) 896 if run_metadata: 897 proto_data = tf_session.TF_GetBuffer(run_metadata_ptr) d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata) 1122 if final_fetches or final_targets or (handle and feed_dict_tensor): 1123 results = self._do_run(handle, final_targets, final_fetches, -> 1124 feed_dict_tensor, options, run_metadata) 1125 else: 1126 results = [] d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata) 1319 if handle is None: 1320 return self._do_call(_run_fn, self._session, feeds, fetches, targets, -> 1321 options, run_metadata) 1322 else: 1323 return self._do_call(_prun_fn, self._session, handle, feeds, fetches) d:\anaconda3664\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args) 1338 except KeyError: 1339 pass -> 1340 raise type(e)(node_def, op, message) 1341 1342 def _extend_graph(self): PermissionDeniedError: Failed to create a directory: e:. [[Node: save_5/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save_5/Const_0_0, save_5/SaveV2/tensor_names, save_5/SaveV2/shape_and_slices, act_core/act_output_linear/b/_939, act_core/act_output_linear/b/RMSProp/_941, act_core/act_output_linear/b/RMSProp_1/_943, act_core/act_output_linear/w/_945, act_core/act_output_linear/w/RMSProp/_947, act_core/act_output_linear/w/RMSProp_1/_949, act_core/halting_linear/b/_951, act_core/halting_linear/b/RMSProp/_953, act_core/halting_linear/b/RMSProp_1/_955, act_core/halting_linear/w/_957, act_core/halting_linear/w/RMSProp/_959, act_core/halting_linear/w/RMSProp_1/_961, global_step, lstm/b_gates/_963, lstm/b_gates/RMSProp/_965, lstm/b_gates/RMSProp_1/_967, lstm/w_gates/_969, lstm/w_gates/RMSProp/_971, lstm/w_gates/RMSProp_1/_973, lstm_1/b_gates/_975, lstm_1/b_gates/RMSProp/_977, lstm_1/b_gates/RMSProp_1/_979, lstm_1/w_gates/_981, lstm_1/w_gates/RMSProp/_983, lstm_1/w_gates/RMSProp_1/_985, lstm_2/b_gates/_987, lstm_2/b_gates/RMSProp/_989, lstm_2/b_gates/RMSProp_1/_991, lstm_2/w_gates/_993, lstm_2/w_gates/RMSProp/_995, lstm_2/w_gates/RMSProp_1/_997)]] Caused by op 'save_5/SaveV2', defined at: File "d:\anaconda3664\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "d:\anaconda3664\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "d:\anaconda3664\lib\site-packages\ipykernel_launcher.py", line 16, in app.launch_new_instance() File "d:\anaconda3664\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance app.start() File "d:\anaconda3664\lib\site-packages\ipykernel\kernelapp.py", line 477, in start ioloop.IOLoop.instance().start() File "d:\anaconda3664\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start super(ZMQIOLoop, self).start() File "d:\anaconda3664\lib\site-packages\tornado\ioloop.py", line 888, in start handler_func(fd_obj, events) File "d:\anaconda3664\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "d:\anaconda3664\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events self._handle_recv() File "d:\anaconda3664\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv self._run_callback(callback, msg) File "d:\anaconda3664\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback callback(*args, **kwargs) File "d:\anaconda3664\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "d:\anaconda3664\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher return self.dispatch_shell(stream, msg) File "d:\anaconda3664\lib\site-packages\ipykernel\kernelbase.py", line 235, in dispatch_shell handler(stream, idents, msg) File "d:\anaconda3664\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request user_expressions, allow_stdin) File "d:\anaconda3664\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "d:\anaconda3664\lib\site-packages\ipykernel\zmqshell.py", line 533, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "d:\anaconda3664\lib\site-packages\IPython\core\interactiveshell.py", line 2698, in run_cell interactivity=interactivity, compiler=compiler, result=result) File "d:\anaconda3664\lib\site-packages\IPython\core\interactiveshell.py", line 2808, in run_ast_nodes if self.run_code(code, result): File "d:\anaconda3664\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 5, in restore_path="e:./dnc_model_17.ckpt" File "D:\PyTrade\DNCore.py", line 121, in fit self._variables_saver = tf.train.Saver() File "d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py", line 1140, in __init__ self.build() File "d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py", line 1172, in build filename=self._filename) File "d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py", line 686, in build save_tensor = self._AddSaveOps(filename_tensor, saveables) File "d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py", line 276, in _AddSaveOps save = self.save_op(filename_tensor, saveables) File "d:\anaconda3664\lib\site-packages\tensorflow\python\training\saver.py", line 219, in save_op tensors) File "d:\anaconda3664\lib\site-packages\tensorflow\python\ops\gen_io_ops.py", line 768, in save_v2 tensors=tensors, name=name) File "d:\anaconda3664\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op op_def=op_def) File "d:\anaconda3664\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op original_op=self._default_original_op, op_def=op_def) File "d:\anaconda3664\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in __init__ self._traceback = self._graph._extract_stack() # pylint: disable=protected-access PermissionDeniedError (see above for traceback): Failed to create a directory: e:. [[Node: save_5/SaveV2 = SaveV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT64, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_save_5/Const_0_0, save_5/SaveV2/tensor_names, save_5/SaveV2/shape_and_slices, act_core/act_output_linear/b/_939, act_core/act_output_linear/b/RMSProp/_941, act_core/act_output_linear/b/RMSProp_1/_943, act_core/act_output_linear/w/_945, act_core/act_output_linear/w/RMSProp/_947, act_core/act_output_linear/w/RMSProp_1/_949, act_core/halting_linear/b/_951, act_core/halting_linear/b/RMSProp/_953, act_core/halting_linear/b/RMSProp_1/_955, act_core/halting_linear/w/_957, act_core/halting_linear/w/RMSProp/_959, act_core/halting_linear/w/RMSProp_1/_961, global_step, lstm/b_gates/_963, lstm/b_gates/RMSProp/_965, lstm/b_gates/RMSProp_1/_967, lstm/w_gates/_969, lstm/w_gates/RMSProp/_971, lstm/w_gates/RMSProp_1/_973, lstm_1/b_gates/_975, lstm_1/b_gates/RMSProp/_977, lstm_1/b_gates/RMSProp_1/_979, lstm_1/w_gates/_981, lstm_1/w_gates/RMSProp/_983, lstm_1/w_gates/RMSProp_1/_985, lstm_2/b_gates/_987, lstm_2/b_gates/RMSProp/_989, lstm_2/b_gates/RMSProp_1/_991, lstm_2/w_gates/_993, lstm_2/w_gates/RMSProp/_995, lstm_2/w_gates/RMSProp_1/_997)]]`
aselle commented 7 years ago

It looks like your save path is invalid

4 save_path="e:./dnc_model_171.ckpt",

try giving it one that isn't a mix of being relative and absolute.

Chinix commented 7 years ago

I have encountered the same problem,and the problem is caused by that I save the model file in the same path which I put the Python file. When I save the model file in a different path from the path of python file, the problem is solved. Good luck!

tensorflowbutler commented 6 years ago

It has been 14 days with no activity and the awaiting response label was assigned. Is this still an issue? Please update the label and/or status accordingly.

tensorflowbutler commented 6 years ago

It has been 14 days with no activity and the awaiting response label was assigned. Is this still an issue? Please update the label and/or status accordingly.

tensorflowbutler commented 6 years ago

Nagging Awaiting Response: It has been 14 days with no activityand the awaiting response label was assigned. Is this still an issue?

tensorflowbutler commented 6 years ago

Nagging Awaiting Response: It has been 14 days with no activityand the awaiting response label was assigned. Is this still an issue?

tensorflowbutler commented 6 years ago

Nagging Awaiting Response: It has been 14 days with no activityand the awaiting response label was assigned. Is this still an issue?

acmaheri commented 5 years ago

I have encountered the same problem,and the problem is caused by that I save the model file in the same path which I put the Python file. When I save the model file in a different path from the path of python file, the problem is solved. Good luck!

I have got the same problem: is there any working solution yet? The above solution is not working for me.

cvxz commented 5 years ago

I use absolute paths for data and models, and the problem solved.

nrj101 commented 4 years ago

I use absolute paths for data and models, and the problem solved.

Yes, it works for me too ---> tf.VERSION: 1.12.0