Skip to content

Commit

Permalink
update solver docker
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhanqun committed Dec 21, 2023
1 parent 576a9f6 commit 78de59b
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 40 deletions.
52 changes: 52 additions & 0 deletions doc/source/getting-started/SERVER_PRE_README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Start pydyna pre server locally

Check failure on line 1 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L1

[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.
Raw output
{"message": "[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 1, "column": 7}}}, "severity": "ERROR"}

Check failure on line 1 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L1

[Vale.Spelling] Did you really mean 'pre'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'pre'?", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 1, "column": 14}}}, "severity": "ERROR"}
===============================

There are two ways to start the pydyna pre server

Check failure on line 4 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L4

[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.
Raw output
{"message": "[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 4, "column": 33}}}, "severity": "ERROR"}

Check failure on line 4 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L4

[Vale.Spelling] Did you really mean 'pre'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'pre'?", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 4, "column": 40}}}, "severity": "ERROR"}

1.Start server manually

Check warning on line 6 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L6

[Google.Headings] '1.Start server manually' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '1.Start server manually' should use sentence-style capitalization.", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 6, "column": 1}}}, "severity": "WARNING"}
-----------------------

* Run this command in the current folder:

.. code:: console
python kwserver.py
2.Start server automatically

Check warning on line 15 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L15

[Google.Headings] '2.Start server automatically' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '2.Start server automatically' should use sentence-style capitalization.", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 15, "column": 1}}}, "severity": "WARNING"}
----------------------------

Start server on Windows
~~~~~~~~~~~~~~~~~~~~~~~

#. Set environment variable:

.. code:: bash
Variable name: ANSYS_PYDYNA_PRE_SERVER_PATH
variable value: <The file path of this package>
example of variable value: C:\pydyna\ansys-pydyna-pre-server
Start server on Linux
~~~~~~~~~~~~~~~~~~~~~

#. Set environment variable:

.. code:: bash
ANSYS_PYDYNA_PRE_SERVER_PATH=<The file path of this package>
example of variable value: /home/lstc/ansys-pydyna-pre-server
Run an example on the client side
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash
hostname = "localhost"
if len(sys.argv) > 1:
hostname = sys.argv[1]
solution = DynaSolution(hostname)
......
#. The function of DynaSolution() will start the pre server automatically.

Check warning on line 52 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L52

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 52, "column": 35}}}, "severity": "WARNING"}

Check failure on line 52 in doc/source/getting-started/SERVER_PRE_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_PRE_README.rst#L52

[Vale.Spelling] Did you really mean 'pre'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'pre'?", "location": {"path": "doc/source/getting-started/SERVER_PRE_README.rst", "range": {"start": {"line": 52, "column": 50}}}, "severity": "ERROR"}
80 changes: 80 additions & 0 deletions doc/source/getting-started/SERVER_SOLVER_README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Start pydyna solver server locally

Check failure on line 1 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L1

[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.
Raw output
{"message": "[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 1, "column": 7}}}, "severity": "ERROR"}
==================================

Prerequisites
-------------

Start server on Windows
~~~~~~~~~~~~~~~~~~~~~~~

#. If you want to start the server on Windows,please ensure that you have installed the ANSYS locally.

Start server on Linux(Centos7)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#. If you want to start the server on Linux,please ensure that you have installed the openmpi package.

Check failure on line 15 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L15

[Vale.Spelling] Did you really mean 'openmpi'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'openmpi'?", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 15, "column": 87}}}, "severity": "ERROR"}

.. code:: bash
yum install openmpi3 openmpi3-dev
#. set environment variable for openmpi

Check failure on line 21 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L21

[Vale.Spelling] Did you really mean 'openmpi'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'openmpi'?", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 21, "column": 33}}}, "severity": "ERROR"}

.. code:: bash
export LD_LIBRARY_PATH=/usr/lib64/openmpi3/lib:$LD_LIBRARY_PATH
export PATH=/usr/lib64/openmpi3/bin:$PATH
There are two ways to start the pydyna solver server

Check failure on line 29 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L29

[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.
Raw output
{"message": "[Vale.Terms] Use 'PyDYNA' instead of 'pydyna'.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 29, "column": 33}}}, "severity": "ERROR"}
====================================================

1.Start server manually

Check warning on line 32 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L32

[Google.Headings] '1.Start server manually' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '1.Start server manually' should use sentence-style capitalization.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 32, "column": 1}}}, "severity": "WARNING"}
-----------------------

