Skip to content

Conversation

@wangkuiyi
Copy link
Collaborator

@wangkuiyi wangkuiyi commented Aug 25, 2017

Fixes #3485
Fixes #3690

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中文部分LGTM。 英文部分请美研的同学再看看。

三个直接放链接的部分,能否改成[标题](链接)的格式呢?


- 学习 Docker 有多难?

理解 Docker 并不难,大概花十分钟看一遍 https://zhuanlan.zhihu.com/p/19902938 即可。这可以帮您省掉花一小时安装和配置各种开发工具,以及切换机器时需要新安装的辛苦。别忘了 PaddlePaddle 更新可能导致需要新的开发工具。更别提简化问题复现带来的好处了。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


- 可以并行编译吗?

是的。我们的 Docker image 运行一个 Bash 脚本 https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build.sh 。这个脚本调用 `make -j$(nproc)` 来启动和 CPU 核一样多的进程来并行编译。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


- Docker on Windows/MacOS?

Docker 在 Windows 和 MacOS 都可以运行。不过实际上是运行在一个 Linux 虚拟机上。可能需要注意给这个虚拟机多分配一些 CPU 和内存,以保证编译高效。具体做法请参考 https://github.com/PaddlePaddle/Paddle/issues/627 。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

git clone https://github.com/paddlepaddle/paddle
```

2. Install build tools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be clear if we call this step as: Create docker image for building Paddlepaddle binary

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. A computer -- Linux, BSD, Windows, MacOS, and
1. Docker.

Nothing else. Not even Python and GCC, because you can install all build tools into a Docker image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add bit more explanation: think the docker container as a standalone factory, it takes paddlepaddle source code and produce paddlepaddle binary. Developer plays the role of a regular consumer who doesn't need to know any detail of the factory, and just use/test the product of the factory.

Copy link
Collaborator Author

@wangkuiyi wangkuiyi Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that it is intractable to explain Docker clearly enough in this document, so I have a hyperlink later pointing to an official Docker document. Also, I added

We run all the tools by running this image.

docker run -v $PWD:/paddle paddle:dev
```

This builds a CUDA-enabled version and writes all binary outputs to directory `./build` of the local computer, other than the Docker container. If we want to build only the CPU part, we can type
Copy link
Contributor

@putcn putcn Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about '{source}/build'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact is that all output binary files are in the build directory under the source code root directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed to

to the sub-directory build in the source root directory on the local computer,


- Docker or virtual machine?

Some people compare Docker with VMs, but Docker doesn't virtualize any hardware, and it doesn't run a guest OS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which means there is no compromise on performance.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! Done.


- Why Docker?

Using a Docker image of build tools standardize the building environment, and easier for others to reproduce your problem, if there is any, and help.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a Docker image of build tools standardize the building environment, which makes it easier for others to reproduce your problem and easier to help.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Done.


Also, some build tools don't run on Windows or Mac or BSD, but Docker runs almost everywhere, so developers can use whatever computer they want.

- Can I don't use Docker?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I choose not to use Docker?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Done.


- Can I don't use Docker?

Sure, you don't have to install build tools into a Docker image; instead, you can install them onto your local computer. This document exists because Docker would make the development way easier.
Copy link
Contributor

@putcn putcn Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can install them into your local computer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


- How difficult is it to learn Docker?

It takes you ten minutes to read https://docs.docker.com/get-started/ and saves you more than one hour to install all required build tools, configure them, and upgrade them when new versions of PaddlePaddle require some new tools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It takes you ten minutes to read https://docs.docker.com/get-started/ and saves you more than one hour to install all required build tools, configure them, especially when new versions of PaddlePaddle require some new tools. Not even to mention the time saved when other people trying to reproduce the issue you have.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great rephrase! Done.


- Docker requires sudo

An owner of a computer has the administrative privilege, a.k.a., sudo. If you use a shared computer for development, please ask the administrator to install and configure Docker. We will do our best to support rkt, another container technology that doesn't require sudo.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An owner of a computer has the administrative privilege, a.k.a., sudo, and Docker requires this privilege to work properly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

If we used `WITH_GPU=OFF` at build time, it generates only CPU-based unit tests, and we don't need nvidia-docker to run them. We can just run

```bash
docker run -v $PWD:/paddle paddle:dev bash -c "cd /paddle/build; ctest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks this document is majorly for Docker muggles, do we need to add some explanations to all the commands and parameters used above?

Copy link
Collaborator Author

@wangkuiyi wangkuiyi Aug 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Done.


- Does Docker do parallel building?

Our building Docker image runs a Bash script https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build.sh, which calls `make -j$(nproc)` to starts as many processes as the number of your processors.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to starts as many processes as the number of your CPU cores.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Our building Docker image runs a Bash script https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build.sh, which calls `make -j$(nproc)` to starts as many processes as the number of your processors.

- Docker on Windows/MacOS?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to group "Docker requires sudo" section and "Docker on Windows/Mac" in to "Some Gotchas" or "trouble shooting" section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! Done.

@putcn
Copy link
Contributor

putcn commented Aug 25, 2017

just followed the instructions to have a trial run on the CPU version, looks all command works as expected, except the process stuck at the memory unit test, I might need to adjust Docker's memory setting.

@putcn
Copy link
Contributor

putcn commented Aug 25, 2017

LGTM

@putcn putcn closed this Aug 25, 2017
@putcn putcn reopened this Aug 25, 2017
putcn
putcn previously approved these changes Aug 25, 2017
Copy link
Contributor

@putcn putcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@putcn
Copy link
Contributor

putcn commented Aug 25, 2017

Copy link
Contributor

@dzhwinter dzhwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM++

@wangkuiyi wangkuiyi merged commit 111812f into PaddlePaddle:develop Aug 26, 2017
heavengate pushed a commit to heavengate/Paddle that referenced this pull request Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants