Skip to content

Commit aa2d0fe

Browse files
Add virtaitech/orion-client:pytorch-1.0.1-py3 docker image (use PyTorch official pip wheel)
- install from official pytorch wheel Add virtaitech/orion-client:tf1.8-base docker image Polish documents
1 parent 2287c5f commit aa2d0fe

File tree

15 files changed

+255
-71
lines changed

15 files changed

+255
-71
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ Orion vGPU软件用户手册
2626

2727
# What's New
2828

29-
* 2019/07/06 Orion vGPU软件更新:更加精确的显存控制
29+
* **2019/07/08** Docker 镜像更新:[PyTorch 1.0.1](./dockerfiles/client-pytorch-1.0.1-py3)[TensorFlow 1.8.0](./dockerfiles/client-tf1.8-base)
3030

31-
用户需要确保Orion Controller,Orion Server和Orion Client都是最新版本。不同版本的Orion vGPU组件无法共同工作。
31+
PyTorch 1.0.1镜像中,PyTorch 1.0.1和torchvision 0.2.2均由官方wheels安装,无须从源码编译。
32+
33+
用户使用最新镜像之前,需要确保Orion Server已经更新至最新版本。
34+
35+
* **2019/07/06** Orion vGPU软件更新:更加精确的显存控制
36+
37+
用户需要确保Orion Controller,Orion Server和Orion Client更新至最新版本。不同版本的Orion vGPU组件无法共同工作。
3238

3339
* `Orion Controller` 使用最新的`orion-controller`
3440

blogposts/pytorch_models.md

Lines changed: 84 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,34 @@
55
我们推荐用户在我们准备的Orion Client容器内部运行PyTorch模型
66

77
```bash
8-
docker pull virtaitech/orion-client:pytorch-1.1.0-py3
8+
docker pull virtaitech/orion-client:pytorch-1.0.1-py3
9+
# (or use pytorch 1.1.0)
10+
# docker pull virtaitech/orion-client:pytorch-1.1.0-py3
911
```
1012

1113
运行容器之前,用户需要保证Orion Controller和Orion Server正常运行。运行容器时,需要将`orion-shm`工具创建的`/dev/shm/orionsock<index>`挂载进容器内的同一路径。用户还需要设置正确的`ORION_CONTROLLER`环境变量。
1214

13-
<a id="run-container"></a>**容器内使用PyTorch Multiprocessing**
15+
<a id="run-container"></a>**容器内使用**
1416

15-
为了在容器中使用PyTorch的Multiprocessing模块,包括PyTorch DataLoader,用户需要增大容器所能使用的共享内存最大值。为此,`docker run`时需要加上
17+
如果用户需要在容器中使用PyTorch Multiprocessing模块(例如通过DataLoader多进程加载Imagenet数据集),用户需要增大容器内用于IPC的共享内存限额。为此,`docker run`时需要加上参数
1618

1719
```bash
1820
--ipc=host
21+
# (or specify max shm size)
22+
# --shm-size=8G
1923
```
20-
或者
21-
```bash
22-
--shm-size=8G
23-
```
24-
参数。这一要求与Orion vGPU软件无关,即使通过`nvidia-docker`使用本地物理GPU也是需要的。关于这一点,用户可以参见[NVIDIA官方PyTorch镜像说明](https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/running.html)
2524

26-
**在KVM虚拟机或者裸物理机运行PyTorch使用Orion vGPU**
2725

28-
如果用户要在非容器环境中安装PyTorch以及Orion Client Runtime以使用Orion vGPU资源,建议用户将Orion Client运行时安装到`/usr/local/cuda-9.0`,并创建软链接`/usr/local/cuda => /usr/local/cuda-9.0`:
26+
这一要求与Orion vGPU软件无关,即使通过`nvidia-docker`使用本地物理GPU也是需要的。关于这一点,用户可以参见[NVIDIA官方PyTorch镜像说明](https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/running.html)
2927

