README.md 8.4 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 7 8
[![Nightly Docker Image](https://github.com/Oneflow-Inc/docker-images/actions/workflows/oneflow-nightly.yml/badge.svg)](https://github.com/Oneflow-Inc/docker-images/actions/workflows/oneflow-nightly.yml)
[![Nightly Release](https://github.com/Oneflow-Inc/oneflow/actions/workflows/release.yml/badge.svg)](https://github.com/Oneflow-Inc/oneflow/actions/workflows/release.yml)
[![Documentation](https://readthedocs.org/projects/oneflow/badge/?version=master)](https://oneflow.readthedocs.io/en/master/?badge=master)
S
Shenghang Tsai 已提交
9

10
## Latest News
S
Shenghang Tsai 已提交
11

S
Shenghang Tsai 已提交
12
- Version 0.5.0 is out!
S
Shenghang Tsai 已提交
13 14
  - 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`.
S
Shenghang Tsai 已提交
15
  - [Full changelog](https://github.com/Oneflow-Inc/oneflow/releases/tag/v0.5.0)
16

S
strint 已提交
17 18
## Install OneFlow

S
Shenghang Tsai 已提交
19
### System Requirements
20

S
Shenghang Tsai 已提交
21
- Python 3.6, 3.7, 3.8, 3.9
S
Shenghang Tsai 已提交
22
- (**Highly recommended**) Upgrade pip
23

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

S
Shenghang Tsai 已提交
28
- CUDA Toolkit Linux x86_64 Driver
S
Shenghang Tsai 已提交
29

S
Shenghang Tsai 已提交
30
  - 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 已提交
31

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

S
Shenghang Tsai 已提交
34
### Install with Pip Package
35

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

S
Shenghang Tsai 已提交
38
  ```bash
S
Shenghang Tsai 已提交
39
  python3 -m pip install -f https://release.oneflow.info oneflow==0.5.0+cu102
S
Shenghang Tsai 已提交
40 41 42
  ```

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

S
Shenghang Tsai 已提交
44 45 46 47 48 49 50
  ```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 已提交
51
    ```bash
S
Shenghang Tsai 已提交
52
    python3 -m pip install --find-links https://release.oneflow.info oneflow==0.5.0+[PLATFORM]
S
Shenghang Tsai 已提交
53
    ```
S
Shenghang Tsai 已提交
54
  - Nightly
S
Shenghang Tsai 已提交
55
    ```
S
Shenghang Tsai 已提交
56
    python3 -m pip install oneflow -f https://staging.oneflow.info/branch/master/[PLATFORM]
S
Shenghang Tsai 已提交
57
    ```
S
Shenghang Tsai 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
  - 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 已提交
74

75 76 77 78 79 80 81
### Use docker image

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

S
strint 已提交
82
### Build from Source
S
Shenghang Tsai 已提交
83

S
Shenghang Tsai 已提交
84 85
<details>
<summary>Clone Source Code</summary>
86

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

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

S
Shenghang Tsai 已提交
93
- #### Option 2: Download from Aliyun
S
Shenghang Tsai 已提交
94

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

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

  </details>
H
Houjiang Chen 已提交
103

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

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

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

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

113 114 115 116 117 118 119 120
  - 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 已提交
121
  - In the root directory of OneFlow source code, run:
122

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

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

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

S
Shenghang Tsai 已提交
131 132 133
    ```
    --use_tuna --use_system_proxy --use_aliyun_mirror
    ```
134

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

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

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

143
- #### Option 3: Build on bare metal
S
Shenghang Tsai 已提交
144

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

S
Shenghang Tsai 已提交
156 157 158
    ```
    mkdir build
    cd build
159 160 161
    ```

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

163 164 165
    - If you are in China

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

167 168 169 170 171
      ```
      cmake .. -C ../cmake/caches/cn/cuda.cmake
      ```

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

173 174 175 176 177 178 179
      ```
      cmake .. -C ../cmake/caches/cn/cpu.cmake
      ```

    - If you are not in China

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

181 182 183 184 185
      ```
      cmake .. -C ../cmake/caches/international/cuda.cmake
      ```

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

187 188 189 190 191
      ```
      cmake .. -C ../cmake/caches/international/cpu.cmake
      ```

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

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

197
  - Add oneflow to your PYTHONPATH, inside `build` directory, run:
198 199

    ```
200
    source source.sh
201 202 203 204 205 206
    ```

    Please note that this change is not permanent.

  - Simple validation

Y
Yu OuYang 已提交
207 208 209
    ```
    python3 -m oneflow --doctor
    ```
S
Shenghang Tsai 已提交
210 211

    </details>
S
Shenghang Tsai 已提交
212

213
### Troubleshooting
H
Houjiang Chen 已提交
214

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

S
strint 已提交
217
### Advanced features
S
Shenghang Tsai 已提交
218

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

S
Shenghang Tsai 已提交
222 223
- 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 已提交
224 225

## Getting Started
S
Shenghang Tsai 已提交
226

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

- Clone the demo code from OneFlow documentation
231

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

S
Shenghang Tsai 已提交
237
- Run it in Python
S
Shenghang Tsai 已提交
238

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

- Oneflow is running and you got the training loss
  ```
  2.7290366
  0.81281316
  0.50629824
  0.35949975
  0.35245502
  ...
  ```
252
- 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 已提交
253
</details>
S
strint 已提交
254 255

## Documentation
S
Shenghang Tsai 已提交
256

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

## Model Zoo and Benchmark
S
Shenghang Tsai 已提交
262 263

- [OneFlow Models](https://github.com/Oneflow-Inc/models)
S
Shenghang Tsai 已提交
264 265
- [OneFlow-Benchmark](https://github.com/Oneflow-Inc/OneFlow-Benchmark)
- [GPT](https://github.com/Oneflow-Inc/OneFlow-Benchmark/tree/master/LanguageModeling/GPT)
S
Shenghang Tsai 已提交
266 267 268
- [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 已提交
269 270

## Communication
S
Shenghang Tsai 已提交
271

272 273 274 275
- [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 已提交
276

277 278 279 280 281 282 283 284 285
  - 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 已提交
286 287

## The Team
S
Shenghang Tsai 已提交
288

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

## License
S
Shenghang Tsai 已提交
292

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