-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new test script; updated container files
- Loading branch information
Showing
4 changed files
with
50 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FROM ubuntu:24.04 | ||
|
||
RUN mkdir -p /src | ||
WORKDIR /src | ||
|
||
RUN mkdir -p /src | ||
RUN apt-get -y clean && apt -y update && apt install -y apt-utils && apt -y upgrade | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive \ | ||
|
@@ -11,7 +11,6 @@ RUN DEBIAN_FRONTEND=noninteractive \ | |
gfortran \ | ||
wget \ | ||
git \ | ||
pkg-config \ | ||
libbz2-dev \ | ||
libgsl-dev \ | ||
libssl-dev \ | ||
|
@@ -25,7 +24,7 @@ RUN DEBIAN_FRONTEND=noninteractive \ | |
python3-pip \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
ARG mpich=4.1.1 | ||
ARG mpich=3.4.3 | ||
ARG mpich_prefix=mpich-$mpich | ||
|
||
ENV FFLAGS="-fallow-argument-mismatch" \ | ||
|
@@ -34,8 +33,8 @@ ENV FFLAGS="-fallow-argument-mismatch" \ | |
RUN wget --no-check-certificate -nv https://www.mpich.org/static/downloads/$mpich/$mpich_prefix.tar.gz \ | ||
&& tar xvzf $mpich_prefix.tar.gz \ | ||
&& cd $mpich_prefix \ | ||
&& ./configure \ | ||
&& make -j 4 \ | ||
&& ./configure --with-device=ch4:ofi \ | ||
&& make -j 16 \ | ||
&& make install \ | ||
&& make clean \ | ||
&& cd .. \ | ||
|
@@ -44,8 +43,11 @@ RUN wget --no-check-certificate -nv https://www.mpich.org/static/downloads/$mpic | |
|
||
RUN /sbin/ldconfig | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
ENTRYPOINT ["/bin/bash", "-c"] | ||
CMD ["/bin/bash"] | ||
ENV PIP_ROOT_USER_ACTION=ignore | ||
|
||
RUN ln -s "$(which python3)" /usr/bin/python | ||
|
||
RUN pip3 install --break-system-packages mpi4py \ | ||
&& rm -Rf /root/.cache/pip | ||
|
||
LABEL Maintainer="John Moustakas [email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,29 @@ | |
# podman-hpc build --tag desihub/fastspecfit-test --file ./Containerfile-test . | ||
# podman-hpc migrate desihub/fastspecfit-test | ||
# podman-hpc run --rm -it desihub/fastspecfit-test /bin/bash | ||
# srun --ntasks=2 podman-hpc run --rm --mpi --entrypoint= -it desihub/fastspecfit-test /usr/local/bin/test-mpi-fastspecfit --mp=4 | ||
# srun --ntasks=2 podman-hpc run --rm --mpi -it desihub/fastspecfit-test /usr/local/bin/test-mpi-fastspecfit --mp=4 | ||
|
||
FROM desihub/fastspecfit-base:1.0 | ||
|
||
WORKDIR /src | ||
|
||
RUN ln -s "$(which python3)" /usr/bin/python | ||
|
||
ENV PIP_ROOT_USER_ACTION=ignore | ||
|
||
RUN for x in \ | ||
wheel \ | ||
setuptools \ | ||
pytest \ | ||
numpy \ | ||
# numpy \ | ||
numba \ | ||
mpi4py \ | ||
ipython \ | ||
ipykernel \ | ||
; do pip3 install --break-system-packages $x; done \ | ||
&& rm -Rf /root/.cache/pip | ||
|
||
COPY test-mpipool /usr/local/bin/test-mpipool | ||
RUN chmod +x /usr/local/bin/test-mpipool | ||
|
||
COPY test-mpi-fastspecfit /usr/local/bin/test-mpi-fastspecfit | ||
RUN chmod +x /usr/local/bin/test-mpi-fastspecfit | ||
|
||
# set prompt and default shell | ||
SHELL ["/bin/bash", "-c"] | ||
ENTRYPOINT ["/bin/bash", "-c"] | ||
CMD ["/bin/bash"] | ||
|
||
LABEL Maintainer="John Moustakas [email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
|
||
from mpi4py.futures import MPIPoolExecutor | ||
import numpy as np | ||
|
||
def calculate_pi(n): | ||
"""Calculate Pi using Monte Carlo method.""" | ||
x = np.random.rand(n) | ||
y = np.random.rand(n) | ||
inside_circle = (x**2 + y**2) <= 1 | ||
return 4 * np.sum(inside_circle) / n | ||
|
||
if __name__ == "__main__": | ||
mp = 16 | ||
n_points = 100000 | ||
with MPIPoolExecutor(mp) as P: | ||
chunk_size = n_points // mp | ||
|
||
results = P.map(calculate_pi, [chunk_size] * mp) | ||
pi_approx = np.mean(list(results)) | ||
|
||
if P.is_master(): | ||
print(f"Approximation of pi: {pi_approx}") |