PaddleClas/docs/en/tutorials/install_en.md

106 lines
4.2 KiB
Markdown
Raw Normal View History

2020-10-19 13:05:34 +08:00
# Installation
---
This tutorial introduces how to install PaddleClas and its requirements.
2020-10-19 13:05:34 +08:00
## 1. Install PaddlePaddle
2020-10-19 13:05:34 +08:00
2021-10-15 11:24:36 +08:00
`PaddlePaddle 2.1` or later is required for PaddleClas. You can use the following steps to install PaddlePaddle.
2020-10-19 13:05:34 +08:00
### 1.1 Environment requirements
2020-10-19 13:05:34 +08:00
- 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
2020-10-19 13:05:34 +08:00
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).
2021-01-05 20:01:18 +08:00
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
2021-06-18 15:51:58 +08:00
sudo docker run --name ppcls -v $PWD:/paddle --shm-size=8G --network=host -it paddlepaddle/paddle:2.1.0 /bin/bash
# Use the following command to create a container if you want to use GPU in the container
2021-06-18 15:51:58 +08:00
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
```
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:
2021-06-21 14:51:42 +08:00
sudo docker exec -it ppcls /bin/bash
```
### 1.3 Install PaddlePaddle using pip
2021-01-05 20:01:18 +08:00
If you want to use PaddlePaddle on GPU, you can use the following command to install PaddlePaddle.
2020-10-19 13:05:34 +08:00
```bash
2021-03-11 15:11:19 +08:00
pip3 install paddlepaddle-gpu --upgrade -i https://mirror.baidu.com/pypi/simple
2020-10-19 13:05:34 +08:00
```
2021-01-05 20:01:18 +08:00
If you want to use PaddlePaddle on CPU, you can use the following command to install PaddlePaddle.
```bash
2021-03-11 15:11:19 +08:00
pip3 install paddlepaddle --upgrade -i https://mirror.baidu.com/pypi/simple
2021-01-05 20:01:18 +08:00
```
**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.
2020-10-19 13:05:34 +08:00
### 1.4 Verify Installation process
2020-10-19 13:05:34 +08:00
```python
import paddle
paddle.utils.run_check()
2020-10-19 13:05:34 +08:00
```
Check PaddlePaddle version
```bash
2021-03-10 22:41:23 +08:00
python3 -c "import paddle; print(paddle.__version__)"
2020-10-19 13:05:34 +08:00
```
Note:
- Make sure the compiled source code is later than PaddlePaddle2.0.
2020-10-19 13:05:34 +08:00
- 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 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.
2020-10-19 13:05:34 +08:00
## 2. Install PaddleClas
### 2.1 Clone PaddleClas source code
2020-10-19 13:05:34 +08:00
```
2021-03-11 15:11:19 +08:00
git clone https://github.com/PaddlePaddle/PaddleClas.git -b develop
2020-10-19 13:05:34 +08:00
```
2021-03-10 22:41:23 +08:00
If it is too slow for you to download from github, you can download PaddleClas from gitee. The command is as follows.
2020-10-19 13:05:34 +08:00
2021-03-10 22:41:23 +08:00
```bash
2021-03-11 15:11:19 +08:00
git clone https://gitee.com/paddlepaddle/PaddleClas.git -b develop
2021-03-10 22:41:23 +08:00
```
### 2.2 Install requirements
2020-10-19 13:05:34 +08:00
PaddleClas dependencies are listed in file `requirements.txt`, you can use the following command to install the dependencies.
2020-10-19 13:05:34 +08:00
```
pip3 install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple
2020-10-19 13:05:34 +08:00
```