Skip to content

Commit 7050bad

Browse files
authored
update solver docker (#344)
1 parent 576a9f6 commit 7050bad

File tree

7 files changed

+180
-40
lines changed

7 files changed

+180
-40
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Start PyDYNA preprocessing server locally
2+
=========================================
3+
4+
There are two ways to start the PyDYNA preprocessing server
5+
6+
1.Start server manually
7+
-----------------------
8+
9+
* Run this command in the current folder:
10+
11+
.. code:: console
12+
13+
python kwserver.py
14+
15+
2.Start server automatically
16+
----------------------------
17+
18+
Start server on Windows
19+
~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
#. Set environment variable:
22+
23+
.. code:: bash
24+
25+
Variable name: ANSYS_PYDYNA_PRE_SERVER_PATH
26+
variable value: <The file path of this package>
27+
28+
example of variable value: C:\pydyna\ansys-pydyna-pre-server
29+
30+
Start server on Linux
31+
~~~~~~~~~~~~~~~~~~~~~
32+
33+
#. Set environment variable:
34+
35+
.. code:: bash
36+
37+
ANSYS_PYDYNA_PRE_SERVER_PATH=<The file path of this package>
38+
39+
example of variable value: /home/lstc/ansys-pydyna-pre-server
40+
41+
Run an example on the client side
42+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43+
44+
.. code:: bash
45+
46+
hostname = "localhost"
47+
if len(sys.argv) > 1:
48+
hostname = sys.argv[1]
49+
solution = DynaSolution(hostname)
50+
......
51+
52+
#. The function of DynaSolution() can start the preprocessing server automatically.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
Start PyDYNA solver server locally
2+
==================================
3+
4+
Prerequisites
5+
-------------
6+
7+
Start server on Windows
8+
~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
#. If you want to start the server on Windows,please ensure that you have installed the ANSYS locally.
11+
12+
Start server on Linux(Centos7)
13+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
15+
#. If you want to start the server on Linux,please ensure that you have installed the Open MPI package.
16+
17+
.. code:: bash
18+
19+
yum install openmpi3 openmpi3-dev
20+
21+
#. set environment variable for Open MPI
22+
23+
.. code:: bash
24+
25+
export LD_LIBRARY_PATH=/usr/lib64/openmpi3/lib:$LD_LIBRARY_PATH
26+
export PATH=/usr/lib64/openmpi3/bin:$PATH
27+
28+
29+
There are two ways to start the PyDYNA solver server
30+
====================================================
31+
32+
1.Start server manually
33+
-----------------------
34+
35+
* Run this command in the current folder:
36+
37+
.. code:: console
38+
39+
python server.py
40+
41+
2.Start Server Automatically
42+
----------------------------
43+
44+
Start Server On Windows
45+
~~~~~~~~~~~~~~~~~~~~~~~
46+
47+
#. Set environment variable:
48+
49+
.. code:: bash
50+
51+
Variable name: ANSYS_PYDYNA_SOLVER_SERVER_PATH
52+
variable value: <The file path of this package>
53+
54+
example of variable value: C:\pydyna\ansys-pydyna-solver-server
55+
56+
Start Server on Linux(Centos7)
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
59+
#. Set environment variable:
60+
61+
.. code:: bash
62+
63+
ANSYS_PYDYNA_SOLVER_SERVER_PATH=<The file path of this package>
64+
65+
example of variable value: /home/lstc/ansys-pydyna-solver-server
66+
67+
Run an example on the client side
68+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69+
70+
.. code:: bash
71+
72+
import ansys.dyna.core.solver as solver
73+
74+
hostname = "localhost"
75+
port = "5000"
76+
dyna=solver.DynaSolver(hostname,port) # connect to the server
77+
dyna.push("./output/ball_plate.k") # push an input file
78+
dyna.start_locally(input = "ball_plate.k",nproc=1)
79+
80+
#. The function of DynaSolver() can start the solver server automatically.

doc/source/getting-started/index.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,23 @@ with these commands:
8080
If you're on Windows with Python 3.8, unzip the wheelhouse archive to a ``wheelhouse``
8181
directory and install PyDYNA using the preceding command.
8282

83-
Install the server
84-
------------------
85-
Currently, PyDYNA server is only supported withing a Docker container.
86-
Future releases support launching the servers directly on local machines as well.
83+
Run PyDYNA Server locally
84+
-------------------------
85+
Launching the servers directly on local machines.
86+
87+
.. include:: ./SERVER_PRE_README.rst
88+
89+
.. include:: ./SERVER_SOLVER_README.rst
90+
91+
Run PyDYNA Server in a Docker container
92+
---------------------------------------
93+
PyDYNA server can be run in a Docker container.
8794

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

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

99+
92100
.. LINKS
93101
.. _pydyna_pypi: https://pypi.org/projects/ansys-dyna-core/
94102
.. _pydyna_repo: https://github.com/ansys/pydyna/

docker/solver/Dockerfile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ENV HOME /home/mpirun
2424
ENV LD_LIBRARY_PATH /ansys_inc/lib
2525
ENV LSTC_LICENSE network
2626
ENV LSTC_LICENSE_SERVER license
27-
ENV SSHDIR ${HOME}/.ssh/
27+
ENV SSHDIR ${HOME}/.ssh
2828

2929

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

69-
ADD ssh/config ${SSHDIR}/config
70-
ADD ssh/id_rsa ${SSHDIR}/id_rsa
71-
ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub
72-
ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys
69+
#ADD ssh/config ${SSHDIR}/config
70+
#ADD ssh/id_rsa ${SSHDIR}/id_rsa
71+
#ADD ssh/id_rsa.pub ${SSHDIR}/id_rsa.pub
72+
#ADD ssh/id_rsa.pub ${SSHDIR}/authorized_keys
73+
#RUN ssh-keygen -A
74+
75+
76+
RUN ssh-keygen -q -b 2048 -f ${SSHDIR}/id_rsa -N ""
77+
RUN chmod 700 ${SSHDIR} && chmod -R 600 ${SSHDIR}/id_rsa
78+
RUN echo "Host *" > ${SSHDIR}/config
79+
RUN echo " StrictHostKeyChecking no" >> ${SSHDIR}/config
80+
RUN cp ${SSHDIR}/id_rsa.pub ${SSHDIR}/authorized_keys
7381
RUN ssh-keygen -A
7482

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

8088
# Copy the openmpi libraries
8189

82-
RUN mkdir -p /opt
83-
COPY mpi /opt/openmpi
90+
RUN yum install -y unzip
91+
COPY mppdyna_docker_centos7.zip .
92+
RUN unzip -qu mppdyna_docker_centos7.zip && rm mppdyna_docker_centos7.zip
93+
RUN mkdir -p /opt/openmpi
94+
RUN cp -r mpi/* /opt/openmpi
95+
RUN chmod -R 777 /opt/openmpi
8496

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

88-
COPY docker_dir /ansys_inc
89-
RUN chmod 755 /ansys_inc/
100+
RUN cp -rpu docker_dir/* /ansys_inc/
101+
RUN chmod -R 777 /ansys_inc/

docker/solver/README.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@ Prerequisites
2727
* Download the latest Linux release artifacts for the ``solver`` Docker container:
2828
`mppdyna_docker_centos7.zip <https://github.com/ansys/pydyna/releases/download/v0.4.3/mppdyna_docker_centos7.zip>`_.
2929

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

3232
The files in this folder should look similar to this:
3333

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

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

5350
.. code:: bash
5451
55-
./do_build
52+
docker build -t dyna_solver_v04 .
5653
5754
#. Check that the image has been built successfully by running this command:
5855

@@ -70,15 +67,20 @@ To build the Docker image for the ``solver`` service, perform these steps:
7067
>>> ...... ...... ............ .............. ......
7168
7269
73-
Run the image as a container
74-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70+
Start the container from a ``docker-compose.yml`` file
71+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7572

76-
Perform these steps to run the image for the ``solver`` service as a container:
73+
Alternatively, you can start the container for the ``pre`` service from a
74+
``docker-compose.yml`` file.
75+
76+
#. Ensure that Docker Compose has been installed on your computer. If Docker Compose is not
77+
installed, see `Overview of installing Docker Compose <https://docs.docker.com/compose/install/>`_
78+
in the Docker documentation.
7779

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

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

8385
.. code:: bash
8486

docker/solver/do_build

Lines changed: 0 additions & 15 deletions
This file was deleted.

docker/solver/docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
version: "3.3"
2+
name: "dyna"
23
services:
34
dyna:
4-
image: dyna_solver_v04
5+
build: ./
56
networks:
67
- dyna_internal
78
volumes:
@@ -14,7 +15,7 @@ services:
1415
mode: ingress
1516
user: mpirun
1617
environment:
17-
- LSTC_LICENSE_SERVER=<license_server_name>
18+
- LSTC_LICENSE_SERVER=lvrpanda.ansys.com
1819
entrypoint: ["/ansys_inc/server.py","dyna"]
1920
networks:
2021
dyna_internal:

0 commit comments

Comments
 (0)