配置tf-faster-rcnn及训练自己的数据

 本机的python环境采用anaconda3创建的python2.7,其中所有安装的依赖和库均在这个虚拟环境中

系统:Ubuntu16.04

显卡:2块tesla p100 

内存:64

python2.7 +Tensorflow-gpu=1.10 +cudnn 9.0+cudnn 7.0.5

一、安装anaconda3,配置路径

vim ~/.bashrc

在最后一行添加:

# anaconda path
export PATH=/home/tanbin/anaconda3/bin:$PATH

使其生效:source ~/.bashrc

二、创建虚拟环境

创建环境:

conda create -n tf27 python=2.7

**环境并进入环境:

source activate tf27

配置tf-faster-rcnn及训练自己的数据

三、安装tensorflow

为了方便,先升级pip

pip install --upgrade pip 或者pip install -U pip

安装tensorflow(这里直接安装tensorflow==1.10)

pip install tensorflow-gpu==1.10

安装其他重要的库 numpy、scipy、matplotlib、PIL(python2.7安装pillow)等,训练过程缺少什么安装什么

pip install numpy scipy pillow matplotlib

四、tf-faster-rcnn 代码克隆下载

git clone https://github.com/endernewton/tf-faster-rcnn.git

建议使用下面方式克隆代码:

git clone --recursive https://github.com/endernewton/tf-faster-rcnn.git

ps:git clone --recursive 用于循环克隆git子项目 

五、配置

1、根据你的显卡更改下对应的计算单元

在tf-faster-rcnn/lib/setup.py的第130行,Tesla p100对应的是sm_60,这里查看NVIDA CUDA显卡计算能力对应表

配置tf-faster-rcnn及训练自己的数据

2、安装cython opencv-python easydict

原作者写到:配置tf-faster-rcnn及训练自己的数据

注意安装opencv的命令是:

  1. pip install python-opencv
  2. pip install cython
  3. pip install easydict

3、安装coco API

  • cd data
  • git clone https://github.com/pdollar/coco.git

  • cd coco/PythonAPI

  • make

 

 

链接: https://pan.baidu.com/s/1xobJj665t7uJg-Dyi4Feug 提取码: 372p

 

 

 

问题一:

 E tensorflow/stream_executor/cuda/cuda_dnn.cc:363] 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

原因:说的是cudnn问题,其实是安装的tensorflow版本较高,不兼容cudnn,本及安装的是tensorflow=1.12.0版本的

解决:卸载原有tensorflow ,重新安装tensorflow=1.10

pip uninstall tensorflow-gpu

pip install tensorflow-gpu==1.10

问题2:

出现numpy changed ………………,其原因跟可能是tensorflow降级后,导致numpy跟着降级了

解决:升级numpy

           pip install --upgrade numpy

问题三:

找不到 data/VOCdevkit2007/results/VOC2007/Main/xxxxxx.txt

这个原因是配置数据文件的时候,没有完全按照pascal_voc格式准备,未设置result文件价及其内容

配置tf-faster-rcnn及训练自己的数据

应该按照这样的格式严格分配数据

 

 问题4:

【Python问题】ImportError: No module named 'yaml' 的解决方法

解决方法:

pip install pyyaml

注意:pip install yaml无效 ,conda install yaml能成功安装,但是不起作用