From bff9f0dbdc0645e4526790982f3206e70a285441 Mon Sep 17 00:00:00 2001 From: chuboning Date: Fri, 13 Oct 2023 09:39:50 +0800 Subject: [PATCH] Add Dockerfile for building --- README.en.md | 2 ++ README.zh.md | 2 ++ scripts/docker/ARM/Dockerfile | 32 +++++++++++++++++++++++++++++++ scripts/docker/README.md | 32 +++++++++++++++++++++++++++++++ scripts/docker/X86/Dockerfile | 36 +++++++++++++++++++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 scripts/docker/ARM/Dockerfile create mode 100644 scripts/docker/README.md create mode 100644 scripts/docker/X86/Dockerfile diff --git a/README.en.md b/README.en.md index 04089c5..72972a9 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 274f843..65033ad 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 0000000..a8511f8 --- /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 0000000..6330ae8 --- /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 0000000..ea3f978 --- /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 + -- Gitee