Ubuntu 16.04 Caffe SSD 环境配置以及训练自己的数据集

这篇文章我一开始写在简书,欢迎关注我的简书账号,会写一些论文翻译以及模型实现过程。「我的简书文章地址」
这篇文章都尽量写的详尽。如果你有任何问题,欢迎在这里提问,或者到我点简书提问
总的来说,Caffe 是一个比较难上手的框架。这次尝试训练 Caffe 框架下 SSD 模型的训练是我第一次使用 Caffe 框架。下面就说一说我踩过的几个坑,希望能够帮助到大家。

1 编译 Caffe 框架

这一步是我认为使用 Caffe 框架的最大障碍,编译不停出错。最后我不得不放弃转而使用 Docker 解决 Caffe 的编译安装问题。下面写出 Docker 的安装以及拉取所需镜像的方法。

Docker 安装

安装过程我是参照的 Docker 官方的安装指引,传送门在这里。
我使用的安装命令为(Ubuntu 16.04 LTS):

# If you have installed older version of docker, removing it by using command as follows
sudo apt-get remove docker docker-engine docker.io

# Docker installation
# 1. Update the apt package index
sudo apt-get update
# 2. Install packages to allow apt to use a repository over HTTPS
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
# 3. Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 4. Add apt repository
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
# 5. INSTALL DOCKER CE
sudo apt-get update
sudo apt-get install docker-ce
# 6. Verify that Docker CE is installed correctly by running the hello-world image
sudo docker run hello-world

以上就是 Docker 的安装过程,安装完成 Docker 后,下一步就是寻找合适的镜像并拉取。如果你对 Docker 的使用并不熟悉,推荐你阅读《第一本Docker书》的前4章,阅读时间大约在2个小时,下载在这里。

寻找并拉取合适的镜像

我是在 Docker Hub 直接搜索我需要的镜像的,我的需求是 python2, gpu 版本的 Caffe 并且是 SSD 分支。
在 Bing.com 搜索「docker hub」,打开之后搜索关键词 「caffe ssd」。
搜索镜像
我所使用的镜像链接在这里。
如果你想在 Docker 中使用 GPU 加速,那么你还必须安装 nvidia-docker,不过幸好安装特别简单。过程如下:

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi

按照顺序依次执行就可以了,如果你遇到问题,请参照

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值