README.md 7.9 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 11 12 13

- Version 0.5rc1 is out!
  - 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`.
  - [Full changelog](https://github.com/Oneflow-Inc/oneflow/releases/tag/v0.5rc1)
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 37 38 39 40
  ```bash
  python3 -m pip install -f https://release.oneflow.info oneflow==0.5rc1+cu102
  ```

- 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
S
Shenghang Tsai 已提交
50
    python3 -m pip install --find-links https://release.oneflow.info oneflow==0.5rc1+[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

S
strint 已提交
73
### Build from Source
S
Shenghang Tsai 已提交
74

S
Shenghang Tsai 已提交
75 76
<details>
<summary>Clone Source Code</summary>
77

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

S
Shenghang Tsai 已提交
80 81 82
  ```bash
  git clone https://github.com/Oneflow-Inc/oneflow --depth=1
  ```
S
Shenghang Tsai 已提交
83

S
Shenghang Tsai 已提交
84
- #### Option 2: Download from Aliyun
S
Shenghang Tsai 已提交
85

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

S
Shenghang Tsai 已提交
88 89 90 91
  ```bash
  curl https://oneflow-public.oss-cn-beijing.aliyuncs.com/oneflow-src.zip -o oneflow-src.zip
  unzip oneflow-src.zip
  ```
S
Shenghang Tsai 已提交
92 93

  </details>
H
Houjiang Chen 已提交
94

S
Shenghang Tsai 已提交
95
<details>
96
<summary>Build OneFlow</summary>
H
Houjiang Chen 已提交
97

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

100 101 102
  Please refer to [this repo](https://github.com/Oneflow-Inc/conda-env)

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

104 105 106 107 108 109 110 111
  - 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 已提交
112
  - In the root directory of OneFlow source code, run:
113

S
Shenghang Tsai 已提交
114
    ```
115
    python3 docker/package/manylinux/build_wheel.py --python_version=3.6
S
Shenghang Tsai 已提交
116
    ```
117

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

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

S
Shenghang Tsai 已提交
122 123 124
    ```
    --use_tuna --use_system_proxy --use_aliyun_mirror
    ```
125

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

S
Shenghang Tsai 已提交
128 129 130
    ```
    --cuda_version=10.1 --python_version=3.6,3.7
    ```
131

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

134
- #### Option 3: Build on bare metal
S
Shenghang Tsai 已提交
135

136 137 138
  - Install dependencies
    - on Ubuntu 20.04, run:
      ```
S
Shenghang Tsai 已提交
139
      sudo apt install -y libopenblas-dev nasm g++ gcc python3-pip cmake autoconf libtool
140 141 142 143 144
      ```
    - on macOS, run:
      ```
      brew install nasm
      ```
S
Shenghang Tsai 已提交
145
  - In the root directory of OneFlow source code, run:
146

S
Shenghang Tsai 已提交
147 148 149
    ```
    mkdir build
    cd build
150 151 152
    ```

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

154 155 156
    - If you are in China

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

158 159 160 161 162
      ```
      cmake .. -C ../cmake/caches/cn/cuda.cmake
      ```

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

164 165 166 167 168 169 170
      ```
      cmake .. -C ../cmake/caches/cn/cpu.cmake
      ```

    - If you are not in China

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

172 173 174 175 176
      ```
      cmake .. -C ../cmake/caches/international/cuda.cmake
      ```

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

178 179 180 181 182
      ```
      cmake .. -C ../cmake/caches/international/cpu.cmake
      ```

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

184
    ```
S
Shenghang Tsai 已提交
185
    make -j$(nproc)
186 187
    ```

188
  - Add oneflow to your PYTHONPATH, inside `build` directory, run:
189 190

    ```
191
    source source.sh
192 193 194 195 196 197
    ```

    Please note that this change is not permanent.

  - Simple validation

S
Shenghang Tsai 已提交
198 199 200 201 202
        ```
        python3 -m oneflow --doctor
        ```

    </details>
S
Shenghang Tsai 已提交
203

204
### Troubleshooting
H
Houjiang Chen 已提交
205

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

S
strint 已提交
208
### Advanced features
S
Shenghang Tsai 已提交
209

S
Shenghang Tsai 已提交
210 211
<details>
<summary>XRT</summary>
H
Houjiang Chen 已提交
212

S
Shenghang Tsai 已提交
213 214
- 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 已提交
215 216

## Getting Started
S
Shenghang Tsai 已提交
217

S
Shenghang Tsai 已提交
218 219 220 221 222 223
<details>
<summary>3 minutes to run MNIST.</summary>

- Clone the demo code from OneFlow documentation
  ```
  git clone https://github.com/Oneflow-Inc/oneflow-documentation.git
224
  cd oneflow-documentation/cn/docs/single_client/code/quick_start/
S
Shenghang Tsai 已提交
225
  ```
226

S
Shenghang Tsai 已提交
227
- Run it in Python
S
Shenghang Tsai 已提交
228

S
Shenghang Tsai 已提交
229 230 231 232 233 234 235 236 237 238 239 240 241
  ```
  python mlp_mnist.py
  ```

- Oneflow is running and you got the training loss
  ```
  2.7290366
  0.81281316
  0.50629824
  0.35949975
  0.35245502
  ...
  ```
242
- 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 已提交
243
</details>
S
strint 已提交
244 245

## Documentation
S
Shenghang Tsai 已提交
246

S
Shenghang Tsai 已提交
247 248
- [API Reference](https://oneflow.readthedocs.io/en/master/)
- [Usage & Design Docs](http://docs.oneflow.org/)
S
Shenghang Tsai 已提交
249
- [System Design](https://docs.oneflow.org/en/v0.4.0/basics_topics/essentials_of_oneflow.html)
S
strint 已提交
250 251

## Model Zoo and Benchmark
S
Shenghang Tsai 已提交
252 253

- [OneFlow Models](https://github.com/Oneflow-Inc/models)
S
Shenghang Tsai 已提交
254 255
- [OneFlow-Benchmark](https://github.com/Oneflow-Inc/OneFlow-Benchmark)
- [GPT](https://github.com/Oneflow-Inc/OneFlow-Benchmark/tree/master/LanguageModeling/GPT)
S
Shenghang Tsai 已提交
256 257 258
- [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 已提交
259 260

## Communication
S
Shenghang Tsai 已提交
261

262 263 264 265
- [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 已提交
266

267 268 269 270 271 272 273 274 275
  - 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 已提交
276 277

## The Team
S
Shenghang Tsai 已提交
278

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

## License
S
Shenghang Tsai 已提交
282

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