0
点赞
收藏
分享

微信扫一扫

在Ubuntu16下安装matterport3D simulator

zidea 2022-04-08 阅读 177
ubuntudocker

安装matterport3D simulator

前言

这个仿真用的很少,网上资料不多,我报错比较奇怪,特此记录。
感谢:
https://blog.csdn.net/qq_45383577/article/details/122754022
https://blog.csdn.net/weixin_41848012/article/details/119854292

安装步骤

1.下载数据集

1.1 进入官网下载申请表。发送邮件至matterport3d@googlegroups.com
Matterport3D: Learning from RGB-D Data in Indoor Environments (niessner.github.io)
点击Download选项
1.2 获得安装许可,使用附件.py文件下载即可。
在这里插入图片描述
在同级目录下使用命令:

python2.7 download_mp.py -o [你的下载路径] --type matterport_skybox_images

目前只下载90个建筑的数据,大小一共是20G左右。
在这里插入图片描述

2.安装simulator

用docker安装,好处大佬们说的很清楚。
2.1 所需条件:

Nvidia GPU with driver >= 396.37
安装docker,安装教程地址:https://docs.docker.com/engine/install/ubuntu/
安装nvidia-docker2.0,安装教程地址:https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker
注意:CUDA/CuDNN不需要安装,因为这些会在docker image中提供

2.2 下载Matterport3DSimulator

# Make sure to clone with --recursive
git clone --recursive https://github.com/peteanderson80/Matterport3DSimulator.git

这里如果–recursive获取子项目的时候出现问题:
在这里插入图片描述
解决方法:进入对应git网址:https://github.com/peteanderson80/Matterport3DSimulator
下载主项目Matterport3DSimulator
在这里插入图片描述
点击pybind11进入子项目下载,将全部内容放入主项目文件夹中的pybind11中
在这里插入图片描述
2.3 使用Docker创建容器

#必须在Matterport3DSimulator文件中执行操作
cd Matterport3DSimulator
#这里是18.04,我是16.04,并不影响
sudo docker build -t mattersim:9.2-devel-ubuntu18.04 .

报红1:code:100
在这里插入图片描述
解决方法:使用https://blog.csdn.net/qq_45383577/article/details/122754022 的方法可以解决此错误。进入Matterport3DSimulator文件目录下修改Dockerfile文件,我修改后的如下:

# Matterport3DSimulator
# Requires nvidia gpu with driver 396.37 or higher


FROM nvidia/cudagl:9.2-devel-ubuntu18.04

