# HAI Platform
![Header](https://img.shields.io/badge/-hai--platform-orange)
[![License](https://img.shields.io/badge/license-LGPL-4EB1BB)](https://www.gnu.org/licenses/lgpl-3.0.en.html)
HAI 分时调度训练平台, 可通过 `docker-compose` 或 `k8s` 部署,提供功能:
- 训练任务分时调度
- 训练任务管理
- jupyter 开发容器管理
- [studio用户界面](https://github.com/HFAiLab/hai-platform-studio)
- haienv 运行环境管理
## 外部依赖
1. 一个集中存储,如 `nfs`, `ceph`, `weka`
- 用于存放用户的运行代码
- 代码运行输出的日志
- 部署需要的 k8s conf
2. k8s,确保你的运算主机都在 k8s 集群中
3. 建议计算节点支持rdma,并安装 [rdma-sriov device-plugin](https://github.com/mellanox/k8s-rdma-shared-dev-plugin)
- 如果没有,在 配置项目 `launcher.manager_envs` 中配置 `HAS_RDMA_HCA_RESOURCE: '0'`
## 快速上手
1. 构建
构建 all-in-one hai-platform 镜像
注:如需包含 haienv 202207 运行环境(包含cuda, torch),以同时作为训练任务镜像,需 `export BUILD_TRAIN_IMAGE=1`;如需自定义训练任务镜像,请参考 [附录:初始化数据库](#初始化数据库) 中 `train_environment` 的配置说明。
```shell
# replace IMAGE_REPO with your own repo
$ IMAGE_REPO=registry.cn-hangzhou.aliyuncs.com/hfai/hai-platform bash one/release.sh
build hai success:
hai-platform image: registry.cn-hangzhou.aliyuncs.com/hfai/hai-platform:fa07f13
hai-cli whl:
/home/hai-platform/build/hai-1.0.0+fa07f13-py3-none-any.whl
/home/hai-platform/build/haienv-1.4.1+fa07f13-py3-none-any.whl
/home/hai-platform/build/haiworkspace-1.0.0+fa07f13-py3-none-any.whl
```
安装 hai-cli 命令行
```shell
pip3 install /home/hai-platform/build/hai-1.0.0+fa07f13-py3-none-any.whl
pip3 install /home/hai-platform/build/haienv-1.4.1+fa07f13-py3-none-any.whl
pip3 install /home/hai-platform/build/haiworkspace-1.0.0+fa07f13-py3-none-any.whl
```
也可以使用预构建的镜像和命令行:
```shell
# 仅包含 hai-platform
registry.cn-hangzhou.aliyuncs.com/hfai/hai-platform:latest
# 包含 hai-platform 和 haienv 202207 运行环境(包含cuda, torch)
registry.cn-hangzhou.aliyuncs.com/hfai/hai-platform:latest-202207
pip3 install hai --extra-index-url https://pypi.hfai.high-flyer.cn/simple --trusted-host pypi.hfai.high-flyer.cn -U
```
2. 部署 hai-platform 到 k8s 集群
- 获取使用帮助
```shell
$ hai-up -h
Usage:
hai-up.sh config/run/up/dryrun/down/upgrade [option]
where:
config: print config script
run/up: run hai platform
dryrun: generate config template
down: tear down hai platform
upgrade: self upgrade hai-cli/hai-up utility
option:
-h/--help: show this help text
-p/--provider: k8s/docker-compose, default to k8s
-c/--config: show config scripts to setup environment variables,
if not specified, current shell environment will be used,
if not shell environment exists, default value in 'hai-up config' will be used
Setup guide
step 1: ensure the following dependencies satisfied
- a kubernetes cluster with loadbalancer and ingress supported
- a shared filesystem mounted in current host and other compute nodes
- for provider docker-compose: docker and docker-compose should be installed in current host
step 2: "hai-up config > config.sh", modify environment variables in config.sh
step 3: "hai-up run -c config.sh" to start the all-in-one hai-platform.
```
- 按提示配置相关环境变量,如共享文件系统路径、节点分组信息、训练镜像、用户信息、挂载点等,确认无误后部署(如需自定义更多配置,可运行 `hai-up dryrun` 获取配置模板并自行修改,手动部署)
```shell
hai-up config > config.sh
# customize config.sh
hai-up run -c config.sh
```
- 使用 `hai-cli` 初始化和提交任务
```shell
HAI_SERVER_ADDR=`kubectl -n hai-platform get svc hai-platform-svc -o jsonpath='{.status.loadBalancer.ingress[0].ip}'`
# TOKEN 为 USER_INFO 设置的token
hai-cli init ${TOKEN} --url http://${HAI_SERVER_ADDR}
# python文件默认需放在用户工作目录 ${SHARED_FS_ROOT}/hai-platform/workspace/{user.user_name}
# 如置于其他路径,需要在pg数据库storage表中添加相应挂载项
hai-cli python ${SHARED_FS_ROOT}/hai-platform/workspace/$(whoami)/test.py -- -n 1
```
- 如需停用hai-platform,运行 `hai-up down`
## 附录:配置说明
`hai-up run/dryrun` 会创建 init.sql, override.toml 配置文件,以及部署到 k8s/docker-compose 的yaml文件,如有自定义配置需求,可自行修改。部分配置解释如下。
### 网络端口
默认打开如下端口:
- 80: server
- 5432: postgresql
- 6379: redis
- 8080: studio
1. hai-platform 将启动一个 webservice,监听在 80 端口
2. 内建的 pgsql 和 redis 需要对外访问,让 manager 能够访问到
- 用户如果用自己搭建的外部 pgsql 和 redis,那么后两个端口可以不设置
3. studio 为平台提供管理 UI 页面
### k8s 相关配置
平台需要在集群创建 deployment,statefulset,pod,configmap 等资源,需要通过 rbac 为平台账号授权,或者直接赋予admin权限,对应的 kubeconfig 会被挂载到`hai-platform`的默认路径`/root/.kube/config`
### 节点分组
目前支持两类分组,TRAINING_GROUP, JUPYTER_GROUP,分别表示训练节点和jupyter节点。
需要指定分组名,以及分组内节点列表,如:
```shell
export MARS_PREFIX="hai-platform-one"
export TRAINING_GROUP="training"
export JUPYTER_GROUP="jupyter_cpu"
export TRAINING_NODES="cn-hangzhou.172.23.183.227"
export JUPYTER_NODES="cn-hangzhou.172.23.183.226"
```
设置分组信息后,启动脚本会自动配置 k8s node 的 label 为 `${MARS_PREFIX}_mars_group=${TRAINING_GROUP}` 或 `${MARS_PREFIX}_mars_group=${JUPYTER_GROUP}`; 并给 `hai-platform` 的 `schduler` 设置调度分组,同时设置数据库中的quota
### 挂载点
默认会挂载如下路径
```yaml
- '${HAI_PLATFORM_PATH}/kubeconfig:/root/.kube:ro' # k8s config,必须挂载
- '${HAI_PLATFORM_PATH}/log:/high-flyer/log' # platform 日志
- '${DB_PATH}:/var/lib/postgresql/12/main' # 持久化 pgsql
- '${HAI_PLATFORM_PATH}/redis:/var/lib/redis' # 持久化 redis
- '${HAI_PLATFORM_PATH}/workspace/log:${HAI_PLATFORM_PATH}/workspace/log' # 保存任务日志
- '${HAI_PLATFORM_PATH}/log/postgresql:/var/log/postgresql' # postgres 日志
- '${HAI_PLATFORM_PATH}/log/redis:/var/log/redis' # redis 日志
- '${HAI_PLATFORM_PATH}/init.sql:/tmp/init.sql' # 初始化的数据库语句,在这里添加相关的帐号、依赖等等配置
- '${HAI_PLATFORM_PATH}/override.toml:/etc/hai_one_config/override.toml' # override配置
```
1. 挂载 k8s 配置文件
2. 若需要,可以挂载 pgsql 的目录作为持久化目录,注意,容器内配置了 `/var/lib/postgresql/12/main` 作为数据目录
3. 用户的任务日志目录,需要在共享文件系统上,该目录信息会被配置到 `override.toml` 的 `experiment.log.dist` 中
### 数据库配置
#### 内建数据库
镜像内建了 `pgsql` 和 `redis`,并且通过 `override.toml` 配置相关信息。
```yaml
[database.postgres.primary]
host = '${HAI_SERVER_ADDR}'
port = 5432
user = '${POSTGRES_USER}'
password = '${POSTGRES_PASSWORD}'
[database.postgres.secondary]
host = '${HAI_SERVER_ADDR}'
port = 5432
user = '${POSTGRES_USER}'
password = '${POSTGRES_PASSWORD}'
[database.redis]
host = '${HAI_SERVER_ADDR}'
port = 637
没有合适的资源?快使用搜索试试~ 我知道了~
一种任务级GPU算力分时调度的高性能深度学习训练平台.zip
共709个文件
py:359个
png:58个
svg:44个
需积分: 5 3 下载量 65 浏览量
2024-02-04
20:21:26
上传
评论
收藏 7.66MB ZIP 举报
温馨提示
一种任务级GPU算力分时调度的高性能深度学习训练平台
资源推荐
资源详情
资源评论
收起资源包目录
一种任务级GPU算力分时调度的高性能深度学习训练平台.zip (709个子文件)
make.bat 769B
haproxy.cfg 1KB
supervisord.conf 13KB
supervisord.conf 6KB
postgresql.conf 4KB
pg_hba.conf 476B
theme.conf 360B
redis.conf 338B
element-plus.css 300KB
element-plus.css 300KB
theme.css 207KB
theme.css 207KB
all.css 58KB
all.css 58KB
basic.css 14KB
pygments.css 5KB
custom.css 840B
custom.css 840B
Dockerfile 4KB
.gitignore 60B
haienv 3KB
haiworkspace 250B
hfai 233B
experiment_api.html 96KB
session.html 91KB
client_remote.html 58KB
training_api.html 54KB
client.html 52KB
exec.html 43KB
custom.html 40KB
tutorial.html 35KB
studio.html 29KB
flags.html 27KB
schedule.html 24KB
hai_intro.html 23KB
ugc.html 21KB
task.html 20KB
cluster.html 20KB
environment.html 20KB
env_var.html 18KB
hai.html 18KB
genindex.html 17KB
install.html 16KB
index.html 15KB
user.html 14KB
layout.html 12KB
resources.html 12KB
index.html 11KB
search.html 11KB
breadcrumbs.html 4KB
fonts.html 2KB
footer.html 2KB
search.html 1KB
versions.html 1KB
searchbox.html 405B
mathjax_config.html 188B
objects.inv 989B
theme_variables.jinja 8KB
home-footer-background.jpg 38KB
home-footer-background.jpg 38KB
element-plus.full.js 881KB
element-plus.full.js 881KB
vue.global.prod.js 125KB
vue.global.prod.js 125KB
jquery.js 87KB
searchindex.js 77KB
bootstrap.min.js 48KB
bootstrap.min.js 48KB
theme.js 24KB
theme.js 24KB
popper.min.js 21KB
popper.min.js 21KB
underscore.js 19KB
list.min.js 18KB
list.min.js 18KB
searchtools.js 16KB
modernizr.min.js 15KB
modernizr.min.js 15KB
language_data.js 11KB
doctools.js 11KB
anchor.min.js 6KB
anchor.min.js 6KB
documentation_options.js 415B
LICENSE 7KB
Makefile 638B
README.md 14KB
tutorial.md 11KB
studio.md 9KB
hai_intro.md 7KB
schedule.md 5KB
environment.md 4KB
env_var.md 2KB
install.md 2KB
README.md 844B
resources.md 380B
.nojekyll 1B
platform_arch.png 610KB
platform_arch.png 610KB
platform_arch.png 610KB
studio_screenshot2.png 233KB
共 709 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
码农阿豪
- 粉丝: 1w+
- 资源: 1754
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功