diff --git a/README.en.md b/README.en.md index 04089c53267b24323c3045553f14e3df2f0ecb0a..72972a943deb86c8cf2d2ed956c67cb599b2c574 100644 --- a/README.en.md +++ b/README.en.md @@ -25,6 +25,8 @@ The generated binary package is stored in the current **dist** directory. ## Installation +*using docker is recommended:[Link](https://gitee.com/ascend/apex/tree/master/scripts/docker/README.md) + Run the following command: ``` cd apex/dist/ diff --git a/README.zh.md b/README.zh.md index 274f843e63795cc988495471e468780614c047d0..65033adffb061c218aa427c63c13999a2309ffdf 100644 --- a/README.zh.md +++ b/README.zh.md @@ -53,6 +53,8 @@ Ascend Apex以patch的形式发布,使能用户在华为昇腾(HUAWEI Ascend ## 二、生成全量代码及编译、安装 +*推荐使用docker,在容器内编译:[参考链接](https://gitee.com/ascend/apex/tree/master/scripts/docker/README.md) + 建议用户以非root用户做环境的安装,避免不必要的安全风险 ### 2.1 获取昇腾适配的Ascend apex源码 diff --git a/scripts/docker/ARM/Dockerfile b/scripts/docker/ARM/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a8511f8271dc1c31c0fcdab7af2f5928adbb8af2 --- /dev/null +++ b/scripts/docker/ARM/Dockerfile @@ -0,0 +1,32 @@ +FROM quay.io/pypa/manylinux2014_aarch64:2023-10-07-c1e05d1 + +# Set pip +RUN cd /usr/local/bin \ + && ln -s /opt/_internal/cpython-3.7.17/bin/pip3.7 pip3.7 \ + && ln -s /opt/_internal/cpython-3.8.18/bin/pip3.8 pip3.8 \ + && ln -s /opt/_internal/cpython-3.9.18/bin/pip3.9 pip3.9 \ + && ln -s /opt/_internal/cpython-3.10.13/bin/pip3.10 pip3.10 \ + && ln -s python3.8 python3 + +# Set pip source +RUN mkdir /root/.pip \ + && echo "[global]" > /root/.pip/pip.conf \ + && echo "index-url=https://mirrors.aliyun.com/pypi/simple" >> /root/.pip/pip.conf \ + && echo "trusted-host=mirrors.aliyun.com" >> /root/.pip/pip.conf \ + && echo "timeout=120" >> /root/.pip/pip.conf + +# Install pip package(build) +RUN pip3.7 install pyyaml \ + && pip3.7 install --force-reinstall setuptools==41.2.0 + +RUN pip3.8 install pyyaml \ + && pip3.8 install --force-reinstall setuptools==41.2.0 + +RUN pip3.9 install pyyaml \ + && pip3.9 install --force-reinstall setuptools==41.2.0 + +RUN pip3.10 install pyyaml \ + && pip3.10 install --force-reinstall setuptools==41.2.0 + +WORKDIR /home + diff --git a/scripts/docker/README.md b/scripts/docker/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6330ae816eed84c6c258eb7ad8ea88830d26d4c0 --- /dev/null +++ b/scripts/docker/README.md @@ -0,0 +1,32 @@ +### Build apex from Docker container + +**Clone apex** + +```Shell +git clone -b master https://gitee.com/ascend/apex.git +``` + +**Build docker image** + +```Shell +cd apex/scripts/docker/{arch} # {arch} for X86 or ARM +docker build -t manylinux-builder:v1 . +``` +**Enter docker Container** + +```Shell +docker run -it -v /{code_path}/apex:/home/apex manylinux-builder:v1 bash +# {code_path} is the apex source code path +``` +**Install torch** + +Take Python 3.8 as an example +```Shell +pip3.8 install torch +# Reference url: https://pytorch.org/get-started/previous-versions/ +``` +**Compile apex** +```Shell +cd /home/apex +bash scripts/build.sh --python=3.8 +``` diff --git a/scripts/docker/X86/Dockerfile b/scripts/docker/X86/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..ea3f97832e424df82176b36da8f544110f8eb0e3 --- /dev/null +++ b/scripts/docker/X86/Dockerfile @@ -0,0 +1,36 @@ +FROM pytorch/manylinux-builder:cpu-2.1 + +# Install python +RUN cd /usr/local/bin \ + && ln -s /opt/_internal/cpython-3.7.5/bin/pip3.7 pip3.7 \ + && ln -s /opt/_internal/cpython-3.8.1/bin/pip3.8 pip3.8 \ + && ln -s /opt/_internal/cpython-3.9.0/bin/pip3.9 pip3.9 \ + && ln -s /opt/_internal/cpython-3.10.1/bin/pip3.10 pip3.10 \ + && ln -s /opt/_internal/cpython-3.7.5/bin/python3.7 python3.7 \ + && ln -s /opt/_internal/cpython-3.8.1/bin/python3.8 python3.8 \ + && ln -s /opt/_internal/cpython-3.9.0/bin/python3.9 python3.9 \ + && ln -s /opt/_internal/cpython-3.10.1/bin/python3.10 python3.10 \ + && ln -s python3.8 python3 + +# Set pip source +RUN mkdir /root/.pip \ + && echo "[global]" > /root/.pip/pip.conf \ + && echo "index-url=https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf \ + && echo "trusted-host=repo.huaweicloud.com" >> /root/.pip/pip.conf \ + && echo "timeout=120" >> /root/.pip/pip.conf + +# Install pip package(build) +RUN pip3.7 install pyyaml \ + && pip3.7 install --force-reinstall setuptools==41.2.0 + +RUN pip3.8 install pyyaml \ + && pip3.8 install --force-reinstall setuptools==41.2.0 + +RUN pip3.9 install pyyaml \ + && pip3.9 install --force-reinstall setuptools==41.2.0 + +RUN pip3.10 install pyyaml \ + && pip3.10 install --force-reinstall setuptools==41.2.0 + +WORKDIR /home +