* Run this command in the current folder:

.. code:: console
python server.py
2.Start server automatically

Check warning on line 41 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L41

[Google.Headings] '2.Start server automatically' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] '2.Start server automatically' should use sentence-style capitalization.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 41, "column": 1}}}, "severity": "WARNING"}
----------------------------

Start server on Windows
~~~~~~~~~~~~~~~~~~~~~~~

#. Set environment variable:

.. code:: bash
Variable name: ANSYS_PYDYNA_SOLVER_SERVER_PATH
variable value: <The file path of this package>
example of variable value: C:\pydyna\ansys-pydyna-solver-server
Start server on Linux(Centos7)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#. Set environment variable:

.. code:: bash
ANSYS_PYDYNA_SOLVER_SERVER_PATH=<The file path of this package>
example of variable value: /home/lstc/ansys-pydyna-solver-server
Run an example on the client side
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash
import ansys.dyna.core.solver as solver
hostname = "localhost"
port = "5000"
dyna=solver.DynaSolver(hostname,port) # connect to the server
dyna.push("./output/ball_plate.k") # push an input file
dyna.start_locally(input = "ball_plate.k",nproc=1)
#. The function of solver.DynaSolver() will start the solver server automatically.

Check failure on line 80 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L80

[Google.Spacing] 'r.D' should have one space.
Raw output
{"message": "[Google.Spacing] 'r.D' should have one space.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 80, "column": 25}}}, "severity": "ERROR"}

Check warning on line 80 in doc/source/getting-started/SERVER_SOLVER_README.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/SERVER_SOLVER_README.rst#L80

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "doc/source/getting-started/SERVER_SOLVER_README.rst", "range": {"start": {"line": 80, "column": 40}}}, "severity": "WARNING"}
16 changes: 12 additions & 4 deletions doc/source/getting-started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,23 @@ with these commands:
If you're on Windows with Python 3.8, unzip the wheelhouse archive to a ``wheelhouse``
directory and install PyDYNA using the preceding command.

Install the server
------------------
Currently, PyDYNA server is only supported withing a Docker container.
Future releases support launching the servers directly on local machines as well.
Run PyDYNA Server locally

Check warning on line 83 in doc/source/getting-started/index.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/getting-started/index.rst#L83

[Google.Headings] 'Run PyDYNA Server locally' should use sentence-style capitalization.
Raw output
{"message": "[Google.Headings] 'Run PyDYNA Server locally' should use sentence-style capitalization.", "location": {"path": "doc/source/getting-started/index.rst", "range": {"start": {"line": 83, "column": 1}}}, "severity": "WARNING"}
-------------------------
Launching the servers directly on local machines.

.. include:: ./SERVER_PRE_README.rst

.. include:: ./SERVER_SOLVER_README.rst

Run PyDYNA Server in a Docker container
---------------------------------------
PyDYNA server can be run in a Docker container.

.. include:: ../../../docker/pre/README.rst

.. include:: ../../../docker/solver/README.rst


.. LINKS
.. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/
.. _pydyna_repo: https://github.com/ansys/pydyna/
Expand Down
30 changes: 21 additions & 9 deletions docker/solver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ENV HOME /home/mpirun
ENV LD_LIBRARY_PATH /ansys_inc/lib
ENV LSTC_LICENSE network
ENV LSTC_LICENSE_SERVER license
ENV SSHDIR ${HOME}/.ssh/
ENV SSHDIR ${HOME}/.ssh


RUN groupadd ${USER}
Expand Down Expand Up @@ -66,10 +66,18 @@ CMD ["/usr/sbin/sshd", "-D"]
ENV PATH /opt/openmpi/bin:${PATH}
RUN echo "export PATH=/opt/openmpi/bin:\${PATH}" >> ${HOME}/.bashrc

ADD ssh/config ${SSHDIR}/config
ADD ssh/id_rsa ${SSHDIR}/id_rsa
ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub
ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys
#ADD ssh/config ${SSHDIR}/config
#ADD ssh/id_rsa ${SSHDIR}/id_rsa
#ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub
#ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys
#RUN ssh-keygen -A


