Tensorflow Dst张量未初始化。使用tf.Saver()时

时间:2018-12-09 16:04:39

标签: python tensorflow

使用tf.saver()时出现错误。 我的GPU是1080TI,具有11GB,我不知道为什么使用tf.saver会导致此问题,这是错误消息:

File "<ipython-input-7-138c302de45b>", line 1, in <module>
    runfile('H:/embeddings/factor_vae/run_speech_commands.py', wdir='H:/embeddings/factor_vae')

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
    execfile(filename, namespace)

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "H:/embeddings/factor_vae/run_speech_commands.py", line 30, in <module>
    factor_vae.train()

  File "H:\embeddings\factor_vae\model.py", line 472, in train
    self.saver.save(sess,self.store_path+self.model_type+str(self.model_num)+'.ckpt')

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py", line 1593, in save
    {self.saver_def.filename_tensor_name: checkpoint_file})

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
    run_metadata_ptr)

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1128, in _run
    feed_dict_tensor, options, run_metadata)

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1344, in _do_run
    options, run_metadata)

  File "C:\Users\shiyanpei26\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1363, in _do_call
    raise type(e)(node_def, op, message)

InternalError: Dst tensor is not initialized.
     [[Node: encoder/dense/kernel/_1295 = _Recv[_start_time=0, client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_270_encoder/dense/kernel", tensor_type=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)]]

我搜索了此错误,我发现这是因为GPU内存不足。但是我的GPU是1080TI,具有11 GB,为什么运行保护程序会导致此问题?

这是该部分的代码:

#config=tf.ConfigProto()
#config.gpu_options.allow_growth=True
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
sess=tf.Session(config=config)

sess.run(tf.global_variables_initializer())

#training process, no error, there is too much so I do not show it

self.saver.save(sess,self.store_path+self.model_type+str(self.model_num)+'.ckpt')  #here is the error

0 个答案:

没有答案