Skip to content
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

Updated Docker image #958

Merged
merged 12 commits into from
Dec 18, 2024
1 change: 1 addition & 0 deletions doc/changelog.d/958.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated Docker image
164 changes: 164 additions & 0 deletions doc/source/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,167 @@ To launch PyPrimeMesh, use this code:
with prime.launch_prime() as prime_client:
model = prime_client.model

Launching PyPrimeMesh through docker
------------------------------------

Ansys Prime Server is capable of being launched through docker.
Docker is an open platform for developing, shipping, and running apps in a containerized way.
Containers are standard units of software that package the code and all its dependencies.
Hence, the app runs quickly and reliably from one computing environment to another.

Ansys Prime Server can be built as a Linux Docker container.
Hence, you should have a linux machine to run the Ansys Prime Server.

Docker for Linux containers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To run the Linux Docker container for the Ansys Prime Server,
ensure that you follow these steps when installing the Docker:

1. Install `Docker Engine <https://docs.docker.com/engine/install/rhel/>`_.

2. Restart your machine and start Docker Engine after completing the installation.

Your Docker engine supports running Linux Docker containers, you can build or install the Ansys Prime Server image.

.. note::
Ansys Prime Server uses Intel MPI library for performing meshing operations. Intel MPI library requires NUMA support.
Docker desktop allows to run linux containers on windows using WSL. Existing Linux distributions used for WSL do not typically support NUMA.
It is expected that a custom Linux distribution would be required for WSL to run the Ansys Prime Server container to support NUMA.
Ansys does not recommend you to run the Ansys Prime Server image without NUMA support.

Build or install the Ansys Prime Server image
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can install the Ansys Prime Server image in the following ways:

• Download it from the GitHub Container Registry.

• Build the Ansys Prime Server Linux container.


GitHub container registry
^^^^^^^^^^^^^^^^^^^^^^^^^

.. note::
You should have write access to the repository or should be a members of the Ansys organization.

After installing Docker on your machine, follow these steps to download the Linux Docker container
for the Ansys Prime Server and install this image.

1. Download the Docker image from the `PyPrimeMesh repository <https://github.com/ansys/pyprimemesh>`_ on GitHub using your GitHub credentials.
2. Use a GitHub personal access token with permission for reading packages to authorize Docker to access the PyPrimeMesh repository. For more information, see `Managing your personal access tokens <https://docs.github.com/en/authentication/keeping-your-account-and-data- secure/managing-your-personal-access-tokens>`_ in the GitHub documentation.
3. Save the token to a file using this command:

.. code-block:: pycon

echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX > GH_TOKEN.txt

4. Authorize Docker to access the repository and run the commands for your OS.

**Linux:**

.. code-block:: pycon

setenv GH_USERNAME <your_github_username>
cat GH_TOKEN.txt | docker login ghcr.io -u $GH_USERNAME --password-stdin

5. Pull the Ansys Prime Server locally using Docker using the following command:

.. code-block:: pycon

docker pull ghcr.io/ansys/prime:25.1.0


Build the Ansys Prime Server linux container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can build the Ansys Prime Server Docker containers from the PyPrimeMesh repository docker folder.
The docker folder has the linux/Dockerfile that builds the Linux-based Docker image.

.. note::
Ansys Prime Server does not support building windows-based docker images.

You can build the docker image file as follows:

• **Build from available Ansys installation**: Builds the Docker image using the Ansys installation available in the machine where the Docker image is being built.

Prerequisites
''''''''''''''

Ensure that Docker is installed in your machine. If you do not have Docker available, see :ref:`Docker for Linux containers <Docker for Linux containers>`.


Build from available Ansys installation
''''''''''''''''''''''''''''''''''''''''

To build your own image from your Ansys installation, follow these instructions:

1. Go to the Docker folder in your local PyPrimeMesh repository.

2. Execute the script with the following command (no specific location needed):

.. code-block:: pycon

python build_docker_linux.py <ANSYS_INSTALLATION_PATH>

For example,

.. code-block:: pycon

$AWP_ROOT251/commonfiles/CPython/3_10/linx64/Release/python/bin/python build_docker_linux.py $AWP_ROOT251

3. Check that the image has been created successfully.

You can view the docker image created with latest tag as follows:

.. figure:: ../images/docker_image.png
:width: 800pt
:align: center

Launch the Ansys Prime Server
''''''''''''''''''''''''''''''

Ansys Prime Server can be launched using the PyPrimeMesh launcher.
You should set the following mandatory environment variable for launching the Ansys Prime Server:

- PYPRIMEMESH_LAUNCH_CONTAINER: Launches the Ansys Prime Server form the PyPrimeMesh container.

- PYPRIMEMESH_IMAGE_TAG: Latest version of the Ansys Prime Server docker image.

- ANSYSLMD_LICENSE_FILE: License server required for launching the Ansys Prime Server.

Setting the environment variable
'''''''''''''''''''''''''''''''''

Define the following general environment variables prior to using the Ansys Prime Server launcher.

**Linux**

.. code-block:: pycon

export PYPRIMEMESH_LAUNCH_CONTAINER=1
export PYPRIMEMESH_IMAGE_TAG=<latest>
export ANSYSLMD_LICENSE_FILE=<valid license server>

.. note::
Docker image creation is supported from 2025 R1 version.

Launching Ansys Prime Server
''''''''''''''''''''''''''''''

Ansys Prime Server can be launched as follows:

.. code-block:: pycon

>>> from ansys.meshing import prime
>>> client = prime.launch_prime()
>>> model = client.model









Binary file added doc/source/images/docker_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions doc/styles/config/vocabularies/ANSYS/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ignore_self_proximity
IGA
[Ii]sogeometric
JTOpen
[Ll]inux
[Ll]ucid
Material Point Manager
[Mm]eshedgeodesic
Expand Down
15 changes: 15 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Create your own Ansys Prime Server Docker container
===================================================

To learn how to build your own Ansys Server Docker container, see
`Guide to building the Linux Docker container <https://prime.docs.pyansys.com/version/dev/getting_started/index.html>`_.

If you have your own Ansys installation, you can build a Docker container that uses your installation.

To do this, download the Python script `build_docker_linux.py <https://github.com/ansys/pyprimemesh/blob/main/docker/build_docker_linux.py>`_ and run it from the command line:

.. code-block:: pycon

python build_docker_linux.py

If you have any problems, open a `GitHub Issue <https://github.com/ansys/pyprimemesh/issues>`_.
Loading