PointRCNN环境搭建及部署

算法地址:PointRCNN

1.数据集(KITTI)准备

官网地址:KITTI数据集官网

数据集结构

1

2.环境部署

a.环境概览

1
2
3
4
5
python 3.6
cuda 10.0
gcc <=7
pytorch==1.0.0
torchvision==0.2.1

b.创建虚拟环境并激活

1
2
conda create -n pointRCNN python=3.6
conda activate pointRCNN

下载源代码:

1
git clone --recursive https://github.com/sshaoshuai/PointRCNN.git

c.安装cuda10.0

具体参考我这篇博客 Yolov4算法部署及环境搭建(服务器上)

在安装老版本的cuda时,会有一些注意事项(特别时安装时的一些注意事项)

1
2
3
4
5
6
7
8
9
10
11
12
#是否安装显卡驱动包,这里注意由于我已经安装了新版显卡驱动,所以选择n,如果你是首次安装选择y

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
y)es/(n)o/(q)uit: n


#添加symbolic link链接 **注意这个连接,如果你之前安装过另一个版本的cuda,除非你确定想要用这个新版本的cuda,否则为了不影响目前服务器系统环境这里就选no。因为指定该链接后,服务器系统将会把默认使用的cuda指向这个新安装的版本** 如果你是首次安装可以选择yes。由于我这里安装过cuda版本,所以选择no

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: n

详细细节可以参考原文链接:https://blog.csdn.net/sinat_30545761/article/details/107709468/

d.安装pytorch1.0.0并配置依赖环境

1
2
3
4
5
6
7
8
9
10
11
pip install easydict
pip install tqdm
pip install tensorboardX
pip install fire
pip install numba
pip install pyyaml
pip install scikit-image
pip install shapely

conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch

在运行最后一步时可能会出现如下报错:

1
2
3
4
5
6
Collecting package metadata (current_repodata.json): done

Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:

- pytorch==1.0.0

解决问题的方法有如下可以参考:

1).增加清华源

1
2
3
4
5
6
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

conda update --all

并未解决

2).手动安装,将torch和torchvision分别安装。

1
2
3
4
5
6
7
pip install https://download.pytorch.org/whl/cu100/torch-1.0.0-cp36-cp36m-linux_x86_64.whl

#torch下载网站https://blog.csdn.net/anananajiushiwo/article/details/123741754
#在该网站中下载想对应的torchvision
#https://pypi.tuna.tsinghua.edu.cn/simple/torchvision/

pip install torchvision-0.2.1-py2.py3-none-any.whl

e.安装gcc(7.2.0)

gcc各版本下载: http://ftp.gnu.org/gnu/gcc/

1
2
3
4
5
6
7
8
9
wget http://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
tar -zxvf gcc-7.2.0.tar.gz

cd gcc-7.2.0/
./contrib/download_prerequisites

./configure --prefix=/space2/zhangzk/GCC --enable-languages=c,c++ --disable-multilib
make -j16 && sudo make install

不出意料,编译会出现很多问题,如下:

1).sanitizer_platform_limits_posix.cc:158:23: 致命错误: sys/ustat.h:没有那个文件或目录
1
2
../../.././libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:158:23: 致命错误: sys/ustat.h:没有那个文件或目录
#include <sys/ustat.h>

解决:

  • 首先将gcc-7.2.0/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc中的这一行#include <sys/ustat.h>中注释或者删除。

  • 大约在250行左右插入。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
    // has been removed from glibc 2.28.
    #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
    || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
    || defined(__x86_64__)
    #define SIZEOF_STRUCT_USTAT 32
    #elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
    || defined(__powerpc__) || defined(__s390__)
    #define SIZEOF_STRUCT_USTAT 20
    #else
    #error Unknown size of struct ustat
    #endif
    unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;

    2

2).
1
2
error: size of array ‘assertion_failed__1150’ is negative  
typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]

我们需要根据这个补丁改一下gcc7.2.0的代码:gcc: Fix error 'size of array is negative' (#16968) · spack/spack@6fb6b28 (github.com)

3).其他问题参考(本人没遇到)

从源码构建gcc扫雷笔记 - 知乎 (zhihu.com)

ubuntu 20.04LST跌跌撞撞安装编译gcc6.3.0_狂躁脑电波的博客-CSDN博客

编译成功后,配置环境变量:

1
2
3
export PATH=/space2/zhangzk/GCC/bin:/space2/zhangzk/GCC/lib64:$PATH     #gcc-7.2.0
export LD_LIBRARY_PATH=/space2/zhangzk/GCC/lib/:$LD_LIBRARY_PATH

f.安装依赖pointnet2,iou3d,roipool3d

1
sh build_and_install.sh

参考:

服务器运行PointRCNN代码全过程记录_今天也想干嘛呢的博客-CSDN博客


PointRCNN环境搭建及部署
https://collapsarva.github.io/2023/11/12/PointRCNN环境搭建及部署/
Author
zzk
Posted on
November 12, 2023
Licensed under