1.获取基础镜像并导入
- 基础镜像ascend-mindspore-arm网址:https://ascendhub.huawei.com/#/detail/ascend-mindspore-arm
- 登录基础镜像网址,点击“获取镜像”
- 在随后出现的Uniportal帐号登录界面,选择账号/邮箱登录、手机号码登录、短信登录三种方式之一,登入。如果网页出现“禁止”字样,请更换登录方式。建议“短信登录”方法登录。
- 版本界面,选择版本“21.0.1.spc001”, 点击下载列表对应的“立即下载”,进入下载界面
- 下载界面会显示下载步骤,请按步骤执行。
- 获取登录访问权限并复制到工作节点执行:
docker login -u WX926930 -p 4u9xchG5IzMuGgVFxvvMVH895SwE0tIXAQrBwl0C46uHzhMwYEq5eWV0EvYbG7CdO ascendhub.huawei.com
- 下载镜像:
docker pull ascendhub.huawei.com/public-ascendhub/ascend-mindspore-arm:21.0.1.spc001
- 在工作节点查询镜像:
(base) root@node62:/home/lhb/code/ascend-mindspore-arm_ssh# docker images |grep ascend-mindspore-arm
ascendhub.huawei.com/public-ascendhub/ascend-mindspore-arm 21.0.1.spc001 67bcd3733d57 5 weeks ago 6.67GB
(base) root@node62:/home/lhb/code/ascend-mindspore-arm_ssh#
2.目标镜像制作
2.1创建工作目录ascend-mindspore-arm_ssh
目录文件如下:
- Ascend-cann-toolkit_5.0.3_linux-aarch64.run 请自行下载
- Dockfile。内容如1小节所示。
- 容器启动run_container.sh脚本。
docker run -it --ipc=host --device=/dev/davinci0 --device=/dev/davinci1 --device=/dev/davinci2 --device=/dev/davinci3 --device=/dev/davinci4 --device=/dev/davinci5 --device=/dev/davinci6 --device=/dev/davinci7 --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc -v /usr/local/Ascend/driver:/usr/local/Ascend/driver -v /usr/local/Ascend/add-ons/:/usr/local/Ascend/add-ons/ -v /var/log/npu/:/usr/slog -v /home/:/home -p 8000:22 ascend-mindspore-arm:ms1.5 bash -c "/etc/init.d/ssh start && /bin/bash"
说明:-p 8000:22 表示外部端口8000映射容器22端口,提供外部ssh访问能力
2.2 创建Dockfile
工作目录创建名字为Dockfile文件,内容如下:
FROM ascendhub.huawei.com/public-ascendhub/ascend-mindspore-arm:21.0.1.spc001
MAINTAINER liangchaoming
RUN apt-get update \
&& /usr/bin/python3.7 -m pip install --upgrade pip \
&& apt-get install libnuma-dev openssh-server apt-utils sshpass -y \
&& /usr/local/Ascend/nnae/latest/script/uninstall.sh
ADD Ascend-cann-toolkit_5.0.3_linux-aarch64.run /opt/packet/Ascend-cann-toolkit_5.0.3_linux-aarch64.run
RUN /opt/packet/Ascend-cann-toolkit_5.0.3_linux-aarch64.run --full \
&& pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/1.5.0/MindSpore/ascend/aarch64/mindspore_ascend-1.5.0-cp37-cp37m-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& echo 'root:root'|chpasswd \
&& mkdir -p /var/run/sshd \
&& sed -i 's/.*PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
2.3 制作目标镜像
- 创建指令:
docker build -t ascend-mindspore-arm:ms1.5 .
注意:指令末尾的".",表示使用当前目录的Dockfile。
- 查询当前节点镜像列表:
(base) root@node64:/home/lhb/test2# docker images |grep ascend-mindspore-arm
ascend-mindspore-arm ms1.5 2454f44b88ee 5 hours ago 12.1GB
- 创建容器启动脚本./run_container.sh
docker run -it -d --ipc=host --device=/dev/davinci0 --device=/dev/davinci1 --device=/dev/davinci2 --device=/dev/davinci3 --device=/dev/davinci4 --device=/dev/davinci5 --device=/dev/davinci6 --device=/dev/davinci7 --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc -v /usr/local/Ascend/driver:/usr/local/Ascend/driver -v /usr/local/Ascend/add-ons/:/usr/local/Ascend/add-ons/ -v /var/log/npu/:/usr/slog -v /home/:/home -p 8000:22 ascend-mindspore-arm:ms1.5 bash -c "/etc/init.d/ssh start && /bin/bash"
- 执行./run_container.sh创建工作容器,并查询容器状态
(base) root@node64:/home/lhb/test2# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0f6f9971a646 ascend-mindspore-arm:ms1.5 "bash -c '/etc/init.…" 3 hours ago Up 3 hours 0.0.0.0:8000->22/tcp compassionate_cerf
3. 容器ssh登录验证
在其它节点执行 ssh root@{IP} -p 8000
示例:ssh root@90.90.66.64 -p 8000(密码root)
执行结果:
[root@node66 ~]# ssh root@90.90.66.64 -p 8000
root@90.90.66.64's password:
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-29-generic aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
Last login: Thu Nov 18 09:10:30 2021 from 90.90.66.66
root@0f6f9971a646:~#