README.md 4.1 KB
Newer Older
1 2 3
Paddle for Linux-musl Usage Guide
===========================================

4
# Introduction
5 6 7
Paddle can be built for linux-musl such as alpine, and be used in libos-liked SGX TEE environment. Currently supported commericial product TEE Scone, and community maintanced TEE Occlum. We also working on to support open source TEE Graphene.


8
# Build Automatically
9
1. clone paddle source from github
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
```bash
git clone https://github.com/PaddlePaddle/Paddle.git
```

2. setup build directory

```bash
# enter paddle directory
cd  ./Paddle

# create and enter building directory
mkdir -p build && cd build
```

3. build docker for compiling. use environment HTTP_PROXY/HTTPS_PROXY for proxy setup.

```bash
28 29 30
# setup proxy address, when the speed of internet is not good.
# export HTTP_PROXY='http://127.0.0.1:8080'
# export HTTPS_PROXY='https://127.0.0.1:8080'
31 32 33 34 35 36

# invoke build script
../paddle/scripts/musl_build/build_docker.sh
```

4. compile paddle in previous built docker. proxy setup method is same as previous step.
37

38 39

```bash
40 41 42
# setup proxy addresss, when the speed of internet is not good.
# export HTTP_PROXY='http://127.0.0.1:8080'
# export HTTPS_PROXY='https://127.0.0.1:8080'
43 44

# invoke build paddle script
45 46
# all arguments, such as -j8 optinal, is past to make procedure.
../paddle/scripts/musl_build/build_paddle.sh -j8
47 48

# find output wheel package
49 50
# output wheel packages will save to "./output" directory.
ls ./output/*.whl
51 52
```

53
# Build Manually
54 55 56 57 58 59 60 61 62 63 64 65 66

1. start up the building docker, and enter the shell in the container
```bash
# checkout paddle source code
git clone https://github.com/PaddlePaddle/Paddle.git

# entery paddle directory
cd ./Paddle

# build docker image
../paddle/scripts/musl_build/build_docker.sh

# enter the container interactive shell
chen.zhiyu's avatar
chen.zhiyu 已提交
67
BUILD_MAN=1 ../paddle/scripts/musl_build/build_paddle.sh
68 69
```

chen.zhiyu's avatar
chen.zhiyu 已提交
70
2. type commands and compile source manually
71 72 73 74 75 76 77 78 79 80
```sh
# compile paddle by commands
# paddle is mount to /paddle directory
# working directory is /root
mkdir build && cd build

# install python requirement
pip install -r /paddle/python/requirements.txt

# configure project with cmake
chen.zhiyu's avatar
chen.zhiyu 已提交
81
cmake -DWITH_MUSL=ON -DWITH_CRYPTO=OFF -DWITH_MKL=OFF -DWITH_GPU=OFF /paddle
82

83 84 85
# run the make to build project.
# the argument -j8 is optional to accelerate compiling.
make -j8
86 87
```

88 89 90
# Scripts
1. **build_docker.sh**
   compiling docker building script. it use alpine linux 3.10 as musl linux build enironment. it will try to install all the compiling tools, development packages, and python requirements for paddle musl compiling.
91

92
    environment variables:
93
   - PYTHON_VERSION: the version of python used for image building, default=3.7.
94 95 96 97 98 99
   - WITH_PRUNE_DAYS: prune old docker images, with days limitation.
   - WITH_REBUILD: force to rebuild the image, default=0.
   - WITH_REQUIREMENT: build with the python requirements, default=1.
   - WITH_UT_REQUIREMENT: build with the unit test requirements, default=0.
   - WITH_PIP_INDEX: use custom pip index when pip install packages.
   - ONLY_NAME: only print the docker name, and exit.
chen.zhiyu's avatar
chen.zhiyu 已提交
100 101
   - HTTP_PROXY: use http proxy.
   - HTTPS_PROXY: use https proxy.
102 103 104

2. **build_paddle.sh** automatically or manually paddle building script. it will mount the root directory of paddle source to /paddle, and run compile procedure in /root/build directory. the output wheel package will save to the ./output directory relative to working directory.

105
    environment variables:
chen.zhiyu's avatar
chen.zhiyu 已提交
106 107
    - BUILD_MAN: build the paddle manually, default=0.
    - WITH_TEST: build with unitest, and run unitest check, default=0.
108 109 110
    - WITH_PRUNE_CONTAINER: remove the container after building, default=1.
    - CTEST_*: CTEST flages used for unit test.
    - FLAGS_*: build flages used for paddle building.
chen.zhiyu's avatar
chen.zhiyu 已提交
111 112
    - HTTP_PROXY: use http proxy.
    - HTTPS_PROXY: use https proxy.
113 114 115 116 117 118

# Files
- **build_docker.sh**: docker building script
- **build_paddle.sh**: paddle building script
- **build_inside.sh**: build_paddle.sh will invoke this script inside the docker for compiling.
- **config.sh**: build config script for configure compiling option setting.
I
iLeGend 已提交
119
- **Dockerfile**: build docker definition file.
120 121
- **package.txt**: build required develop packages for alpine linux.
- **REAME.md**: this file.