新手踩坑tensorflow上运行模型

原创 2018年04月17日 15:11:24

一、rom ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm ImportError: cannot import name '_ellipsoid'

Python中可能会遇到 cannot import name ‘XXX’ 错误, 其实这有可能出现再模块导入的顺序问题上, 比如:在A文件头执行到语句 from B import XXX ,程序马上就会转到B文件中去,从头到尾顺序寻找B文件中的XXX函数,而A文件就暂停执行,直到把XXX函数复制到内存中,但B文件中的文件头可能也有导入, 如果B文件头中又导入了A文件中的函数,由于XXX函数还没有被复制。所以于A文件因为暂停执行而无法导入,就会出现上面的错误了。

二、libstdc++.so.6: version `CXXABI_1.3.9' not found (required by..... )

ibstdc++.so.6在系统中存在于/usr/lib/libstdc++.so.6 或者/usr/lib/x86_64-linux-gnu/libstdc++.so.6。导致这个问题的出现可能是你在别的库中(例如anaconda)也存在该动态库文件。

1、查看
strings /usr/lib/libstdc++.so.6 | grep 'CXXABI'
或者

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep 'CXXABI'

可以看到

CXXABI_1.3
CXXABI_1.3.1
CXXABI_1.3.2
CXXABI_1.3.3
CXXABI_1.3.4
CXXABI_1.3.5
CXXABI_1.3.6
CXXABI_1.3.7
CXXABI_1.3.8
CXXABI_1.3.9
CXXABI_TM_1

CXXABI_FLOAT128

有CXXABI_1.3.9这一项,而同样的方式查看anaconda3/lib/下libstdc++.so.6文件
strings anaconda3/lib/libstdc++.so.6 | grep 'CXXABI'

最高才存在CXXABI_1.3.7

2、复制动态库

#删除原来的libstdc++.so.6
sudo rm -rf anaconda3/lib/libstdc++.so.6
#拷贝新的动态库文件,注意自己的是哪个版本
sudo cp /usr/lib/libstdc++.so.6.0.21 /home/ubuntu/anaconda3/lib/

3、建立软连接
cd anaconda3/lib/
sudo chmod +r libstdc++.so.6.0.21
sudo ln -sf libstdc++.so.6.0.21 libstdc++.so.6

sudo ldconfig

//////////////////////////////////////////////////////////////////上述原因具体事情,具体分析。

/home/jdmdx/anaconda3/envs/tensorflow/bin/python "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py"
2018-04-18 01:01:04.704523: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2018-04-18 01:01:04.744722: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Feature: image/encoded (data type: string) is required but could not be found.
2018-04-18 01:01:04.750963: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Feature: image/encoded (data type: string) is required but could not be found.
2018-04-18 01:01:04.751038: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Feature: image/encoded (data type: string) is required but could not be found.
2018-04-18 01:01:04.751253: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at example_parsing_ops.cc:240 : Invalid argument: Feature: image/encoded (data type: string) is required but could not be found.
WARNING:tensorflow:From /home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
[*] Try to load trained model...
[*] Reading checkpoints...
Traceback (most recent call last):
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1327, in _do_call
    return fn(*args)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1312, in _run_fn
    options, feed_dict, fetch_list, target_list, run_metadata)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1420, in _call_tf_sessionrun
    status, run_metadata)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in __exit__
    c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1,1,1280,9] rhs shape= [1,1,1280,10]
     [[Node: save/Assign_24 = Assign[T=DT_FLOAT, _class=["loc:@mobilenetv2/logits/w"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](mobilenetv2/logits/w, save/RestoreV2:24)]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py", line 118, in <module>
    main()
  File "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py", line 86, in main
    could_load, step = load(sess, saver, args.checkpoint_dir)
  File "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py", line 18, in load
    saver.restore(sess, os.path.join(checkpoint_dir, ckpt_name))
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1775, in restore
    {self.saver_def.filename_tensor_name: save_path})
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 905, in run
    run_metadata_ptr)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1140, in _run
    feed_dict_tensor, options, run_metadata)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1321, in _do_run
    run_metadata)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1340, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1,1,1280,9] rhs shape= [1,1,1280,10]
     [[Node: save/Assign_24 = Assign[T=DT_FLOAT, _class=["loc:@mobilenetv2/logits/w"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](mobilenetv2/logits/w, save/RestoreV2:24)]]

Caused by op 'save/Assign_24', defined at:
  File "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py", line 118, in <module>
    main()
  File "/home/jdmdx/tensorflow code/MobileNetV2-master/train_mobilenetv2.py", line 81, in main
    saver = tf.train.Saver()
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1311, in __init__
    self.build()
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1320, in build
    self._build(self._filename, build_save=True, build_restore=True)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1357, in _build
    build_save=build_save, build_restore=build_restore)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 809, in _build_internal
    restore_sequentially, reshape)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 470, in _AddRestoreOps
    assign_ops.append(saveable.restore(saveable_tensors, shapes))
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 162, in restore
    self.op.get_shape().is_fully_defined())
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 281, in assign
    validate_shape=validate_shape)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 61, in assign
    use_locking=use_locking, name=name)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
    op_def=op_def)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3290, in create_op
    op_def=op_def)
  File "/home/jdmdx/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1654, in __init__
    self._traceback = self._graph._extract_stack()  # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1,1,1280,9] rhs shape= [1,1,1280,10]
     [[Node: save/Assign_24 = Assign[T=DT_FLOAT, _class=["loc:@mobilenetv2/logits/w"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](mobilenetv2/logits/w, save/RestoreV2:24)]]

\\\\\\\\\\\\\\\\\\\\\\\\\\\不知道什么错误,在sess上加入了sess=tf.Session()导致mobilenetv2训练卡死




IndexError: list index out of range

在config文件中出现这种错误,是因为输入参数的时候没有输入全。


Tensorflow FIFOQueue '_4_batch_join/fifo_queue' is closed and has insufficient elements
在跑mobileNet模型时,出现的错误,原因是在sess.run之前 没有写sess = tf.InteractiveSession()



protobuf 转换python代码时发生 Expected "required", "optional", or "repeated".错误解决方法
Google Protocol Buffers 简称 Protobuf,它提供了一种灵活、高效、自动序列化结构数据的机制,可以联想 XML,但是比 XML 更小、更快、更简单。仅需要自定义一次你所需的数据格式,然后用户就可以使用 Protobuf 编译器自动生成各种语言的源码,方便的读写用户自定义的格式化的数据。与语言无关,与平台无关,还可以在不破坏原数据格式的基础上,依据老的数据格式,更新现有的数据格式。

   

          在很多谷歌开源的程序中都大部分用到了protobuf,比如最新开源出来的object_detection中就存在这样的定义。最近想着编译一下这个目标检测识别的程序,发现protobuf居然报了个错误,错误码即如下:


.proto:386:3: Expected "required", "optional", or "repeated".


针对这个问题,才发现自己电脑上的protobuf版本是2.5版本(通过命令:protoc --version进行查看),可能原因还是新版本又更新了一些参数,查看了下需求,也发现需要用到2.6版本,所以只能重新进行编译protobuf.高的版本。
于是从https://github.com/google/protobuf/releases?after=v2.6.1下载2.6的数据包。

        直接按照传统的  ./configure,  make -j4 , sudo make install等方式来进行安装。

        这时候还需要一个步骤,需要在/etc/profile中配置一下参数:

[plain] view plain copy

    export LD_LIBRARY_PATH=/usr/local/lib  


不然就会报如下错误:

protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory

        完成安装后,再重新进行进行代码转换,即可成功。

[html] view plain copy

    protoc ./object_detection/protos/*.proto --python_out=.  
    dscbigdata-Lenovo-Product:~/work/tensorflow/models-master$   


这时候,对应的python文件已经生成。


在object_detection中的mobilev1训练时,出现failed to find any matching files for .......................(ckpt保存地址)

此训练使用迁移学习进行的训练,需要下载别人的训练节点进行训练加速。




Openstack从入门到精通-(最新Pike版避免踩坑)

-
  • 1970年01月01日 08:00

tensorflow 入门踩坑

官方学习文档,第一个程序,掉进坑里 http://wiki.jikexueyuan.com/project/tensorflow-zh/get_started/basic_usage.html ...
  • qq_33291307
  • qq_33291307
  • 2018-01-25 06:27:47
  • 20

Windows 下安装tensorflow的坑

在Windows上安装tensorflow折腾了很长时间,有几次本以为装好了,没用两次就不能用了,希望大家不要踩同样的坑  系统:Windows7 显卡:GTX850s tensorflow:0....
  • chuangchuangtan
  • chuangchuangtan
  • 2017-03-14 19:12:06
  • 770

致Android-那些年,我们一起踩过的坑

大爷的,从搞android至今,踩过的坑倒是不少,MD,要是同一个坑,踩一次也就算了,踩两次、多次那就显得狠low了…记录那些年,希望跟我踩同一个坑的同胞们一些帮助(主要是怕自己踩同一个坑,哈哈~~)...
  • yiluyoufeng
  • yiluyoufeng
  • 2016-06-18 23:29:23
  • 843

前端踩的一些坑

今天用bootstrap modal 进行ajax发送数据时,发送数据时第一次点击,发送一次ajax提交,第二次点击发送两次ajax提交,第三次点击发送3次ajax提交...),原来是在标签上绑定了太...
  • leadn
  • leadn
  • 2017-02-15 16:36:28
  • 1251

Bootstrap踩坑经历

Bootstrap是一款十分受欢迎的前端响应式框架,里面几乎包含了所有你能想到的优秀组件,设计出来的网站十分炫酷,但是使用过程并没有想象中的那么顺利,这里发布一下使用Bootstrap时所可能遇到的'...
  • z403877967
  • z403877967
  • 2017-06-07 16:04:13
  • 572

前端踩坑

1、inline-block元素自带的4px边距 设置父元素font-size:0;letter-spacing:-4px; 然后设置子元素正常的font-size和letter-spacing; ...
  • ViVianWhere
  • ViVianWhere
  • 2017-03-10 16:57:47
  • 365

Tensorflow 跑MaskRCNN框架遇到的各种坑(一)

根据网上的教程,配置好了gpu 版本的tensorflow,开始安装MaskRCNN ,遇到问题,在此记录一下 首先按照这篇教程 http://blog.csdn.net/wei_guo_xd/art...
  • Aimer_Chen
  • Aimer_Chen
  • 2017-11-14 11:17:44
  • 1314

vue踩坑不完全指北(1)

1.Vuejs组件 vuejs构建组件使用 Vue.component('componentName',{ /*component*/ }); 这里注意一点,组件要先注册再使用,也就是说: Vue...
  • chern1992
  • chern1992
  • 2017-06-10 16:01:53
  • 1032

前端总结:踩过的坑以及一些冷知识

css css样式这一块坑比较多,有些情况不按常理出牌,在精确控制样式和大小时就会遇到这些坑。 1、 行内元素(比如img)默认会在末尾(或底部)留白/间隙,无法去除。解决办法:通过disp...
  • linysuccess
  • linysuccess
  • 2016-12-02 10:56:32
  • 876
收藏助手
不良信息举报
您举报文章:新手踩坑tensorflow上运行模型
举报原因:
原因补充:

(最多只允许输入30个字)