使用TensorFlow遇到的若干问题

2022-02-15一、查看版本:

进入命令行状态后,可以在终端输入查询命令如下:

import tensorflow
tensorflow.__version__

查询安装路径为:

tensorflow.__path__

二、cuDNN 不可用

Loaded runtime CuDNN library: 7.0.5 but source was compiled with: 7.1.4.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration.

我的开发环境是

ubuntu18.04   
cuda9.0   
cudnn7.0  
tensorflow 1.12.0  
python 3.6

发现错误原因是版本太高。

解决方案是降级到与我的cudnn匹配的版本:

pip3 install --upgrade --force-reinstall tensorflow-gpu==1.9.0

三.没有命名的”错误

File "object_detection/builders/model_builder_test.py", line 23, in      
    from object_detection.builders import model_builder Module
NotFoundError: No module named 'object_detection'

这是上一步slim的导入路径,要使用slim的绝对路径:

export PYTHONPATH="$PYTHONPATH:/home/user/models/research/slim"

四、:” 没有’mul’

原因:新版本发布的API已经修改

tf.mul, tf.sub and tf.neg are deprecated in favor of tf.multiply, tf.subtract and tf.negative.

解决方案:将 tf.mul 更改为 tf.mul。使用时,将 tf.sub 和 tf.neg 的其余部分更改为 tf.和 tf。相应地。

五、:

打印“纪元 {0}:{1} / {2}”。(

^

中的打印功能

需要括号。

六、Dst 不是

原因:GPU 内存已满。

解决方法:如果使用,请关闭其他正在运行的程序。

七、Numpy 版本变更

每次运行代码都会出现这个警告,其实numpy的版本比较高

/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/eason/.local/lib/python3.5/site-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])

先卸载numpy:

pip3 uninstall numpy

重新安装,只要是1.版本17或更低

pip3 install numpy==1.16

八、: 没有命名的”

解决方案:

sudo apt-get install python3-tk

分类:

技术要点:

相关文章:

© 版权声明
THE END
喜欢就支持一下吧
点赞7赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容