README.md 8.1 KB
Newer Older
1 2
# OneFlow

S
strint 已提交
3
**OneFlow is a performance-centered and open-source deep learning framework.**
S
strint 已提交
4

5
[![Simple CI](https://github.com/Oneflow-Inc/oneflow/actions/workflows/simple.yml/badge.svg)](https://github.com/Oneflow-Inc/oneflow/actions/workflows/simple.yml)
6
[![Documentation Status](https://readthedocs.org/projects/oneflow/badge/?version=master)](https://oneflow.readthedocs.io/en/master/?badge=master)
S
Shenghang Tsai 已提交
7

8
## Latest News
S
Shenghang Tsai 已提交
9

10
- Version 0.5rc2 is out!
S
Shenghang Tsai 已提交
11 12
  - First class support for eager execution. The deprecated APIs are moved to `oneflow.compatible.single_client`
  - Drop-in replacement of `import torch` for existing Pytorch projects. You could test it by inter-changing `import oneflow as torch` and `import torch as flow`.
13
  - [Full changelog](https://github.com/Oneflow-Inc/oneflow/releases/tag/v0.5rc2)
14

S
strint 已提交
15 16
## Install OneFlow

S
Shenghang Tsai 已提交
17
### System Requirements
18

S
Shenghang Tsai 已提交
19 20
- Python 3.6, 3.7, 3.8 (3.9 is available in nightly version)
- (**Highly recommended**) Upgrade pip
21

S
Shenghang Tsai 已提交
22 23 24
  ```
  python3 -m pip install --upgrade pip #--user
  ```
25

S
Shenghang Tsai 已提交
26
- CUDA Toolkit Linux x86_64 Driver
S
Shenghang Tsai 已提交
27

S
Shenghang Tsai 已提交
28
  - CUDA runtime is statically linked into OneFlow. OneFlow will work on a minimum supported driver, and any driver beyond. For more information, please refer to [CUDA compatibility documentation](https://docs.nvidia.com/deploy/cuda-compatibility/index.html).
S
Shenghang Tsai 已提交
29

S
Shenghang Tsai 已提交
30
  - Please upgrade your Nvidia driver to version 440.33 or above and install OneFlow for CUDA 10.2 if possible.
S
Shenghang Tsai 已提交
31

S
Shenghang Tsai 已提交
32
### Install with Pip Package
33

S
Shenghang Tsai 已提交
34
- To install latest stable release of OneFlow with CUDA support:
35

S
Shenghang Tsai 已提交
36
  ```bash
37
  python3 -m pip install -f https://release.oneflow.info oneflow==0.5rc2+cu102
S
Shenghang Tsai 已提交
38 39 40
  ```

- To install nightly release of OneFlow with CUDA support:
41

S
Shenghang Tsai 已提交
42 43 44 45 46 47 48
  ```bash
  python3 -m pip install oneflow -f https://staging.oneflow.info/branch/master/cu102
  ```

- To install other available builds for different variants:

  - Stable
S
Shenghang Tsai 已提交
49
    ```bash
50
    python3 -m pip install --find-links https://release.oneflow.info oneflow==0.5rc2+[PLATFORM]
S
Shenghang Tsai 已提交
51
    ```
S
Shenghang Tsai 已提交
52
  - Nightly
S
Shenghang Tsai 已提交
53
    ```
S
Shenghang Tsai 已提交
54
    python3 -m pip install oneflow -f https://staging.oneflow.info/branch/master/[PLATFORM]
S
Shenghang Tsai 已提交
55
    ```
S
Shenghang Tsai 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  - All available `[PLATFORM]`:
    | Platform |CUDA Driver Version| Supported GPUs |
    |---|---|---|
    | cu112 | >= 450.80.02 | GTX 10xx, RTX 20xx, A100, RTX 30xx |
    | cu111 | >= 450.80.02 | GTX 10xx, RTX 20xx, A100, RTX 30xx |
    | cu110, cu110_xla | >= 450.36.06 | GTX 10xx, RTX 20xx, A100|
    | cu102, cu102_xla | >= 440.33 | GTX 10xx, RTX 20xx |
    | cu101, cu101_xla | >= 418.39 | GTX 10xx, RTX 20xx |
    | cu100, cu100_xla | >= 410.48 | GTX 10xx, RTX 20xx |
    | cpu | N/A | N/A |

- If you are in China, you could run this to have pip download packages from domestic mirror of pypi:
  ```
  python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
  ```
  For more information on this, please refer to [pypi 镜像使用帮助](https://mirror.tuna.tsinghua.edu.cn/help/pypi/)
S
Shenghang Tsai 已提交
72

73 74 75 76 77 78 79
### Use docker image

```
docker pull oneflowinc/oneflow:nightly-cuda10.2
docker pull oneflowinc/oneflow:nightly-cuda11.1
```

S
strint 已提交
80
### Build from Source
S
Shenghang Tsai 已提交
81

S
Shenghang Tsai 已提交
82 83
<details>
<summary>Clone Source Code</summary>
84

S
Shenghang Tsai 已提交
85
- #### Option 1: Clone source code from GitHub
H
Houjiang Chen 已提交
86

S
Shenghang Tsai 已提交
87 88 89
  ```bash
  git clone https://github.com/Oneflow-Inc/oneflow --depth=1
  ```
S
Shenghang Tsai 已提交
90

S
Shenghang Tsai 已提交
91
- #### Option 2: Download from Aliyun
S
Shenghang Tsai 已提交
92

S
Shenghang Tsai 已提交
93
  If you are in China, please download OneFlow source code from: https://oneflow-public.oss-cn-beijing.aliyuncs.com/oneflow-src.zip
94

S
Shenghang Tsai 已提交
95 96 97 98
  ```bash
  curl https://oneflow-public.oss-cn-beijing.aliyuncs.com/oneflow-src.zip -o oneflow-src.zip
  unzip oneflow-src.zip
  ```
S
Shenghang Tsai 已提交
99 100

  </details>
H
Houjiang Chen 已提交
101

S
Shenghang Tsai 已提交
102
<details>
103
<summary>Build OneFlow</summary>
H
Houjiang Chen 已提交
104

105
- #### Option 1: Build with Conda (recommended)
S
Shenghang Tsai 已提交
106

107 108 109
  Please refer to [this repo](https://github.com/Oneflow-Inc/conda-env)

- #### Option 2: Build in docker container (recommended)
S
Shenghang Tsai 已提交
110

111 112 113 114 115 116 117 118
  - Pull a docker image:

    ```
    docker pull oneflowinc/oneflow-manylinux2014-cuda10.2:0.1
    ```

    All images available : https://hub.docker.com/u/oneflowinc

S
Shenghang Tsai 已提交
119
  - In the root directory of OneFlow source code, run:
120

S
Shenghang Tsai 已提交
121
    ```
122
    python3 docker/package/manylinux/build_wheel.py --python_version=3.6
S
Shenghang Tsai 已提交
123
    ```
124

S
Shenghang Tsai 已提交
125
    This should produce `.whl` files in the directory `wheelhouse`
126

S
Shenghang Tsai 已提交
127
  - If you are in China, you might need to add these flags:
128

S
Shenghang Tsai 已提交
129 130 131
    ```
    --use_tuna --use_system_proxy --use_aliyun_mirror
    ```
132

S
Shenghang Tsai 已提交
133
  - You can choose CUDA/Python versions of wheel by adding:
134

S
Shenghang Tsai 已提交
135 136 137
    ```
    --cuda_version=10.1 --python_version=3.6,3.7
    ```
138

S
Shenghang Tsai 已提交
139
  - For more useful flags, plese run the script with flag `--help` or refer to the source code of the script.
140

141
- #### Option 3: Build on bare metal
S
Shenghang Tsai 已提交
142

143 144 145
  - Install dependencies
    - on Ubuntu 20.04, run:
      ```
S
Shenghang Tsai 已提交
146
      sudo apt install -y libopenblas-dev nasm g++ gcc python3-pip cmake autoconf libtool
147 148 149 150 151
      ```
    - on macOS, run:
      ```
      brew install nasm
      ```
S
Shenghang Tsai 已提交
152
  - In the root directory of OneFlow source code, run:
153

S
Shenghang Tsai 已提交
154 155 156
    ```
    mkdir build
    cd build
157 158 159
    ```

  - Config the project, inside `build` directory:
S
Shenghang Tsai 已提交
160

161 162 163
    - If you are in China

      run this to config for CUDA:
S
Shenghang Tsai 已提交
164

165 166 167 168 169
      ```
      cmake .. -C ../cmake/caches/cn/cuda.cmake
      ```

      run this to config for CPU-only:
S
Shenghang Tsai 已提交
170

171 172 173 174 175 176 177
      ```
      cmake .. -C ../cmake/caches/cn/cpu.cmake
      ```

    - If you are not in China

      run this to config for CUDA:
S
Shenghang Tsai 已提交
178

179 180 181 182 183
      ```
      cmake .. -C ../cmake/caches/international/cuda.cmake
      ```

      run this to config for CPU-only:
S
Shenghang Tsai 已提交
184

185 186 187 188 189
      ```
      cmake .. -C ../cmake/caches/international/cpu.cmake
      ```

  - Build the project, inside `build` directory, run:
S
Shenghang Tsai 已提交
190

191
    ```
S
Shenghang Tsai 已提交
192
    make -j$(nproc)
193 194
    ```

195
  - Add oneflow to your PYTHONPATH, inside `build` directory, run:
196 197

    ```
198
    source source.sh
199 200 201 202 203 204
    ```

    Please note that this change is not permanent.

  - Simple validation

S
Shenghang Tsai 已提交
205 206 207 208 209
        ```
        python3 -m oneflow --doctor
        ```

    </details>
S
Shenghang Tsai 已提交
210

211
### Troubleshooting
H
Houjiang Chen 已提交
212

S
Shenghang Tsai 已提交
213
Please refer to [troubleshooting](docs/source/troubleshooting.md) for common issues you might encounter when compiling and running OneFlow.
H
Houjiang Chen 已提交
214

S
strint 已提交
215
### Advanced features
S
Shenghang Tsai 已提交
216

S
Shenghang Tsai 已提交
217 218
<details>
<summary>XRT</summary>
H
Houjiang Chen 已提交
219

S
Shenghang Tsai 已提交
220 221
- You can check this [doc](oneflow/xrt/README.md) to obtain more details about how to use XLA and TensorRT with OneFlow.
</details>
S
strint 已提交
222 223

## Getting Started
S
Shenghang Tsai 已提交
224

S
Shenghang Tsai 已提交
225 226 227 228
<details>
<summary>3 minutes to run MNIST.</summary>

- Clone the demo code from OneFlow documentation
229

S
Shenghang Tsai 已提交
230 231
  ```
  git clone https://github.com/Oneflow-Inc/oneflow-documentation.git
232
  cd oneflow-documentation/cn/docs/single_client/code/quick_start/
S
Shenghang Tsai 已提交
233
  ```
234

S
Shenghang Tsai 已提交
235
- Run it in Python
S
Shenghang Tsai 已提交
236

S
Shenghang Tsai 已提交
237 238 239 240 241 242 243 244 245 246 247 248 249
  ```
  python mlp_mnist.py
  ```

- Oneflow is running and you got the training loss
  ```
  2.7290366
  0.81281316
  0.50629824
  0.35949975
  0.35245502
  ...
  ```
250
- More info on this demo, please refer to [doc on quick start](https://docs.oneflow.org/master/single_client/quick_start/quickstart_in_3_min.html).
S
Shenghang Tsai 已提交
251
</details>
S
strint 已提交
252 253

## Documentation
S
Shenghang Tsai 已提交
254

S
Shenghang Tsai 已提交
255 256
- [API Reference](https://oneflow.readthedocs.io/en/master/)
- [Usage & Design Docs](http://docs.oneflow.org/)
S
Shenghang Tsai 已提交
257
- [System Design](https://docs.oneflow.org/en/v0.4.0/basics_topics/essentials_of_oneflow.html)
S
strint 已提交
258 259

## Model Zoo and Benchmark
S
Shenghang Tsai 已提交
260 261

- [OneFlow Models](https://github.com/Oneflow-Inc/models)
S
Shenghang Tsai 已提交
262 263
- [OneFlow-Benchmark](https://github.com/Oneflow-Inc/OneFlow-Benchmark)
- [GPT](https://github.com/Oneflow-Inc/OneFlow-Benchmark/tree/master/LanguageModeling/GPT)
S
Shenghang Tsai 已提交
264 265 266
- [ResNet-50](https://github.com/Oneflow-Inc/models/tree/main/Vision/classification/image/resnet50)
- [Wide&Deep](https://github.com/Oneflow-Inc/models/tree/main/RecommenderSystems/wide_and_deep)
- [BERT](https://github.com/Oneflow-Inc/models/tree/main/NLP/bert-oneflow)
S
strint 已提交
267 268

## Communication
S
Shenghang Tsai 已提交
269

270 271 272 273
- [GitHub issues](https://github.com/Oneflow-Inc/oneflow/issues): any install, bug, feature issues.
- [www.oneflow.org](http://www.oneflow.org): brand related information.

- ### 中文
S
Shenghang Tsai 已提交
274

275 276 277 278 279 280 281 282 283
  - QQ 群: 331883
  - 微信号(加好友入交流群): OneFlowXZS
  - [知乎](https://www.zhihu.com/org/oneflow-17)

- ### International
  - [Discord](https://discord.gg/4kpjGA5bZY)
  - [Twitter](https://twitter.com/OneFlowNews)
  - [LinkedIn](https://www.linkedin.com/company/oneflow-inc)
  - [Medium](https://oneflow2020.medium.com)
S
strint 已提交
284 285

## The Team
S
Shenghang Tsai 已提交
286

S
strint 已提交
287 288 289
OneFlow was originally developed by [OneFlow Inc](http://www.oneflow.org) and [Zhejiang Lab](http://www.zhejianglab.com/).

## License
S
Shenghang Tsai 已提交
290

S
strint 已提交
291
[Apache License 2.0](LICENSE)