30-
```bash
31-
mkdir -p /usr/local/cuda-9.0
32-
./install-client -d /usr/local/cuda-9.0
33-
ln -s /usr/local/cuda-9.0 /usr/local/cuda
34-
```
28+
**在KVM虚拟机或者裸物理机运行PyTorch使用Orion vGPU**
3529

36-
此外,用户可能需要根据[PyTorch Dockerfile文档](../dockerfiles/client-pytorch-1.1.0-py3/README.md)中介绍的步骤,从源码编译一个依赖项更精简的PyTorch版本。
30+
* 对于PyTorch 1.0.x 版本,用户运行`install-client`安装包安装Orion Client Runtime后即可支持。PyTorch可以直接从
31+
32+
* 对于PyTorch 1.1.0 版本,我们目前要求用户从源码编译,以去掉部分组件依赖。用户可以参考根据[PyTorch 1.1.0 镜像文档](../dockerfiles/client-pytorch-1.1.0-py3/README.md)中介绍的步骤、编译参数,从源码编译一个依赖项更精简的PyTorch 1.1.0版本。
3733

3834
## 支持情况
39-
Orion vGPU对PyTorch的支持还在持续开发中。目前,我们支持PyTorch 1.0.1和1.1.0版本。
35+
Orion vGPU对PyTorch的支持还在持续开发中。目前,我们支持PyTorch 1.0.x和1.1.0版本。
4036

