-
Notifications
You must be signed in to change notification settings - Fork 220
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
Add support for Intel MPI #389
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
set_intel_vars=/opt/intel/oneapi/setvars.sh | ||
if [ -f $set_intel_vars ]; then | ||
source $set_intel_vars | ||
fi | ||
|
||
function resolve_host() { | ||
host="$1" | ||
check="nslookup $host" | ||
max_retry=5 | ||
counter=0 | ||
backoff=0.1 | ||
until $check > /dev/null | ||
do | ||
if [ $counter -eq $max_retry ]; then | ||
echo "Couldn't resolve $host" | ||
return | ||
fi | ||
sleep $backoff | ||
echo "Couldn't resolve $host... Retrying" | ||
((counter++)) | ||
backoff=$(echo - | awk "{print $backoff + $backoff}") | ||
done | ||
echo "Resolved $host" | ||
} | ||
|
||
if [ "$K_MPI_JOB_ROLE" == "launcher" ]; then | ||
resolve_host "$HOSTNAME" | ||
cat /etc/mpi/hostfile | while read host | ||
do | ||
resolve_host $host | ||
done | ||
fi | ||
|
||
exec "$@" |
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,57 @@ | ||
FROM bash AS downloader | ||
|
||
RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB -O key.PUB | ||
|
||
|
||
FROM debian:buster as base | ||
|
||
COPY --from=downloader key.PUB /tmp/key.PUB | ||
|
||
# Install Intel oneAPI keys. | ||
RUN apt update \ | ||
&& apt install -y --no-install-recommends gnupg2 ca-certificates \ | ||
&& apt-key add /tmp/key.PUB \ | ||
&& rm /tmp/key.PUB \ | ||
&& echo "deb https://apt.repos.intel.com/oneapi all main" | tee /etc/apt/sources.list.d/oneAPI.list \ | ||
&& apt remove -y gnupg2 ca-certificates \ | ||
&& apt autoremove -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
FROM base as builder | ||
|
||
RUN apt update \ | ||
&& apt install -y --no-install-recommends \ | ||
libstdc++-8-dev binutils \ | ||
intel-oneapi-compiler-dpcpp-cpp \ | ||
intel-oneapi-mpi-devel \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV I_MPI_CC=clang I_MPI_CXX=clang++ | ||
COPY pi.cc /src/pi.cc | ||
RUN bash -c "source /opt/intel/oneapi/setvars.sh && mpicxx /src/pi.cc -o /pi" | ||
|
||
|
||
FROM base | ||
|
||
RUN apt update \ | ||
&& apt install -y --no-install-recommends \ | ||
openssh-server \ | ||
openssh-client \ | ||
dnsutils \ | ||
intel-oneapi-mpi \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Add priviledge separation directoy to run sshd as root. | ||
RUN mkdir -p /var/run/sshd | ||
# Add capability to run sshd as non-root. | ||
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/sshd | ||
|
||
RUN useradd -m mpiuser | ||
WORKDIR /home/mpiuser | ||
COPY intel-entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
COPY --chown=mpiuser sshd_config .sshd_config | ||
RUN sed -i 's/[ #]\(.*StrictHostKeyChecking \).*/ \1no/g' /etc/ssh/ssh_config | ||
|
||
COPY --from=builder /pi /home/mpiuser/pi |
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,52 @@ | ||
apiVersion: kubeflow.org/v2beta1 | ||
kind: MPIJob | ||
metadata: | ||
name: pi | ||
spec: | ||
slotsPerWorker: 1 | ||
cleanPodPolicy: Running | ||
sshAuthMountPath: /home/mpiuser/.ssh | ||
mpiImplementation: Intel | ||
mpiReplicaSpecs: | ||
Launcher: | ||
replicas: 1 | ||
template: | ||
spec: | ||
containers: | ||
- image: docker.io/kubeflow/mpi-pi:intel | ||
imagePullPolicy: Always | ||
name: mpi-launcher | ||
securityContext: | ||
runAsUser: 1000 | ||
args: | ||
- mpirun | ||
- -n | ||
- "2" | ||
- /home/mpiuser/pi | ||
resources: | ||
limits: | ||
cpu: 1 | ||
memory: 1Gi | ||
Worker: | ||
replicas: 2 | ||
template: | ||
spec: | ||
containers: | ||
- image: docker.io/kubeflow/mpi-pi:intel | ||
imagePullPolicy: Always | ||
name: mpi-worker | ||
securityContext: | ||
runAsUser: 1000 | ||
capabilities: | ||
add: | ||
- NET_BIND_SERVICE | ||
command: | ||
args: | ||
- /usr/sbin/sshd | ||
- -De | ||
- -f | ||
- /home/mpiuser/.sshd_config | ||
resources: | ||
limits: | ||
cpu: 1 | ||
memory: 1Gi |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this still can cause issues sometimes, i.e. sometimes there is a window when the launcher is able to resolve it's own hostname, but workers are not. This happens to me usually in the second run if I schedule two runs in a row.
It should be fine though, since this is only an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that was the problem?
When I only had the check for the launcher, I was getting flaky startups. Now that I have checks for all the workers as well, the job starts every time. I couldn't really debug what was going on with just the check for the launcher, as Hydra doesn't log the output of the ssh calls :(