RUN ssh-keygen -q -b 2048 -f ${SSHDIR}/id_rsa -N ""
RUN chmod 700 ${SSHDIR} && chmod -R 600 ${SSHDIR}/id_rsa
RUN echo "Host *" > ${SSHDIR}/config
RUN echo " StrictHostKeyChecking no" >> ${SSHDIR}/config
RUN cp ${SSHDIR}/id_rsa.pub ${SSHDIR}/authorized_keys
RUN ssh-keygen -A

RUN chmod -R 600 ${SSHDIR}* && \
Expand All @@ -79,11 +87,15 @@ RUN chown -R ${USER}:${USER} ${HOME}

# Copy the openmpi libraries

RUN mkdir -p /opt
COPY mpi /opt/openmpi
RUN yum install -y unzip
COPY mppdyna_docker_centos7.zip .
RUN unzip -qu mppdyna_docker_centos7.zip && rm mppdyna_docker_centos7.zip
RUN mkdir -p /opt/openmpi
RUN cp -r mpi/* /opt/openmpi
RUN chmod -R 777 /opt/openmpi

# The executable will go in /ansys_inc, and the
# ifort runtime libraries in /ansys_inc/lib

COPY docker_dir /ansys_inc
RUN chmod 755 /ansys_inc/
RUN cp -rpu docker_dir/* /ansys_inc/
RUN chmod -R 777 /ansys_inc/
22 changes: 12 additions & 10 deletions docker/solver/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ Prerequisites
* Download the latest Linux release artifacts for the ``solver`` Docker container:
`mppdyna_docker_centos7.zip <https://github.com/ansys/pydyna/releases/download/v0.4.3/mppdyna_docker_centos7.zip>`_.

* Move this ZIP file to the ``docker/solver`` directory and unzip it in the same directory.
* Move this ZIP file to the ``docker/solver`` directory.

The files in this folder should look similar to this:

.. code:: bash
>>> Dockerfile README.rst do_build docker-compose.yml docker_dir mpi mppdyna_docker_centos7.zip
>>> Dockerfile README.rst docker-compose.yml mppdyna_docker_centos7.zip
* Within docker_dir, there is a file called mppdyna. This file is the executable to run. It can be
any executable (SMP, MPP) or revision and branch. To run a given file, the name shall be changed to
mppdyna and copied inside docker_dir.
Once all prerequisites are met, you can build the Docker image for the ``solver`` service.

Expand All @@ -52,7 +49,7 @@ To build the Docker image for the ``solver`` service, perform these steps:

.. code:: bash
./do_build
docker build -t dyna_solver_v04 .
#. Check that the image has been built successfully by running this command:

Expand All @@ -70,15 +67,20 @@ To build the Docker image for the ``solver`` service, perform these steps:
>>> ...... ...... ............ .............. ......
Run the image as a container
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Start the container from a ``docker-compose.yml`` file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Perform these steps to run the image for the ``solver`` service as a container:
Alternatively, you can start the container for the ``pre`` service from a
``docker-compose.yml`` file.

#. Ensure that Docker Compose has been installed on your computer. If Docker Compose is not
installed, see `Overview of installing Docker Compose <https://docs.docker.com/compose/install/>`_
in the Docker documentation.

#. In the ``docker-compose.yml`` file, replace ``<license_server_name>`` with the correct
license server hosting the LS-DYNA license.

#. Run this Docker command:
#. In your terminal, go to the ``docker/solver`` directory and run this Docker command:

.. code:: bash
Expand Down
15 changes: 0 additions & 15 deletions docker/solver/do_build

This file was deleted.

5 changes: 3 additions & 2 deletions docker/solver/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: "3.3"
name: "dyna"
services:
dyna:
image: dyna_solver_v04
build: ./
networks:
- dyna_internal
volumes:
Expand All @@ -14,7 +15,7 @@ services:
mode: ingress
user: mpirun
environment:
- LSTC_LICENSE_SERVER=<license_server_name>
- LSTC_LICENSE_SERVER=lvrpanda.ansys.com
entrypoint: ["/ansys_inc/server.py","dyna"]
networks:
dyna_internal:

0 comments on commit 78de59b

Please sign in to comment.