diff --git a/docs/en/tutorials/install_en.md b/docs/en/tutorials/install_en.md index 0d3c831a4c986526e559d3c9764a7cb6b8284068..7fd68a1eabb06b65787585cb0a6d49ef47409f49 100644 --- a/docs/en/tutorials/install_en.md +++ b/docs/en/tutorials/install_en.md @@ -1,17 +1,50 @@ # Installation --- +This tutorial introduces how to install PaddleClas and its requirements. -## Introduction +## 1. Install PaddlePaddle -This document introduces how to install PaddleClas and its requirements. +`PaddlePaddle 2.0` or later is required for PaddleClas. You can use the following steps to install PaddlePaddle. -## Install PaddlePaddle +### 1.1 Environment requirements -Python 3.x, CUDA 10.0, CUDNN7.6.4 nccl2.1.2 and later version are required at first, For now, PaddleClas only support training on the GPU device. Please follow the instructions in the [Installation](http://www.paddlepaddle.org.cn/install/quick) if the PaddlePaddle on the device is lower than 2.0.0. +- python 3.x +- cuda >= 10.1 (necessary if you want to use paddlepaddle-gpu) +- cudnn >= 7.6.4 (necessary if you want to use paddlepaddle-gpu) +- nccl >= 2.1.2 (necessary if you want the use distributed training/eval) +- gcc >= 8.2 +Docker is recomended to run Paddleclas, for more detailed information about docker and nvidia-docker, you can refer to the [tutorial](https://www.runoob.com/docker/docker-tutorial.html). -### Install PaddlePaddle using pip +When you use cuda10.1, the driver version needs to be larger or equal than 418.39. When you use cuda10.2, the driver version needs to be larger or equal than 440.33. For more cuda versions and specific driver versions, you can refer to the [link](https://docs.nvidia.com/deploy/cuda-compatibility/index.html). + +If you do not want to use docker, you can skip section 1.2 and go into section 1.3 directly. + + +### 1.2 (Recommended) Prepare a docker environment. The first time you use this docker image, it will be downloaded automatically. Please be patient. + + +``` +# Switch to the working directory +cd /home/Projects +# You need to create a docker container for the first run, and do not need to run the current command when you run it again +# Create a docker container named ppcls and map the current directory to the /paddle directory of the container +# It is recommended to set a shared memory greater than or equal to 8G through the --shm-size parameter +sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it docker pull paddlepaddle/paddle:2.1.0 /bin/bash + +# Use the following command to create a container if you want to use GPU in the container +sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it docker pull paddlepaddle/paddle:2.1.0-gpu-cuda10.2-cudnn7 /bin/bash +``` + +You can also visit [DockerHub](https://hub.docker.com/r/paddlepaddle/paddle/tags/) to get more docker images. + +``` +# use ctrl+P+Q to exit docker, to re-enter docker using the following command: +sudo docker container exec -it ppcls /bin/bash +``` + +### 1.3 Install PaddlePaddle using pip If you want to use PaddlePaddle on GPU, you can use the following command to install PaddlePaddle. @@ -25,11 +58,11 @@ If you want to use PaddlePaddle on CPU, you can use the following command to ins pip3 install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple ``` -### Install PaddlePaddle from source code - -You can also compile PaddlePaddle from source code, please refer to [Installation](http://www.paddlepaddle.org.cn/install/quick). +**Note:** +* If you have already installed CPU version of PaddlePaddle and want to use GPU version now, you should uninstall CPU version of PaddlePaddle and then install GPU version to avoid package confusion. +* You can also compile PaddlePaddle from source code, please refer to [PaddlePaddle Installation tutorial](http://www.paddlepaddle.org.cn/install/quick) to more compilation options. -Verify Installation +### 1.4 Verify Installation process ```python import paddle @@ -43,14 +76,15 @@ python3 -c "import paddle; print(paddle.__version__)" ``` Note: -- Make sure the compiled version is later than PaddlePaddle2.0. +- Make sure the compiled source code is later than PaddlePaddle2.0. - Indicate **WITH_DISTRIBUTE=ON** when compiling, Please refer to [Instruction](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#id3) for more details. -- When running in docker, in order to ensure that the container has enough shared memory for data read acceleration of Paddle, please set the parameter `--shm_size=8g` at creating a docker container, if conditions permit, you can set it to a larger value. +- When running in docker, in order to ensure that the container has enough shared memory for dataloader acceleration of Paddle, please set the parameter `--shm_size=8g` at creating a docker container, if conditions permit, you can set it to a larger value. -## Install PaddleClas -**Clone PaddleClas: ** +## 2. Install PaddleClas + +### 2.1 Clone PaddleClas source code ``` git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop @@ -62,16 +96,10 @@ If it is too slow for you to download from github, you can download PaddleClas f git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop ``` -**Install requirements** - -``` -pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple -``` +### 2.2 Install requirements -If the install process of visualdl failed, you can try the following commands. +PaddleClas dependencies are listed in file `requirements.txt`, you can use the following command to install the dependencies. ``` -pip3 install --upgrade visualdl -i https://mirror.baidu.com/pypi/simple +pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple ``` - -What's more, visualdl is just supported in python3, so python3 is needed if you want to use visualdl. diff --git a/docs/zh_CN/tutorials/install.md b/docs/zh_CN/tutorials/install.md index ad0ff86fdab439b6995f4e57bb7a9b7182eae443..f7ed8026d7e256eaaa36013f61a5f2a4a20049f1 100644 --- a/docs/zh_CN/tutorials/install.md +++ b/docs/zh_CN/tutorials/install.md @@ -1,19 +1,55 @@ # 安装说明 --- +本章将介绍如何安装PaddleClas及其依赖项。 -## 一、简介 -本章将介绍如何安装PaddleClas及其依赖项。 +## 1. 安装PaddlePaddle + +运行PaddleClas需要`PaddlePaddle 2.0`或更高版本。可以参考下面的步骤安装PaddlePaddle。 + +### 1.1 环境要求 + +- python 3.x +- cuda >= 10.1 (如果使用paddlepaddle-gpu) +- cudnn >= 7.6.4 (如果使用paddlepaddle-gpu) +- nccl >= 2.1.2 (如果使用分布式训练/评估) +- gcc >= 8.2 + +建议使用我们提供的docker运行PaddleClas,有关docker、nvidia-docker使用请参考[链接](https://www.runoob.com/docker/docker-tutorial.html)。 + +在cuda10.1时,建议显卡驱动版本大于等于418.39;在使用cuda10.2时,建议显卡驱动版本大于440.33,更多cuda版本与要求的显卡驱动版本可以参考[链接](https://docs.nvidia.com/deploy/cuda-compatibility/index.html)。 -## 二、安装PaddlePaddle +如果不使用docker,可以直接跳过1.2部分内容,从1.3部分开始执行。 -运行PaddleClas需要`PaddlePaddle 2.0`或更高版本。请参照[安装文档](http://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 -### 通过pip安装PaddlePaddle +### 1.2 (建议)准备docker环境。第一次使用这个镜像,会自动下载该镜像,请耐心等待。 -如果已经安装好了cuda、cudnn、nccl或者安装好了docker、nvidia-docker运行环境,可以pip安装最新GPU版本PaddlePaddle +``` +# 切换到工作目录下 +cd /home/Projects +# 首次运行需创建一个docker容器,再次运行时不需要运行当前命令 +# 创建一个名字为ppcls的docker容器,并将当前目录映射到容器的/paddle目录下 + +如果您希望在CPU环境下使用docker,使用docker而不是nvidia-docker创建docker,设置docker容器共享内存shm-size为8G,建议设置8G以上 +sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it docker pull paddlepaddle/paddle:2.1.0 /bin/bash + +如果希望使用GPU版本的容器,请运行以下命令创建容器。 +sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it docker pull paddlepaddle/paddle:2.1.0-gpu-cuda10.2-cudnn7 /bin/bash +``` + + +您也可以访问[DockerHub](https://hub.docker.com/r/paddlepaddle/paddle/tags/)获取与您机器适配的镜像。 + +``` +# ctrl+P+Q可退出docker 容器,重新进入docker 容器使用如下命令 +sudo docker container exec -it ppcls /bin/bash +``` + +### 1.3 通过pip安装PaddlePaddle + +运行下面的命令,通过pip安装最新GPU版本PaddlePaddle ```bash pip3 install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple @@ -25,10 +61,12 @@ pip3 install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple pip3 install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple ``` -### 源码编译PaddlePaddle +**注意:** +* 如果先安装了CPU版本的paddlepaddle,之后想切换到GPU版本,那么需要首先卸载CPU版本的paddle,再安装GPU版本的paddle,否则容易导致使用的paddle版本混乱。 +* 您也可以从源码编译安装PaddlePaddle,请参照[PaddlePaddle 安装文档](http://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 -您也可以从源码编译安装PaddlePaddle,请参照[安装文档](http://www.paddlepaddle.org.cn/install/quick)中的说明进行操作。 +### 1.4 验证是否安装成功 使用以下命令可以验证PaddlePaddle是否安装成功。 @@ -47,18 +85,12 @@ python3 -c "import paddle; print(paddle.__version__)" - 从源码编译的PaddlePaddle版本号为0.0.0,请确保使用了PaddlePaddle 2.0及之后的源码编译。 - PaddleClas基于PaddlePaddle高性能的分布式训练能力,若您从源码编译,请确保打开编译选项,**WITH_DISTRIBUTE=ON**。具体编译选项参考[编译选项表](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/install/Tables.html#id3)。 - 在docker中运行时,为保证docker容器有足够的共享内存用于Paddle的数据读取加速,在创建docker容器时,请设置参数`--shm_size=8g`,条件允许的话可以设置为更大的值。 +- -**运行环境需求:** -- Python3 -- CUDA >= 9.0 -- cuDNN >= 7.6.4 -- nccl >= 2.1.2 +## 2. 安装PaddleClas - -## 三、安装PaddleClas - -**克隆PaddleClas模型库:** +### 2.1 克隆PaddleClas模型库 ```bash git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop @@ -70,20 +102,10 @@ git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop ``` - - -**安装Python依赖库:** +### 2.2 安装Python依赖库 Python依赖库在`requirements.txt`中给出,可通过如下命令安装: ```bash pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple ``` - -visualdl可能出现安装失败,请尝试 - -```bash -pip3 install --upgrade visualdl -i https://mirror.baidu.com/pypi/simple -``` - -此外,visualdl目前只支持在python3下运行,因此如果希望使用visualdl,需要使用python3。 diff --git a/tools/export_model.py b/tools/export_model.py index 53b3e54802bc3b4fb787f59d9fd9a239ed9f2346..6ce369011854eb1d19d4ca18e785ce3dbeef1196 100644 --- a/tools/export_model.py +++ b/tools/export_model.py @@ -24,6 +24,8 @@ import paddle import paddle.nn as nn from ppcls.utils import config +from ppcls.utils.logger import init_logger +from ppcls.utils.config import print_config from ppcls.arch import build_model, RecModel, DistillationModel from ppcls.utils.save_load import load_dygraph_pretrain from ppcls.arch.gears.identity_head import IdentityHead @@ -72,7 +74,14 @@ class ExportModel(nn.Layer): if __name__ == "__main__": args = config.parse_args() - config = config.get_config(args.config, overrides=args.override, show=True) + config = config.get_config( + args.config, overrides=args.override, show=False) + + log_file = os.path.join(config['Global']['output_dir'], + config["Arch"]["name"], "export.log") + init_logger(name='root', log_file=log_file) + print_config(config) + # set device assert config["Global"]["device"] in ["cpu", "gpu", "xpu"] device = paddle.set_device(config["Global"]["device"])