-   Notifications  You must be signed in to change notification settings 
- Fork 5.9k
Add docker build doc #3676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docker build doc #3676
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文部分LGTM。 英文部分请美研的同学再看看。
三个直接放链接的部分,能否改成[标题](链接)的格式呢?
   doc/howto/dev/build_cn.md  Outdated    
 |  | ||
| - 学习 Docker 有多难? | ||
|  | ||
| 理解 Docker 并不难,大概花十分钟看一遍 https://zhuanlan.zhihu.com/p/19902938 即可。这可以帮您省掉花一小时安装和配置各种开发工具,以及切换机器时需要新安装的辛苦。别忘了 PaddlePaddle 更新可能导致需要新的开发工具。更别提简化问题复现带来的好处了。 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
   doc/howto/dev/build_cn.md  Outdated    
 |  | ||
| - 可以并行编译吗? | ||
|  | ||
| 是的。我们的 Docker image 运行一个 Bash 脚本 https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build.sh 。这个脚本调用 `make -j$(nproc)` 来启动和 CPU 核一样多的进程来并行编译。 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
   doc/howto/dev/build_cn.md  Outdated    
 |  | ||
| - Docker on Windows/MacOS? | ||
|  | ||
| Docker 在 Windows 和 MacOS 都可以运行。不过实际上是运行在一个 Linux 虚拟机上。可能需要注意给这个虚拟机多分配一些 CPU 和内存,以保证编译高效。具体做法请参考 https://github.com/PaddlePaddle/Paddle/issues/627 。 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
   doc/howto/dev/build_en.md  Outdated    
 | git clone https://github.com/paddlepaddle/paddle | ||
| ``` | ||
|  | ||
| 2. Install build tools. | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
   doc/howto/dev/build_en.md  Outdated    
 | 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
   doc/howto/dev/build_en.md  Outdated    
 | 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 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about '{source}/build'
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
buildin the source root directory on the local computer,
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| 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? | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great rephrase! Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done.
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| - 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. | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
   doc/howto/dev/build_en.md  Outdated    
 |  | ||
| 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? | 
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point! Done.
| 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. | 
| LGTM | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM++
Fixes #3485
Fixes #3690