新手踩坑tensorflow上运行模型

一、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保存地址)

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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////

。///////////////////////////

///////////////////////

////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




ubuntu16.04电脑异常关机后分辨率出现的特别低,设置里分辨率只有800*600。查资料发现是因为异常关机导致驱动出现错误。


解决方法为:在设置中选择更新:

                              


                           然后选择驱动设备:

                              

           由于上传的电脑没有GPU,上面显示没有。有GPU的 选择英伟达驱动进行更新,重启计算机即可。。                 

阅读更多

扫码向博主提问

__JDM__

非学,无以致疑;非问,无以广识
去开通我的Chat快问
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页