Skip to content

Commit e1cdba5

Browse files
[Docker] Add docker image (#856)
* execute 'ldconfig' after /bin/bash automatically * add_dockerhub * refine doc * update base image to paddle official image(test=document_fix)
1 parent 8b9601d commit e1cdba5

File tree

5 files changed

+42
-16
lines changed

5 files changed

+42
-16
lines changed

docker/Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nvcr.io/nvidia/cuda:11.6.2-cudnn8-runtime-ubuntu20.04
1+
FROM paddlepaddle/paddle:latest-dev-cuda11.6-cudnn8.4-trt8.4-gcc82
22

33
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
44
RUN echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
@@ -32,10 +32,10 @@ RUN wget https://mirrors.huaweicloud.com/python/3.9.7/Python-3.9.7.tgz && \
3232
cd .. && rm -rf Python-3.9.7 && rm Python-3.9.7.tgz && \
3333
ln -s /usr/local/bin/python3.9 /usr/local/bin/python
3434

35-
RUN python3 -m pip install --upgrade pip -i https://pypi.douban.com/simple/ && pip install pysdf open3d db-sqlite3 -i https://pypi.douban.com/simple/
35+
RUN python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && pip install pysdf open3d db-sqlite3 -i https://pypi.tuna.tsinghua.edu.cn/simple
3636

3737
# install pymesh and paddle
38-
RUN python3 -m pip install --upgrade pip -i https://pypi.douban.com/simple/ && pip install numpy==1.22.4 -i https://pypi.douban.com/simple/
38+
RUN python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple && pip install "numpy>=1.20.0,<=1.23.1" -i https://pypi.tuna.tsinghua.edu.cn/simple
3939
COPY ./pymesh.tar.xz /src/pymesh.tar.xz
4040

4141
RUN cd /src && \
@@ -50,8 +50,11 @@ ENV PATH="$PATH:/usr/lib/x86_64-linux-gnu/"
5050
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64/:$LD_LIBRARY_PATH"
5151

5252
RUN python3 -m ensurepip --upgrade && \
53-
pip3 config set global.index-url https://pypi.doubanio.com/simple/ && \
53+
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
5454
# ensure paddle install normally
55-
ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.8 /usr/local/cuda/lib64/libcudnn.so && \
56-
ln -s /usr/local/cuda/lib64/libcublas.so.11 /usr/local/cuda/lib64/libcublas.so && \
5755
python3 -m pip install paddlepaddle-gpu==0.0.0.post116 -f https://www.paddlepaddle.org.cn/whl/linux/gpu/develop.html
56+
57+
RUN apt-get update
58+
RUN apt-get install -y -o Acquire::Retries=10 --no-install-recommends openssh-server
59+
60+
RUN echo 'ldconfig' >> /root/.bashrc

docker/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
docker build . -t paddlescience:latest
22

33
if [ -x "$(command -v nvidia-docker)" ]; then
4-
nvidia-docker run --network=host -it paddlescience
4+
nvidia-docker run --name paddlescience_container --network=host -it paddlescience
55
elif [ -x "$(command -v docker)" ]; then
6-
docker run --gpus all --network=host -it paddlescience
6+
docker run --name paddlescience_container --gpus all --network=host -it paddlescience
77
else
88
echo "Docker start failed, please install nvidia-docker or docker(>=19.03) first"
99
fi

docs/zh/install_setup.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,37 @@
44

55
### 1.1 从 docker 镜像启动[可选]
66

7-
如果你对 docker 有一定了解,则可以通过我们提供的 Dockerfile 文件,直接构建出能运行 PaddleScience 的环境。按照下列步骤构建镜像,创建容器并进入容器,以运行 PaddleScience。
7+
=== "从 DockerHub 拉取镜像"
88

9-
1. 克隆 PaddleScience 源码:`git clone https://github.com/PaddlePaddle/PaddleScience.git`
10-
2. 下载 PyMesh 预编译文件压缩包 [pymesh.tar.xz](https://paddle-org.bj.bcebos.com/paddlescience/docker/pymesh.tar.xz),并放置在 `PaddleScience/docker/` 目录下
11-
3.`PaddleScience/docker/` 目录下,执行 `bash run.sh`,等待 docker build 完毕后自动进入环境。如果出现因网络问题导致的 apt 下载报错,则重复执行 `bash run.sh` 直至 build 完成即可
12-
4. 在 docker 环境中,执行 `ldconfig`
9+
``` sh
10+
# pull image
11+
docker pull hydrogensulfate/paddlescience
12+
13+
# create a container named 'paddlescience' based on pulled image
14+
## docker version < 19.03
15+
nvidia-docker run --name paddlescience_container --network=host -it --shm-size 64g hydrogensulfate/paddlescience:latest /bin/bash
16+
17+
## docker version >= 19.03
18+
# docker run --name paddlescience_container --gpus all --network=host -it shm-size 64g hydrogensulfate/paddlescience:latest /bin/bash
19+
```
20+
21+
!!! note
22+
23+
Dockerhub 拉取的镜像**仅**预装了运行 PaddleScience 所需的依赖包,如 pymesh、open3d,**并不包含 PaddleScience**。
24+
因此请在镜像拉取和容器构建完成后,参考 [1.4 安装 PaddleScience](#14-paddlescience) 中的步骤,在容器中安装 PaddleScience。
25+
26+
=== "通过 Dockerfile 构建镜像"
27+
28+
``` sh
29+
git clone https://github.com/PaddlePaddle/PaddleScience.git
30+
cd PaddleScience/docker/
31+
wget -nc https://paddle-org.bj.bcebos.com/paddlescience/docker/pymesh.tar.xz
32+
bash run.sh
33+
```
34+
35+
如果出现因网络问题导致的 docker 构建时 apt 下载报错,则重复执行 `bash run.sh` 直至构建完成。
1336

14-
更多关于 Paddle Docker 的安装和使用,请参考 [Docker 安装](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/fromdocker.html)
37+
更多关于 Paddle Docker 的安装和使用,请参考 [Docker 安装](https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/fromdocker.html)
1538

1639
### 1.2 python 环境安装[可选]
1740

examples/NLS-MB/conf/NLS-MB_rogue_wave.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ EVAL:
6060
eval_with_no_grad: true
6161

6262
INFER:
63-
pretrained_model_path: null
63+
pretrained_model_path: https://paddle-org.bj.bcebos.com/paddlescience/models/NLS-MB/NLS-MB_rogue_wave_pretrained.pdparams
6464
export_path: ./inference/NLS-MB_rogue_wave
6565
pdmodel_path: ${INFER.export_path}.pdmodel
6666
pdpiparams_path: ${INFER.export_path}.pdiparams

examples/NLS-MB/conf/NLS-MB_soliton.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ EVAL:
5959
eval_with_no_grad: true
6060

6161
INFER:
62-
pretrained_model_path: null
62+
pretrained_model_path: https://paddle-org.bj.bcebos.com/paddlescience/models/NLS-MB/NLS-MB_soliton_pretrained.pdparams
6363
export_path: ./inference/NLS-MB_soliton
6464
pdmodel_path: ${INFER.export_path}.pdmodel
6565
pdpiparams_path: ${INFER.export_path}.pdiparams

0 commit comments

Comments
 (0)