caffe pwcnet docker

该博客详细介绍了如何在基于nvidia/cuda的Docker镜像中安装Flownet2。首先,通过docker run命令创建并启动容器,然后将代码库上传并安装必要的依赖。接着,手动下载并解压Flownet2的模型文件。最后,配置Caffe环境并运行Flownet2进行光流估计。整个过程包括了环境设置、依赖安装、模型部署和代码执行等步骤。
摘要由CSDN通过智能技术生成

思路:在nvidia/cuda镜像中安装Dockerfile提到的内容

参照flownet2-docker-master中的Dockfile

1、创建nvidia/cuda容器
在一个你希望和容器文件建立映射的路径下运行以下命令

docker run -it --runtime=nvidia -v $PWD:/home/share --gpus all nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04 bash

2、上传flownet2-docker-master到容器中,也就是建立映射的路径
3、安装

apt-get update &&                          \
    apt-get install -y --no-install-recommends \
        module-init-tools                      \
        build-essential                        \
        ca-certificates                        \
        wget                                   \
        git                                    \
        libatlas-base-dev                      \
        libboost-all-dev                       \
        libgflags-dev                          \
        libgoogle-glog-dev                     \
        libhdf5-serial-dev                     \
        libleveldb-dev                         \
        liblmdb-dev                            \
        libopencv-dev                          \
        libprotobuf-dev                        \
        libsnappy-dev                          \
        protobuf-compiler                      \
        python-dev                             \
        python-numpy                           \
        python-scipy                           \
        python-protobuf                        \
        python-pillow                          \
        python-skimage

4、安装flownet2
1)这里我把github上的代码下载之后放到了码云上,免得被墙。以下是在flownet2-docker-master文件下,一行一行运行

git clone https://gitee.com/haixusong/flownet2
cp ./FN2_Makefile.config ./flownet2/Makefile.config
cp ./FN2_run-flownet-docker.py ./flownet2/scripts/run-flownet-docker.py
cd flownet2
rm -rf .git                                                 
cd models

2)使用vim打开models下的download-models.sh文件,里面有三个模型的链接,手动下载吧,毕竟被墙了。这模型文件挺大的,不能放到码云,这也就是为啥我没用Dockerfile的原因。
下载后上传并解压到models文件夹,例如:

tar xvzf flownet2-models.tar.gz -C ……/flownet2/models

记得换成自己models的路径。

rm flownet2-models.tar.gz                                               && \
    cd ..                                                                   && \
    make -j`nproc`                                                          && \
    make -j`nproc` pycaffe

3)删除不需要的软件

apt-get remove -y                               \
        module-init-tools                           \
        build-essential                             \
        ca-certificates                             \
        git                                         \
        wget                                     && \
    apt-get install -y --no-install-recommends      \
        sudo                                     && \
    apt-get autoremove -y                        && \
    apt-get autoclean -y                         && \
    rm -rf /var/lib/apt/lists/*

参照run-network.sh,在创建的容器中

1)flownet2中配置caffe环境:source set-env.sh

2)运行.py文件
非kitti
在这之前可先创建output文件夹,这是个绝对路径。cd /output 可查看运行结果

python run-flownet-docker.py --gpu 0 /home/share/flownet2-docker-master/flownet2/models/FlowNet2/FlowNet2_weights.caffemodel* /home/share/flownet2-docker-master/flownet2/models/FlowNet2/FlowNet2_deploy.prototxt.template data/0000000-imgL.png data/0000001-imgL.png flow.flo

同时运行多个:

python run-flownet-docker.py --gpu 0 /home/share/flownet2-docker-master/flownet2/models/FlowNet2/FlowNet2_weights.caffemodel* /home/share/flownet2-docker-master/flownet2/models/FlowNet2/FlowNet2_deploy.prototxt.template data/flowinput/0003-first.txt data/flowinput/0003-second.txt data/flowout/0003.txt

kitti

python run-flownet-docker.py --gpu 0 /home/share/flownet2-docker-master/flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_weights.caffemodel* /home/share/flownet2-docker-master/flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_deploy.prototxt.template data/0000000-imgL.png data/0000001-imgL.png flow.flo
python run-flownet-docker.py --gpu 0 /home/share/flownet2-docker-master/flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_weights.caffemodel* /home/share/flownet2-docker-master/flownet2/models/FlowNet2-KITTI/FlowNet2-KITTI_deploy.prototxt.template data/flowinput/0003-first.txt data/flowinput/0003-second.txt data/flowout/0003.txt

容器ID1641e69a108c
在这里插入图片描述
3)每次重启容器,再代码时候都要配置caffe的环境,比较麻烦,将环境加到.bashrc文件里
在flownet2文件下:

echo $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

以上可获得CAFFE_PATH的数值

vim ~/.bashrc

复制以下内容:

CAFFE_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

RELEASE_PATH="$CAFFE_PATH/build" 

export PYTHONPATH="$CAFFE_PATH/python:$PYTHONPATH"
export LD_LIBRARY_PATH="$RELEASE_PATH/lib:$LD_LIBRARY_PATH"
export PATH="$RELEASE_PATH/tools:$RELEASE_PATH/scripts:$PATH"
export CAFFE_BIN="$RELEASE_PATH/tools/caffe"

记得替换CAFFE_PATH的数值,这个内容其实就参照的set-env.sh。最后

source ~/.bashrc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值