install_en.md 4.2 KB
Newer Older
1 2 3
# Installation

---
4
This tutorial introduces how to install PaddleClas and its requirements.
5

6
## 1. Install PaddlePaddle
7

8
`PaddlePaddle 2.0` or later is required for PaddleClas. You can use the following steps to install PaddlePaddle.
9

10
### 1.1 Environment requirements
11

12 13 14 15 16
- 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
17

18
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).
L
littletomatodonkey 已提交
19

20 21 22 23 24 25 26 27 28 29 30 31 32 33
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
L
littletomatodonkey 已提交
34
sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0 /bin/bash
35 36

# Use the following command to create a container if you want to use GPU in the container
L
littletomatodonkey 已提交
37
sudo nvidia-docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0-gpu-cuda10.2-cudnn7 /bin/bash
38 39 40 41 42 43 44 45 46 47
```

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
L
littletomatodonkey 已提交
48 49

If you want to use PaddlePaddle on GPU, you can use the following command to install PaddlePaddle.
50 51

```bash
52
pip3 install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple
53 54
```

L
littletomatodonkey 已提交
55 56 57
If you want to use PaddlePaddle on CPU, you can use the following command to install PaddlePaddle.

```bash
58
pip3 install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple
L
littletomatodonkey 已提交
59 60
```

61 62 63
**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.
64

65
### 1.4 Verify Installation process
66 67

```python
68 69
import paddle
paddle.utils.run_check()
70 71 72 73 74
```

Check PaddlePaddle version:

```bash
75
python3 -c "import paddle; print(paddle.__version__)"
76 77 78
```

Note:
79
- Make sure the compiled source code is later than PaddlePaddle2.0.
80
- 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.
81
- 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.
82 83 84



85 86 87
## 2. Install PaddleClas

### 2.1 Clone PaddleClas source code
88 89

```
90
git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop
91 92
```

93
If it is too slow for you to download from github, you can download PaddleClas from gitee. The command is as follows.
94

95
```bash
96
git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop
97 98
```

99
### 2.2 Install requirements
100

101
PaddleClas dependencies are listed in file `requirements.txt`, you can use the following command to install the dependencies.
102 103

```
104
pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple
105
```