Back
Featured image of post Paddle飞桨部署方案

Paddle飞桨部署方案

Paddle飞桨部署文档

Paddle是百度开源的一款深度学习平台

基础环境

环境说明

版本
GPU NVIDA Tesla P4
操作系统 ubuntu 18.04 x86_64
硬件规格 4C20G 1Mbps + 100GB
Python 3.7.10
包管理 Anaconda 3
telsa驱动 NVIDIA-Linux-x86_64-418.152.00
cuda驱动 cuda_10.1.243_418.87.00_linux

环境预设

  1. 检查显卡
lspci | grep -i nvidia

2.确认gcc版本,没有则安装

gcc --version

3.安装内核开发包

sudo apt-get install linux-headers-$(uname -r)

4.禁掉Nouveau驱动

echo '''blacklist nouveau
options nouveau modeset=0''' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf

sudo update-initramfs -u

5.重启,检查模块是否成功禁用

sudo reboot
# 检查无输出则正常
lsmod |grep nouveau 

安装 tesla驱动

  1. 安装dkms

    sudo apt-get install dkms
    
  2. 下载驱动

    http://www.nvidia.com/Download/Find.aspx

    类别 选项
    Product Type Data Center / Telsa
    Product Series P-Series
    Product Telsa P4
    Operating System Linux 64-bit
    CUDA Toolkit 10.1
    Language English(US)

    选择Telsa Driver for Linux 64 # 418.152.00进行下载

  3. 安装

    chmod +x NVIDIA-Linux-x86_64-418.152.00.run
    sudo ./NVIDIA-Linux-x86_64-418.152.00.run
    
  4. 验证

    nvidia-smi
    

    输出如下

    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 418.152.00   Driver Version: 418.152.00   CUDA Version: 10.1     |
    |-------------------------------+----------------------+----------------------+
    | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
    | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
    |===============================+======================+======================|
    |   0  Tesla P4            Off  | 00000000:00:09.0 Off |                    0 |
    | N/A   24C    P8     6W /  75W |      0MiB /  7611MiB |      0%      Default |
    +-------------------------------+----------------------+----------------------+
    
    +-----------------------------------------------------------------------------+
    | Processes:                                                       GPU Memory |
    |  GPU       PID   Type   Process name                             Usage      |
    |=============================================================================|
    |  No running processes found                                                 |
    +-----------------------------------------------------------------------------+
    

安装 cuda驱动

https://cloud.tencent.com/document/product/560/8064

1.下载驱动包

wget https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
chmod +x cuda_10.1.243_418.87.00_linux.run
sudo bash cuda_10.1.243_418.87.00_linux.run --toolkit --samples --silent
  1. 配置环境变量
echo '''export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}''' | sudo tee /etc/profile.d/cuda.sh
source /etc/profile
  1. 重启
  2. 验证安装结果
cd /usr/local/cuda-10.1/samples/1_Utilities/deviceQuery

# 报错g++ not found 则按需安装g++
sudo make
./deviceQuery

返回Result=PASS 则表示安装成功

安装 anaconda

  1. 下载安装脚本

    https://www.anaconda.com/products/individual

    wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
    
  2. 执行安装

bash Anaconda3-2020.11-Linux-x86_64.sh 

安装后重登陆加载环境变量

  1. 更新国内源

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    
    conda config --set show_channel_urls yes
    

Paddle部署

https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/2.0/install/conda/linux-conda.html

创建虚拟环境

conda create -n paddle_env python=3.7
conda activate paddle_env

安装 paddle

conda install paddlepaddle-gpu==2.0.0 cudatoolkit=10.1 --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/Paddle/

其他依赖库安装

# paddlehub不支持conda安装
# https://github.com/PaddlePaddle/PaddleHub/issues/499
pip install paddlehub
conda install shapely
conda install pyclipper

验证安装

$ python
>>> import paddle
>>> paddle.utils.run_check()

输出installed successfully则表示安装成功

PaddlePaddle works well on 1 GPU.
PaddlePaddle works well on 1 GPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
Built with Hugo
Theme Stack designed by Jimmy