<commit_before>PaddlePaddle in Docker Containers
=================================

Docker container is currently the only officially-supported way to
running PaddlePaddle.  This is reasonable as Docker now runs on all
major operating systems including Linux, Mac OS X, and Windows.
Please be aware that you will need to change `Dockers settings
<https://github.com/PaddlePaddle/Paddle/issues/627>`_ to make full use
of your hardware resource on Mac OS X and Windows.


Development Using Docker
------------------------

Developers can work on PaddlePaddle using Docker.  This allows
developers to work on different platforms -- Linux, Mac OS X, and
Windows -- in a consistent way.

1. Build the Development Environment as a Docker Image

   .. code-block:: bash

      git clone --recursive https://github.com/PaddlePaddle/Paddle
      cd Paddle
      docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile .


   Note that by default :code:`docker build` wouldn't import source
   tree into the image and build it.  If we want to do that, we need
   to set a build arg:

   .. code-block:: bash

   docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile --build-arg BUILD_AND_INSTALL=ON .


1. Run the Development Environment

   Once we got the image :code:`paddle:dev`, we can use it to develop
   Paddle by mounting the local source code tree into a container that
   runs the image:

   .. code-block:: bash
   docker run -d -p 2202:22 -v $PWD:/paddle paddle:dev

   This runs a container of the development environment Docker image
   with the local source tree mounted to :code:`/paddle` of the
   container.

   Note that the default entry-point of :code:`paddle:dev` is
   :code:`sshd`, and above :code:`docker run` commands actually starts
   an SSHD server listening on port 2202.  This allows us to log into
   this container with:

   .. code-block:: bash
   ssh root@localhost -p 2202

   Usually, I run above commands on my Mac.  I can also run them on a
   GPU server :code:`xxx.yyy.zzz.www` and ssh from my Mac to it:

   .. code-block:: bash
   my-mac$ ssh root@xxx.yyy.zzz.www -p 2202

1. Build and Install Using the Development Environment

   Once I am in the container, I can use
   :code:`paddle/scripts/docker/build.sh` to build, install, and test
   Paddle:

   .. code-block:: bash
   /paddle/paddle/scripts/docker/build.sh

   This builds everything about Paddle in :code:`/paddle/build`.  And
   we can run unit tests there:

   .. code-block:: bash
   cd /paddle/build
   ctest


CPU-only and GPU Images
-----------------------

For each version of PaddlePaddle, we release 2 Docker images, a
CPU-only one and a CUDA GPU one.  We do so by configuring
`dockerhub.com <https://hub.docker.com/r/paddledev/paddle/>`_
automatically runs the following commands:

.. code-block:: bash

   docker build -t paddle:cpu -f paddle/scripts/docker/Dockerfile .
   docker build -t paddle:gpu -f paddle/scripts/docker/Dockerfile.gpu .


To run the CPU-only image as an interactive container:

.. code-block:: bash<commit_msg>Update code indentation in rst files<commit_after>PaddlePaddle in Docker Containers
=================================

Docker container is currently the only officially-supported way to
running PaddlePaddle.  This is reasonable as Docker now runs on all
major operating systems including Linux, Mac OS X, and Windows.
Please be aware that you will need to change `Dockers settings
<https://github.com/PaddlePaddle/Paddle/issues/627>`_ to make full use
of your hardware resource on Mac OS X and Windows.


Development Using Docker
------------------------

Developers can work on PaddlePaddle using Docker.  This allows
developers to work on different platforms -- Linux, Mac OS X, and
Windows -- in a consistent way.

1. Build the Development Environment as a Docker Image

   .. code-block:: bash

      git clone --recursive https://github.com/PaddlePaddle/Paddle
      cd Paddle
      docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile .


   Note that by default :code:`docker build` wouldn't import source
   tree into the image and build it.  If we want to do that, we need
   to set a build arg:

   .. code-block:: bash

      docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile --build-arg BUILD_AND_INSTALL=ON .


1. Run the Development Environment

   Once we got the image :code:`paddle:dev`, we can use it to develop
   Paddle by mounting the local source code tree into a container that
   runs the image:

   .. code-block:: bash
      docker run -d -p 2202:22 -v $PWD:/paddle paddle:dev

   This runs a container of the development environment Docker image
   with the local source tree mounted to :code:`/paddle` of the
   container.

   Note that the default entry-point of :code:`paddle:dev` is
   :code:`sshd`, and above :code:`docker run` commands actually starts
   an SSHD server listening on port 2202.  This allows us to log into
   this container with:

   .. code-block:: bash
      ssh root@localhost -p 2202

   Usually, I run above commands on my Mac.  I can also run them on a
   GPU server :code:`xxx.yyy.zzz.www` and ssh from my Mac to it:

   .. code-block:: bash
      my-mac$ ssh root@xxx.yyy.zzz.www -p 2202

1. Build and Install Using the Development Environment

   Once I am in the container, I can use
   :code:`paddle/scripts/docker/build.sh` to build, install, and test
   Paddle:

   .. code-block:: bash
      /paddle/paddle/scripts/docker/build.sh

   This builds everything about Paddle in :code:`/paddle/build`.  And
   we can run unit tests there:

   .. code-block:: bash
      cd /paddle/build
      ctest


CPU-only and GPU Images
-----------------------

For each version of PaddlePaddle, we release 2 Docker images, a
CPU-only one and a CUDA GPU one.  We do so by configuring
`dockerhub.com <https://hub.docker.com/r/paddledev/paddle/>`_
automatically runs the following commands:

.. code-block:: bash

   docker build -t paddle:cpu -f paddle/scripts/docker/Dockerfile .
   docker build -t paddle:gpu -f paddle/scripts/docker/Dockerfile.gpu .


To run the CPU-only image as an interactive container:

.. code-block:: bash
{'fraction_non_alphanumeric': 0.10172245693857654, 'fraction_numerical': 0.008124796880077998, 'mean_word_length': 3.046679815910585, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931958', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1739, 'n_words': 780}