# Install cudnn
ENV CUDNN_VERSION 7.6.4.38
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
#修改
RUN sed -i "s#http://archive.ubuntu.com/#http://mirrors.tuna.tsinghua.edu.cn/#" /etc/apt/sources.list \
    && rm -Rf /var/lib/apt/lists/* \
    && apt-get update
RUN apt-get install -y --no-install-recommends \
    libcudnn7=$CUDNN_VERSION-1+cuda9.2 \
libcudnn7-dev=$CUDNN_VERSION-1+cuda9.2 \
&& \
    apt-mark hold libcudnn7 && \
    rm -rf /var/lib/apt/lists/*

# Install a few libraries to support both EGL and OSMESA options
ENV DEBIAN_FRONTEND=noninteractive
#修改
RUN sed -i "s#http://archive.ubuntu.com/#http://mirrors.aliyun.com/pypi/simple/#" /etc/apt/sources.list \
    && rm -Rf /var/lib/apt/lists/* \
    && apt-get update

RUN apt-get install -y wget doxygen curl libjsoncpp-dev libepoxy-dev libglm-dev libosmesa6 libosmesa6-dev libglew-dev libopencv-dev python-opencv python3-setuptools python3-dev python3-pip
RUN pip3 install opencv-python==4.1.0.25 torch==1.1.0 torchvision==0.3.0 numpy==1.13.3 pandas==0.24.1 networkx==2.2

#install latest cmake
ADD https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.sh /cmake-3.12.2-Linux-x86_64.sh
RUN mkdir /opt/cmake
RUN sh /cmake-3.12.2-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
RUN cmake --version

ENV PYTHONPATH=/root/mount/Matterport3DSimulator/build

报红2:code:2这个错误是我解决上述错误后出现的,究其原因就是time out,网络问题。尝试了很多方法:修改延迟时间,换源,翻墙等依然效果不大。
在这里插入图片描述
解决方法:再次修改dockefile文件,删除报错部分,也就是pip3安装命令,待容器创建完成后,缺什么补什么。

# Matterport3DSimulator
# Requires nvidia gpu with driver 396.37 or higher

FROM nvidia/cudagl:9.2-devel-ubuntu18.04

# Install cudnn
ENV CUDNN_VERSION 7.6.4.38
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
####
RUN sed -i "s#http://archive.ubuntu.com/#http://mirrors.tuna.tsinghua.edu.cn/#" /etc/apt/sources.list \
    && rm -Rf /var/lib/apt/lists/* \
    && apt-get update
RUN apt-get install -y --no-install-recommends \
    libcudnn7=$CUDNN_VERSION-1+cuda9.2 \
libcudnn7-dev=$CUDNN_VERSION-1+cuda9.2 \
&& \
    apt-mark hold libcudnn7 && \
    rm -rf /var/lib/apt/lists/*
    
# Install a few libraries to support both EGL and OSMESA options
ENV DEBIAN_FRONTEND=noninteractive

RUN sed -i "s#http://archive.ubuntu.com/#http://mirrors.aliyun.com/pypi/simple/#" /etc/apt/sources.list \
    && rm -Rf /var/lib/apt/lists/* \
    && apt-get update
#####################这里原本是pip3安装命令,我删除了#######################################################
RUN apt-get install -y wget doxygen curl libjsoncpp-dev libepoxy-dev libglm-dev libosmesa6 libosmesa6-dev libglew-dev libopencv-dev python-opencv python3-setuptools python3-dev python3-pip
#install latest cmake
ADD https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.sh /cmake-3.12.2-Linux-x86_64.sh
RUN mkdir /opt/cmake
RUN sh /cmake-3.12.2-Linux-x86_64.sh --prefix=/opt/cmake --skip-license
RUN ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
RUN cmake --version

ENV PYTHONPATH=/root/mount/Matterport3DSimulator/build

容器创建成功如图:
在这里插入图片描述
2.3 编辑容器
添加数据集路径到环境中

#命令打开bashrc文件
sudo gedit ~/.bashrc
最后添加路径(每个人都不同):
export MATTERPORT_DATA_DIR=/home/ryain/M3D/v1/scans

进入容器:

nvidia-docker run -it --mount type=bind,source=$MATTERPORT_DATA_DIR,target=/root/mount/Matterport3DSimulator/data/v1/scans --volume `pwd`:/root/mount/Matterport3DSimulator mattersim:9.2-devel-ubuntu18.04

下载之前缺少的依赖,

pip3 install opencv-python==4.1.0.25 torch==1.1.0 torchvision==0.3.0 numpy==1.13.3 pandas==0.24.1 networkx==2.2 -i https://pypi.tuna.tsinghua.edu.cn/simple

这里可能会出两个问题,先是pip3需要下载,补上就行了。再一个就是https://blog.csdn.net/qq_45383577/article/details/122754022提到的python版本问题,我按照大佬方法修改:

apt-get update
apt-get install sudo

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 200

最后编译容器:

cd /root/mount/Matterport3DSimulator
mkdir build && cd build
cmake -DEGL_RENDERING=ON ..
make
cd ../

编译成功后:
在这里插入图片描述

后续待更

参考文章:
1]: https://github.com/peteanderson80/Matterport3DSimulator
2]: https://blog.csdn.net/weixin_41848012/article/details/119854292
3]: https://blog.csdn.net/qq_45383577/article/details/122754022
4]: https://zhuanlan.zhihu.com/p/424693141

举报

相关推荐

0 条评论