4137
需要注意的是
4238
* Orion vGPU目前不支持PyTorch通过RDMA网络使用远程GPU资源
@@ -60,7 +56,7 @@ Orion vGPU对PyTorch的支持还在持续开发中。目前,我们支持PyTorc
6056
...
6157
```
6258

63-
用户可以用`--dataset lfw --dataroot=path/to/celeba`参数使用解压后的数据集进行训练。由于我们目前只支持单块Orion vGPU,用户需要加上`--ngpu 1`参数
59+
用户可以用`--dataset lfw --dataroot=path/to/celeba`参数使用解压后的数据集进行训练。由于我们暂时不能完全支持NCCL通信库,用户需要加上`--ngpu 1`参数指定使用一块Orion vGPU进行训练
6460
```bash
6561
python3 main.py --dataset lfw --dataroot /path/to/celeba --cuda --ngpu 1
6662
```
@@ -105,21 +101,86 @@ Orion vGPU对PyTorch的支持还在持续开发中。目前,我们支持PyTorc
105101
以保证容器内部的DataLoader Worker进程之间可以通过共享内存交换数据。
106102

107103
* [MNIST Convnets](https://github.com/pytorch/examples/tree/master/mnist) 支持
104+
105+
```bash
106+
python3 main.py
107+
```
108+
109+
默认会训练10个epochs。
110+
108111
* [MNIST Hogwild](https://github.com/pytorch/examples/tree/master/mnist_hogwild) 暂不支持,对CUDA IPC的全面支持还在开发阶段。
109112
* [Linear Regression](https://github.com/pytorch/examples/tree/master/regression) 支持
113+
114+
```bash
115+
python3 main.py
116+
```
117+
110118
* [Reinforcement Learning](https://github.com/pytorch/examples/tree/master/reinforcement_learning) 支持
119+
120+
```bash
121+
pip3 install -r requirements.txt
122+
# For REINFORCE:
123+
python3 reinforce.py
124+
# For actor critic:
125+
python3 actor_critic.py
126+
```
127+
111128
* [SNLI with GloVe vectors and LSTMs](https://github.com/pytorch/examples/tree/master/snli) 支持
112129

113-
用户需要安装`spacy`,并下载语料集:
130+
用户需要安装torchtext和spacy,并下载spacy模型:
131+
此外,用户需要安装`spacy`
114132
```bash
115-
pip3 install spacy
133+
pip3 install torchtext spacy
134+
116135
python3 -m spacy download en
117136
```
118-
* [Super Resolution](https://github.com/pytorch/examples/tree/master/super_resolution) 提供的容器内不支持,因为编译时没有带上Lapack支持。
137+
138+
然后运行模型:
139+
140+
```bash
141+
python3 main.py
142+
```
143+
144+
* [Super Resolution](https://github.com/pytorch/examples/tree/master/super_resolution) ~~提供的容器内不支持~~提供的PyTorch 1.1.0镜像不支持,因为编译PyTorch时没有带上Lapack支持。
145+
146+
**Update 2019/07/08** 用户可以在我们提供的PyTorch 1.0.1镜像中运行这个例子:
147+
148+
```bash
149+
# Train 100 epochs
150+
python3 main.py --upscale_factor 3 --batchSize 4 --testBatchSize 100 --nEpochs 100 --lr 0.001
151+
152+
# Super Resolution
153+
python3 super_resolve.py --input_image dataset/BSDS300/images/test/16077.jpg --model model_epoch_500.pth --output_filename out.png
154+
```
155+
156+
生成的图片为`out.png`,用户可以与输入图片`dataset/BSDS300/images/test/16077.jpg`对比效果。
157+
119158
* [Time Sequence Prediction](https://github.com/pytorch/examples/tree/master/time_sequence_prediction) 支持
159+
160+
```bash
161+
# Generate input data
162+
python3 generate_sine_wave.py
163+
# Train
164+
python3 train.py
165+
```
166+
167+
训练结束后会在当前目录生成预测的波形图。
168+
120169
* [Variational Auto-Encoders](https://github.com/pytorch/examples/tree/master/vae) 支持
170+
171+
```bash
172+
python3 main.py
173+
```
174+
121175
* [Word Language Model using LSTM](https://github.com/pytorch/examples/tree/master/word_language_model) 支持
122176

177+
```bash
178+
# Train a tied LSTM on Wikitext-2 with CUDA
179+
python3 main.py --cuda --epochs 6 --tied
180+
# Generate samples from the trained LSTM model.
181+
python3 generate.py
182+
```
183+
123184
## 多卡训练Resnet50模型示例
124185

125186
本节中,我们展示一个有趣的场景:将两块本地Tesla P100 16GB计算卡虚拟化成4块Orion vGPU用于在Imagenet数据集上训练Resnet50模型。我们在Orion Client内的资源申请环境变量为`ORION_VGPU=4``ORION_GMEM=7800`,这样可以保证每两块Orion vGPU位于一块Tesla P100计算卡上。
@@ -179,9 +240,9 @@ python3 main.py --arch resnet50 \
179240

180241
可以看到,实际的计算任务被Orion Server进程`oriond`完全接管。
181242

182-
用户或许会发现,`orion-smi`汇报的显存使用少于`nvidia-smi`汇报的实际物理显存使用,这是因为`orion-smi`工具目前只汇报堆上分配的显存,没有计入CUDA context、cuDNN等隐式占用的显存开销。
243+
~~用户或许会发现,`orion-smi`汇报的显存使用少于`nvidia-smi`汇报的实际物理显存使用,这是因为`orion-smi`工具目前只汇报堆上分配的显存,没有计入CUDA context、cuDNN等隐式占用的显存开销。~~
183244

184-
**[2019-07-06]更新** Orion vGPU软件增加了对显存使用控制的精确控制,将包括CUDA context在内的主要隐式显存分配纳入了控制范围,因此用户使用`orion-smi`工具看到的结果会非常接近于`nvidia-smi`。对于PyTorch模型训练,一般显存显示误差在20秒以内
245+
**Update 2019/07/06** Orion vGPU软件增加了对显存使用控制的精确控制,将包括CUDA context在内的主要隐式显存分配纳入了控制范围,因此用户使用`orion-smi`工具看到的结果会非常接近于`nvidia-smi`。对于PyTorch模型训练,一般显存显示误差在20MB以内
185246

186247

187248
经过7个epoch后,我们的训练达到49.362% top-1精度,75.680% top-5精度。

dockerfiles/README.md

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,37 @@
22

33
我们准备了安装有Orion Client Runtime,以及TensorFlow,PyTorch的不同镜像。其中,
44
* TensorFlow 1.12直接从`pip`源安装
5-
* PyTorch 1.1.0从官方源码直接编译生成
5+
* PyTorch 1.0.1直接从`pip`源安装,1.1.0从官方源码直接编译生成
66
* 镜像内操作系统均为`Ubuntu 16.04`
7-
* 在部分镜像中,我们还安装了`MNLX_OFED 4.5.1`RDMA驱动
7+
* 我们提供了部分安装`MNLX_OFED 4.5.1`用户态驱动的镜像,以支持RDMA
88

9-
此repo中的Dockerfile对应于Orion vGPU软件的官方[Docker Hub Registry](https://hub.docker.com/r/virtaitech/orion-client)
9+
此仓库中的Dockerfiles对应于Orion vGPU软件的官方[Docker Hub Registry](https://hub.docker.com/r/virtaitech/orion-client)
1010

11-
需要注意的是,每个镜像对应的路径下所需要的
12-
* `install-client`安装包
13-
* MLNX_OFED 4.5-1.0.1.0驱动
14-
* 以及PyTorch从源码编译得到的wheel包
15-
16-
需要用户自行放置到路径下,方可成功运行`docker build`
11+
## TensorFlow 基础镜像
1712

18-
## [TensorFlow 1.12 基础镜像](./client-tf1.12-base)
13+
### [TensorFlow 1.12](./client-tf1.12-base)
1914

2015
```bash
2116
docker pull virtaitech/orion-client:tf1.12-base
2217
```
2318

2419
此镜像中通过`pip3 install tensorflow-gpu==1.12`安装了官方TensorFlow,然后通过`install-client`安装包安装了Orion Client运行时。
2520

26-
## [TensorFlow 1.12 带MNLX驱动,Python 3.5环境](./client-tf1.12-py3)
21+
为方便用户,我们将TensorFlow官方CNN benchmarks克隆到`/root/benchmarks`目录下。
22+
23+
### [TensorFlow 1.8](./client-tf1.8-base)
24+
25+
```bash
26+
docker pull virtaitech/orion-client:tf1.8-base
27+
```
28+
29+
此镜像中通过`pip3 install tensorflow-gpu==1.8`安装了官方TensorFlow,然后通过`install-client`安装包安装了Orion Client运行时。
30+
31+
为方便用户,我们将TensorFlow官方CNN benchmarks克隆到`/root/benchmarks`目录下。
32+
33+
### 支持RDMA的TensorFlow镜像
34+
35+
### [TensorFlow 1.12 带MNLX驱动,Python 3.5环境](./client-tf1.12-py3)
2736

2837
```bash
2938
docker pull virtaitech/orion-client:tf1.12-py3
@@ -35,7 +44,7 @@ docker pull virtaitech/orion-client:tf1.12-py3
3544

