【玩转PointPillars】Ubuntu18.04上部署second

【我的环境】

Ubuntu 18.04

cuda 10.2

cudnn 8.0.3

gcc 8.4.0

cmake 3.16.8

    这仅仅是一次实验记录,其意义在于如果你的系统环境与我的一样,可以放心大胆地按照以下步骤成功部署。脱离上面的主要环境,则一切失败皆有可能发生。

1.创建虚拟环境

(base) ➜  ~ conda create -n second python=3.6
(base) ➜  ~ conda activate second  #激活

2. 安装依赖软件

(second) ➜  ~ conda install scikit-image scipy numba pillow matplotlib
(second) ➜  ~ pip install fire tensorboardX protobuf opencv-python
(second) ➜  ~ conda install shapely pybind11 protobuf
(second) ➜  ~ conda install google-sparsehash -c bioconda
(second) ➜  ~ sudo apt-get install libboost-all-dev

3. 安装pytorch

(second) ➜  ~ conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.2 -c pytorch

4. 安装spconv

        这个就是second的一大创新点,引入了稀疏卷积。

(second) ➜  ~ git clone https://github.com/traveller59/spconv.git  --recursive
(second) ➜  ~ cd spconv
(second) ➜  ~ python setup.py bdist_wheel
(second) ➜  ~ cd ./dist   
(second) ➜  ~ pip install spconv-1.2.1-cp36-cp36m-linux_x86_64.whl

4. 安装Apex

        APEX是英伟达开源的,完美支持PyTorch框架,用于改变数据格式来减小模型显存占用的工具。其中最有价值的是amp(Automatic Mixed Precision),将模型的大部分操作都用Float16数据类型测试,一些特别操作仍然使用Float32。并且用户仅仅通过三行代码即可完美将自己的训练代码迁移到该模型。实验证明,使用Float16作为大部分操作的数据类型,并没有降低参数,在一些实验中,反而由于可以增大Batch size,带来精度上的提升,以及训练速度上的提升。

        安装Apex的前提是你安装好了CUDA和CUDNN,另外你安装的CUDA版本和编译pytorch的cuda版本要是一致的,不然会报错。我这里确认一下。

(second) ➜  ~ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
(second) ➜  ~ python -c "import torch;print(torch.version.cuda)" 
10.2

(second) ➜  ~ git clone https://github.com/NVIDIA/apex
(second) ➜  ~ cd apex
(second) ➜  ~ pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./

5. 配置second

(second) ➜  ~ git clone https://github.com/traveller59/second.pytorch.git
(second) ➜  ~ cd  ./second.pytorch/second

将下面的环境变量写入.bashrc。当然,这个是依你实际所用的SHELL来的,像我是用zsh,所以环境变量我写入到.zshrc中。

export NUMBAPRO_CUDA_DRIVER=/usr/lib/x86_64-linux-gnu/libcuda.so
export NUMBAPRO_NVVM=/usr/local/cuda/nvvm/lib64/libnvvm.so
export NUMBAPRO_LIBDEVICE=/usr/local/cuda/nvvm/libdevice

export PYTHONPATH=$PYTHONPATH:~/second.pytorch  #(换成自己的路径)

6. 配置KittiViewer

(1).安装依赖

        这里主要是安装flask和flask_cors,其中flask_cors是用来解决跨域问题。

pip install flask -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install flask_cors -i https://pypi.tuna.tsinghua.edu.cn/simple
(2). 启动后端服务器

(second) ➜  kittiviewer git:(master) python backend/main.py main
  warnings.warn(errors.NumbaWarning(msg))
 * Serving Flask app 'second' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:16666/ (Press CTRL+C to quit)

(3). 在本地启动一个web server

(second) ➜  frontend git:(master) python -m http.server 
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
(4). 浏览器上打开

【参考文献】

https://blog.csdn.net/lemonxiaoxiao/article/details/111995328#commentBox

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值