Ubantu-TF1.14-gpu+object_detection_API安装过程

注:以下操作需要安装好cuda和cudnn后进行一下操作

Step 1:安装virtualenv

使用安装命令如下:

pip install virtualenv

安装完成后,创建python=3.6的虚拟环境,命令如下:

virtualenv envpy3.6 --python=python3.6

这是会报virtualenv命令找不到的错误,需要将virtualenv安装目录的bin目录添加到PATH

环境变量中,/wbq/.bashrc 末尾添加。

export PATH=/home/wbq/.local/bin:$PATH

再次执行创建虚拟环境的命令,进入虚拟环境并开启虚拟环境:

cd /home/wbq/envpy3.6/
source ./bin/activate

Step 2:安装tensorflow1.14

使用pip 命令安装,因为安装包较大报了超时的错,所以加上镜像源安装:

pip install tensorflow-gpu==1.14.0  -i https://pypi.doubanio.com/simple/

使用代码测试一下:

import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
>>>
Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: GeForce GTX 960M, pci bus id: 0000:02:00.0, compute capability: 5.0

Step 3:安装Protobuf

在安装tensorflow1.14.0-gpu版本时,pip自动安装了protobuf-3.12.2,需要下载相同版本的解压包,下载链接如下:

https://github.com/protocolbuffers/protobuf/releases的到protobuf-all-3.12.2.tar.gz

使用下面命令解压并安装:

tar -zvxf protobuf-all-3.12.2.tar.gz -C ./protobuf3.12.2/
cd /home/wbq/yuxiubin/protobuf3.12.2/protobuf-3.12.2/
./configure
make
make check          #会出错 但是不用管
sudo make install

测试是否安装成功:

protoc --version

出现错误:

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

添加如下环境路径:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Step 4:安装Object_detection API-1.13.0

官网的安装文档如下:https://github.com/tensorflow/models/blob/r1.13.0/research/object_detection/g3doc/installation.md

按照官方文档进行安装

使用protoc进行编译:

/home/wbq/yuxiubin/transfer_detect/models-r1.13.0/research/
protoc object_detection/protos/*.proto --python_out=.

配置环境变量:

export PYTHONPATH=$PYTHONPATH:/home/wbq/yuxiubin/transfer_detect/models-r1.13.0/research/:/home/wbq/yuxiubin/transfer_detect/models-r1.13.0/research/slim

测试脚本如下:

python object_detection/builders/model_builder_test.py
#测试成功显示:
Ran 22 tests in 0.132s
OK (skipped=1)

Step 5:安装COCO API

Download the cocoapi and copy the pycocotools subfolder to the tensorflow/models/research directory if you are interested in using COCO evaluation metrics. The default metrics are based on those used in Pascal VOC evaluation. To use the COCO object detection metrics add metrics_set: "coco_detection_metrics" to the eval_config message in the config file. To use the COCO instance segmentation metrics add metrics_set: "coco_mask_metrics" to the eval_config message in the config file.

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tecnsorflow>/models/research/

出现错误:

x86_64-linux-gnu-gcc: error: pycocotools/_mask.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files

安装pip install cython

所以官方文档中的这些包最好还是要装上:

pip install --user Cython
pip install --user contextlib2
pip install --user pillow
pip install --user lxml
pip install --user jupyter
pip install --user matplotlib

装上依旧报错:

' error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 '

在虚拟环境python3.6中使用如下命令,make成功:

sudo apt-get install python3 python-dev python3-dev \
     build-essential libssl-dev libffi-dev \
     libxml2-dev libxslt1-dev zlib1g-dev \
     python-pip

再次执行:

cp -r pycocotools <path_to_tensorflow>/models/research/

Step 6:使用Object_detect进行模型训练

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值