Commit d4b6e644 authored by songlinfeng's avatar songlinfeng 💬
Browse files

Update README.md

parent 0da9d5a2
......@@ -3,29 +3,36 @@
## 简介
DTK Container Toolkit 使用户能够构建和运行使用DCU设备的容器,该toolkit包括以下工具包。
```dtk-container-toolkit``` - DTK容器运行时
```dtk-ctk``` - DTK容器工具集命令行
## 使用
- ```dtk-container-toolkit``` - DTK容器运行时
- ```dtk-ctk``` - DTK容器工具集命令行
## 使用
- --gpus需要Docker version 19+
- cdi 需要Docker version 25+
首先确保已经安装好DTK。
### 安装
使用 dpkg/rpm -i 进行安装。
使用 dpkg/rpm -i 进行安装。安装后会自动执行以下命令
```sh
$ dtk-ctk --quiet config --config-file=/etc/dtk-container-runtime/config.toml --in-place #生成配置文件
$ dtk-ctk runtime configure --runtime=docker --set-as-default #修改docker的config.json的runtime
```
重启docker服务
```sh
$ sudo systemctl restart docker
```
### 在容器中使用HCU
### 在docker中使用DCU
#### 通过 docker CLI
可以通过 docker run 添加参数 --gpus 给容器添加HCU设备。
```sh
$ docker run -it --gpus all ubuntu:18.04 # 添加所有HCU设备
$ docker run -it --gpus 1 ubuntu:18.04 # 添加一个HCU设备,HCU 0
$ docker run -it --gpus "device=0,2" ubuntu:18.04 #添加第0号和第2号GPU
```
#### 通过环境变量 `DTK_VISIBLE_DEVICES`
......@@ -35,3 +42,42 @@ docker run -it -e DTK_VISIBLE_DEVICES=all ubuntu:18.04 # 添加所有HCU设备
docker run -it -e DTK_VISIBLE_DEVICES=0 ubuntu:18.04 # 添加HCU设备0
docker run -it -e DTK_VISIBLE_DEVICES=0,1 ubuntu:18.04 # 添加HCU设备0、1
```
#### 通过CDI方式
- 首先,生成CDI spec文件
```sh
$ dtk-ctk cdi generate --output=/etc/cdi/dtk.json
```
- 配置docker开启CDI
```sh
$ dtk-ctk runtime configure --runtime=docker --set-as-default --cdi.enabled
```
- 使用所有的DCU
```sh
$ docker run --rm --device c-3000.com/hcu=all -it ubuntu:18.04
```
- 使用第0块和第1块DCU
```sh
$ docker run --rm --device c-3000.com/hcu=0 --device c-3000.com/hcu=1 -it ubuntu:18.04
```
### 在podman中使用DCU
podman 需要version 2.0+
- 首先需要修改podman的runtime
```sh
$ dtk-ctk runtime configure --runtime=podman --set-as-default
```
- 通过环境变量方式使用
```sh
$ podman run -it -e DTK_VISIBLE_DEVICES=all ubuntu:18.04
```
###列出可使用的DCU
```sh
$ dtk-ctk cdi list
INFO[0000] Found 3 CDI devices
c-3000.com/hcu=0
c-3000.com/hcu=1
c-3000.com/hcu=2
c-3000.com/hcu=all
c-3000.com/hcu=hcu-73873c7a6eb008a1
c-3000.com/hcu=hcu-73873c7a6eb02041
c-3000.com/hcu=hcu-73873c7a6eb040a1
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment