TENSORFLOW PROCESS FINISHED WITH EXIT CODE -1073741819 (0XC0000005)

这次报错与是否gpu没有关系:

TENSORFLOW 导入失败:PROCESS FINISHED WITH EXIT CODE -1073741819 (0XC0000005)

测试脚本:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()

这个异常,我的解决方法是,tf2.0一下版本,只支持cuda10.0。

重新安装cuda10.0,tf1.15.0版本,后来这个问题就解决了。

预训练下面有个:checkpoint文件,

checkpoint

model_checkpoint_path: "snap-43001"
all_model_checkpoint_paths: "snap-33501"
all_model_checkpoint_paths: "snap-35501"
all_model_checkpoint_paths: "snap-37001"
all_model_checkpoint_paths: "snap-43001"

实际上 最终模型是snap-37001

改一下checkpoint

model_checkpoint_path: "snap-37001"
all_model_checkpoint_paths: "snap-29001"
all_model_checkpoint_paths: "snap-33501"
all_model_checkpoint_paths: "snap-35501"
all_model_checkpoint_paths: "snap-37001"
 

ok,然后加载预训练ok!

加载预训练方法1:

tf 1.15版本以前加载预训练:

saver.restore(sess, restore_snap)

tf1.15版本:

            aaa = tf.train.latest_checkpoint(restore_snap)
            #saver.restore(sess, restore_snap)
            print("start restore------------------", restore_snap,aaa)
            self.saver.restore(self.sess, aaa)
            print("Model restored from " + restore_snap)

加载预训练方法2:

参考:https://blog.csdn.net/wjc1182511338/article/details/82111790

def build_graph():
    w1 = tf.Variable([1,3,10,15],name='W1',dtype=tf.float32)
    w2 = tf.Variable([3,4,2,18],name='W2',dtype=tf.float32)
    w3 = tf.placeholder(shape=[4],dtype=tf.float32,name='W3')
    w4 = tf.Variable([100,100,100,100],dtype=tf.float32,name='W4')
    add = tf.add(w1,w2,name='add')
    add1 = tf.add(add,w3,name='add1')
    return w3,add1

with tf.Session() as sess:
    ckpt_state = tf.train.get_checkpoint_state('./temp/')
    if ckpt_state:
        w3,add1=build_graph()
        saver = tf.train.Saver()
        saver.restore(sess, ckpt_state.model_checkpoint_path)
    else:
        w3,add1=build_graph()
        init_op = tf.group(tf.global_variables_initializer(),tf.local_variables_initializer())
        sess.run(init_op)
        saver = tf.train.Saver()
    a = sess.run(add1,feed_dict={
            w3:[1,2,3,4]
        })
    print(a)
    saver.save(sess,'./temp/model')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值