|
1 |
| -# Installation |
| 1 | +# 安装 |
2 | 2 |
|
3 |
| -- [Prerequisites](#prerequisites) |
4 |
| -- [Installation](#installation) |
5 |
| - - [Best Practices](#best-practices) |
6 |
| - - [Customize Installation](#customize-installation) |
7 |
| - - [CUDA versions](#cuda-versions) |
8 |
| - - [Install MMEngine without MIM](#install-mmengine-without-mim) |
9 |
| - - [Install MMCV without MIM](#install-mmcv-without-mim) |
10 |
| - - [Install on CPU-only platforms](#install-on-cpu-only-platforms) |
11 |
| - - [Install on Google Colab](#install-on-google-colab) |
12 |
| - - [Using MMPose with Docker](#using-mmpose-with-docker) |
13 |
| - - [Trouble shooting](#trouble-shooting) |
14 |
| - |
15 |
| -<!-- TOC --> |
16 |
| - |
17 |
| -## Prerequisites |
18 |
| - |
19 |
| -In this section we demonstrate how to prepare an environment with PyTorch. |
20 |
| - |
21 |
| -MMPose works on Linux, Windows and macOS. It requires Python 3.6+, CUDA 9.2+ and PyTorch 1.5+. |
22 |
| - |
23 |
| -If you are experienced with PyTorch and have already installed it, just skip this part and jump to the [next section](#installation). Otherwise, you can follow these steps for the preparation. |
24 |
| - |
25 |
| -**Step 0.** Download and install Miniconda from the [official website](https://docs.conda.io/en/latest/miniconda.html). |
26 |
| - |
27 |
| -**Step 1.** Create a conda environment and activate it. |
28 |
| - |
29 |
| -```shell |
30 |
| -conda create --name openmmlab python=3.8 -y |
31 |
| -conda activate openmmlab |
32 |
| -``` |
33 |
| - |
34 |
| -**Step 2.** Install PyTorch following [official instructions](https://pytorch.org/get-started/locally/), e.g. |
35 |
| - |
36 |
| -On GPU platforms: |
37 |
| - |
38 |
| -```shell |
39 |
| -conda install pytorch torchvision -c pytorch |
40 |
| -``` |
41 |
| - |
42 |
| -```{warning} |
43 |
| -This command will automatically install the latest version PyTorch and cudatoolkit, please check whether they match your environment. |
44 |
| -``` |
45 |
| - |
46 |
| -On CPU platforms: |
47 |
| - |
48 |
| -```shell |
49 |
| -conda install pytorch torchvision cpuonly -c pytorch |
50 |
| -``` |
51 |
| - |
52 |
| -## Install MMPose |
53 |
| - |
54 |
| -We recommend that users follow our best practices to install MMPose. However, the whole process is highly customizable. See [Customize Installation](#customize-installation) section for more information. |
55 |
| - |
56 |
| -### Best Practices |
57 |
| - |
58 |
| -**Step 0.** Install [MMEngine](https://github.com/open-mmlab/mmengine) and [MMCV](https://github.com/open-mmlab/mmcv) using [MIM](https://github.com/open-mmlab/mim). |
59 |
| - |
60 |
| -```shell |
61 |
| -pip install -U openmim |
62 |
| -mim install mmengine |
63 |
| -mim install mmcv>=2.0.0rc1 |
64 |
| -``` |
65 |
| - |
66 |
| -**Step 1.** Install MMPose. |
67 |
| - |
68 |
| -Case a: If you develop and run mmpose directly, install it from source: |
69 |
| - |
70 |
| -```shell |
71 |
| -git clone https://github.com/open-mmlab/mmpose.git -d dev-1.x |
72 |
| -# "-b dev-1.x" means checkout to the `dev-1.x` branch. |
73 |
| -cd mmpose |
74 |
| -pip install -r requirements.txt |
75 |
| -pip install -v -e . |
76 |
| -# "-v" means verbose, or more output |
77 |
| -# "-e" means installing a project in editable mode, |
78 |
| -# thus any local modifications made to the code will take effect without reinstallation. |
79 |
| -``` |
80 |
| - |
81 |
| -Case b: If you use mmpose as a dependency or third-party package, install it with pip: |
82 |
| - |
83 |
| -```shell |
84 |
| -mim install mmpose>=1.0.0rc0 |
85 |
| -``` |
86 |
| - |
87 |
| -### Customize Installation |
88 |
| - |
89 |
| -#### CUDA versions |
90 |
| - |
91 |
| -When installing PyTorch, you need to specify the version of CUDA. If you are not clear on which to choose, follow our recommendations: |
92 |
| - |
93 |
| -- For Ampere-based NVIDIA GPUs, such as GeForce 30 series and NVIDIA A100, CUDA 11 is a must. |
94 |
| -- For older NVIDIA GPUs, CUDA 11 is backward compatible, but CUDA 10.2 offers better compatibility and is more lightweight. |
95 |
| - |
96 |
| -Please make sure the GPU driver satisfies the minimum version requirements. See [this table](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions) for more information. |
97 |
| - |
98 |
| -Installing CUDA runtime libraries is enough if you follow our best practices, because no CUDA code will be compiled locally. However if you hope to compile MMCV from source or develop other CUDA operators, you need to install the complete CUDA toolkit from NVIDIA's [website](https://developer.nvidia.com/cuda-downloads), and its version should match the CUDA version of PyTorch. i.e., the specified version of cudatoolkit in `conda install` command. |
99 |
| - |
100 |
| -#### Install MMEngine without MIM |
101 |
| - |
102 |
| -To install MMEngine with pip instead of MIM, please follow [MMEngine installation guides](https://mmengine.readthedocs.io/zh_CN/latest/get_started/installation.html). |
103 |
| - |
104 |
| -For example, you can install MMEngine by the following command. |
105 |
| - |
106 |
| -```shell |
107 |
| -pip install mmengine |
108 |
| -``` |
109 |
| - |
110 |
| -#### Install MMCV without MIM |
111 |
| - |
112 |
| -MMCV contains C++ and CUDA extensions, thus depending on PyTorch in a complex way. MIM solves such dependencies automatically and makes the installation easier. However, it is not a must. |
113 |
| - |
114 |
| -To install MMCV with pip instead of MIM, please follow [MMCV installation guides](https://mmcv.readthedocs.io/en/latest/get_started/installation.html). This requires manually specifying a find-url based on PyTorch version and its CUDA version. |
115 |
| - |
116 |
| -For example, the following command install mmcv-full built for PyTorch 1.10.x and CUDA 11.3. |
117 |
| - |
118 |
| -```shell |
119 |
| -pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10/index.html |
120 |
| -``` |
121 |
| - |
122 |
| -#### Install on CPU-only platforms |
123 |
| - |
124 |
| -MMPose can be built for CPU only environment. In CPU mode you can train (requires MMCV version >= 1.4.4), test or inference a model. |
125 |
| - |
126 |
| -However, some functionalities are missing in this mode, usually GPU-compiled ops like `Deformable Convolution`. Most models in MMPose don't depend on these ops, but if you try to train/test/infer a model containing these ops, an error will be raised. |
127 |
| - |
128 |
| -#### Install on Google Colab |
129 |
| - |
130 |
| -[Google Colab](https://colab.research.google.com/) usually has PyTorch installed, |
131 |
| -thus we only need to install MMEngine, MMCV and MMPose with the following commands. |
132 |
| - |
133 |
| -**Step 1.** Install [MMEngine](https://github.com/open-mmlab/mmengine) and [MMCV](https://github.com/open-mmlab/mmcv) using [MIM](https://github.com/open-mmlab/mim). |
134 |
| - |
135 |
| -```shell |
136 |
| -!pip3 install openmim |
137 |
| -!mim install mmengine |
138 |
| -!mim install mmcv>=2.0.0rc1 |
139 |
| -``` |
140 |
| - |
141 |
| -**Step 2.** Install MMPose from the source. |
142 |
| - |
143 |
| -```shell |
144 |
| -!git clone https://github.com/open-mmlab/mmpose.git -b dev-1.x |
145 |
| -%cd mmpose |
146 |
| -!pip install -e . |
147 |
| -``` |
148 |
| - |
149 |
| -**Step 3.** Verification. |
150 |
| - |
151 |
| -```python |
152 |
| -import mmpose |
153 |
| -print(mmpose.__version__) |
154 |
| -# Example output: 1.0.0 |
155 |
| -``` |
156 |
| - |
157 |
| -```{note} |
158 |
| -Note that within Jupyter, the exclamation mark `!` is used to call external executables and `%cd` is a [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd) to change the current working directory of Python. |
159 |
| -``` |
160 |
| - |
161 |
| -#### Using MMPose with Docker |
162 |
| - |
163 |
| -We provide a [Dockerfile](https://github.com/open-mmlab/mmpose/blob/master/docker/Dockerfile) to build an image. Ensure that your [docker version](https://docs.docker.com/engine/install/) >=19.03. |
164 |
| - |
165 |
| -```shell |
166 |
| -# build an image with PyTorch 1.6.0, CUDA 10.1, CUDNN 7. |
167 |
| -# If you prefer other versions, just modified the Dockerfile |
168 |
| -docker build -t mmpose docker/ |
169 |
| -``` |
170 |
| - |
171 |
| -**Important:** Make sure you've installed the [nvidia-container-toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker). |
172 |
| - |
173 |
| -Run it with |
174 |
| - |
175 |
| -```shell |
176 |
| -docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmpose/data mmpose |
177 |
| -``` |
178 |
| - |
179 |
| -`{DATA_DIR}` is your local folder containing all the datasets for mmpose. |
180 |
| - |
181 |
| -```{note} |
182 |
| -If you encounter the error message like `permission denied`, please add `sudo` at the start of the command and try it again. |
183 |
| -``` |
184 |
| - |
185 |
| -### Trouble shooting |
186 |
| - |
187 |
| -If you have some issues during the installation, please first view the [FAQ](./notes/faq.md) page. |
188 |
| -You may [open an issue](https://github.com/open-mmlab/mmpose/issues/new/choose) on GitHub if no solution is found. |
| 3 | +内容建设中 |
0 commit comments