3645
为了展示的方便,我们同样安装了Juypter Notebook和部分Python packages。
3746

38-
## [TensorFlow 1.12 带MNLX驱动,Python 2.7环境](./client-tf1.12-py2)
47+
### [TensorFlow 1.12 带MNLX驱动,Python 2.7环境](./client-tf1.12-py2)
3948

4049
```bash
4150
docker pull virtaitech/orion-client:tf1.12-py2
@@ -47,23 +56,34 @@ docker pull virtaitech/orion-client:tf1.12-py2
4756

4857
本镜像中,我们安装了部分Python packages,以便用户使用[TensorFlow Object Detection](https://github.com/tensorflow/models/tree/master/research/object_detection)模型,以及其余[官方Models](https://github.com/tensorflow/models)
4958

50-
## [PyTorch 1.1.0, Python 3.5环境](./client-pytorch-1.1.0-py3)
59+
## PyTorch 镜像
5160

52-
由于PyTorch官方提供的`pip`源wheel包里面编译了太多组件,部分组件我们这一版的Orion vGPU软件还不支持,我们通过PyTorch的源码编译了1.1.0版本的wheel包。我们没有对源码进行任何修改,只是更改了编译选项。
61+
### 注意事项
62+
在使用PyTorch DataLoader加载训练数据时,启动容器时需要设置`--ipc=host`参数保证DataLoader进程之间可以进行IPC。本要求与Orion vGPU软件**无关**,即使用户通过`nvidia-docker`在容器中运行PyTorch也是必须的。
5363

54-
我们同样从源码开始,使用默认编译选项编译了torchvision 0.3.0版本,打包进镜像。我们也安装了部分Python packages,使得用户可以直接在镜像里面运行PyTorch的官方examples:https://github.com/pytorch/examples
64+
在我们的[一篇技术博客](../blogposts/pytorch_models.md)里,我们介绍了如何让PyTorch使用多块Orion vGPU在Imagenet数据集上训练Resnet50模型。
5565

56-
我们在镜像中已经将[官方模型例子](https://github.com/pytorch/examples)克隆后放在`/root/examples`目录下,用户可以进入其中每个模型子目录运行模型。
66+
### [PyTorch 1.0.1, Python 3.5环境](./client-pytorch-1.0.1-py3)
5767

58-
最后,我们通过通过`install-client`安装包安装了Orion Client运行时
68+
我们从PyTorch官方提供的Python3 wheel包安装了PyTorch 1.0.1
5969

60-
我们在[PyTorch 1.10 Python3.5 镜像](./client-pytorch-1.1.0-py3)中介绍了我们编译PyTorch 1.1.0,TorchVision 0.3.0,以及安装Orion Client Runtime的步骤,用户可以参考。
70+
```bash
71+
RUN pip3 install torch==1.0.1 -f https://download.pytorch.org/whl/cu90/stable
72+
```
6173

62-
### 注意事项
63-
由于PyTorch DataLoader需要通过IPC通讯,启动容器时需要通过`--shm-size=8G`参数保证DataLoader可以正常工作。这一点对于Native环境也是一样的。
74+
我们在镜像中已经将[官方模型例子](https://github.com/pytorch/examples)克隆后放在`/root/examples`目录下,用户可以进入其中每个模型子目录运行模型。我们同时安装了包括torchvision 0.2.2在内的一系列Python packages。
75+
76+
最后,我们通过`install-client`安装包安装了Orion Client运行时。
77+
78+
### [PyTorch 1.1.0, Python 3.5环境](./client-pytorch-1.1.0-py3)
79+
80+
PyTorch 1.1.0官方提供的`pip`源wheel包里部分组件我们这一版的Orion vGPU软件还不支持,因此我们更改了编译选项编译了精简版本的PyTorch 1.1.0 wheel包(**源代码无修改**
6481

65-
此外,由于我们对PyTorch的支持还在持续开发中,用户需要注意的是:
66-
* 我们还不支持PyTorch通过RDMA网络使用远程GPU资源
67-
* 在使用多卡训练时,需要用GLOO作为后端,而不是默认的NCCL
82+
我们同样从源码开始,使用默认编译选项编译了torchvision 0.3.0版本,打包进镜像。
83+
84+
我们在镜像中已经将[官方模型例子](https://github.com/pytorch/examples)克隆后放在`/root/examples`目录下,用户可以进入其中每个模型子目录运行模型。
85+
86+
最后,我们运行`install-client`安装包安装了Orion Client运行时。
87+
88+
我们在[PyTorch 1.10 Python3.5 镜像](./client-pytorch-1.1.0-py3)中介绍了我们编译PyTorch 1.1.0,TorchVision 0.3.0,以及安装Orion Client Runtime的步骤,用户可以参考。
6889

69-
在我们的[一篇技术博客](../blogposts/pytorch_models.md)里,我们介绍了如何让PyTorch使用多块Orion vGPU在Imagenet数据集上训练Resnet50模型。
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM ubuntu:16.04
2+
MAINTAINER zoumao@virtaitech.com
3+
4+
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
5+
6+
RUN apt update -y &&\
7+
apt install -y libcurl4-openssl-dev &&\
8+
apt install -y python3-dev python3-pip &&\
9+
apt install -y git wget curl bc net-tools &&\
10+
apt install -y lsb-core &&\
11+
apt install -y libjpeg-dev zlib1g-dev libopenmpi-dev libomp-dev &&\
12+
apt clean
13+
14+
# Setup pip source
15+
COPY pip.conf /etc/
16+
17+
WORKDIR /root
18+
19+
# Install PyTorch, torchvision and other python packages
20+
RUN pip3 install torch==1.0.1 -f https://download.pytorch.org/whl/cu90/stable
21+
COPY requirement.txt .
22+
RUN pip3 install -r requirement.txt && rm requirement.txt
23+
24+
# Prepare PyTorch examples
25+
RUN git clone https://github.com/pytorch/examples.git
26+
# Also package the processed MNIST data
27+
# COPY data examples/data
28+
29+
# Install Orion Client runtime
30+
COPY install-client .
31+
RUN chmod +x install-client && ./install-client -q && rm install-client
32+
33+
# Set the num of Orion vGPU each process requests from Orion Controller
34+
ENV ORION_VGPU=1
35+
36+
WORKDIR /root
37+
CMD ["/bin/bash"]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 构建镜像
2+
用户只需将`install-client`安装包放到Dockerfile所在的路径下,即可通过`docker build`命令构建镜像。
3+
4+
安装PyTorch 1.0.1时使用官方提供的wheel packages:
5+
6+
```bash
7+
RUN pip3 install torch==1.0.1 -f https://download.pytorch.org/whl/cu90/stable
8+
```
9+
10+
此外,我们安装了包括torchvision 0.2.2在内的部分Python packages。
11+
12+
# 使用镜像
13+
14+
在我们的[一篇技术博客](../../blogposts/pytorch_models.md)里,我们介绍了如何在容器中运行各种[PyTorch官方模型示例](https://github.com/pytorch/examples)
15+
16+
# 注意事项
17+
18+
* 在使用PyTorch DataLoader加载训练数据时,启动容器时需要设置`--ipc=host`参数保证DataLoader进程之间可以进行IPC。本要求与Orion vGPU软件**无关**,即使用户通过`nvidia-docker`在容器中运行PyTorch也是必须的。
19+
20+
* 目前Orion vGPU软件不支持PyTorch通过RDMA网络使用远程物理GPU资源。用户如果有使用Remote Orion vGPU的需求,需要通过TCP方式。
21+
22+
* 目前Orion vGPU软件不支持PyTorch使用NCCL作为后端进行多卡训练,因此用户需要使用Facebook GLOO作为通讯后端。
23+
24+
25+
具体地,用户可以参考[技术博客](../../blogposts/pytorch_models.md)中介绍PyTorch以GLOO作为多进程通讯后端,从而使用多块Orion vGPU在Imagenet数据集上训练Resnet50模型的例子。
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[global]
2+
index-url=https://pypi.doubanio.com/simple/
3+
trusted-host=pypi.doubanio.com
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pillow
2+
scipy==1.2.0
3+
matplotlib==3.0
4+
pandas
5+
cython
6+
tqdm
7+
contextlib2
8+
lxml
9+
torchvision==0.2.2

dockerfiles/client-pytorch-1.1.0-py3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
如果要构建镜像,用户需要按照下面的步骤从源码编译PyTorch和TorchVision。
1313

14-
## 从源码编译PyTorch 1.1.0的Python 3.5版本
14+
## 从源码编译PyTorch 1.1.0
1515

1616
我们以Ubuntu 16.04环境为例。
1717

dockerfiles/client-tf1.12-base/build-docker-images.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

dockerfiles/client-tf1.12-py2/build-docker-images.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)