-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #553 from andres-fr/main
Fixed Issue #552
- Loading branch information
Showing
3 changed files
with
136 additions
and
12 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
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,76 @@ | ||
Bootstrap: docker | ||
From: nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04 | ||
Stage: spython-base | ||
|
||
%post | ||
# Dockerfile for AlgoPerf environment. | ||
# To build Docker image with only Jax GPU installed: | ||
# docker build -t <image_name> --build-arg framework=jax | ||
# To build Docker image with Pytorch GPU installed: | ||
# docker build -t <image_name> --build-arg framework=pytorch | ||
|
||
# To build Docker image | ||
|
||
# Installing machine packages | ||
echo "Setting up machine" | ||
apt-get update | ||
apt-get install -y curl tar | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 pip wget ffmpeg | ||
apt-get install libtcmalloc-minimal4 | ||
apt-get install unzip | ||
apt-get install pigz | ||
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libtcmalloc_minimal.so.4 | ||
|
||
# Install GCP tools | ||
echo "Setting up gsutil" | ||
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-413.0.0-linux-x86_64.tar.gz | ||
tar -xf google-cloud-cli-413.0.0-linux-x86_64.tar.gz | ||
yes | ./google-cloud-sdk/install.sh | ||
|
||
# Directory setup for input and output | ||
echo "Setting up directories for data and experiment_runs" | ||
mkdir -p data/ | ||
mkdir -p experiment_runs/ | ||
|
||
# Install Algorithmic efficiency repo | ||
echo "Setting up algorithmic_efficiency repo" | ||
branch="main" | ||
framework="both" | ||
git_url=https://github.com/mlcommons/algorithmic-efficiency.git | ||
git clone $git_url && cd /algorithmic-efficiency | ||
cd /algorithmic-efficiency && git checkout $branch | ||
|
||
cd /algorithmic-efficiency && pip install -e '.[full]' | ||
|
||
if [ "$framework" = "jax" ] ; then \ | ||
echo "Installing Jax GPU" \ | ||
&& cd /algorithmic-efficiency \ | ||
&& pip install -e '.[jax_gpu]' -f 'https://storage.googleapis.com/jax-releases/jax_cuda_releases.html' \ | ||
&& pip install -e '.[pytorch_cpu]' -f 'https://download.pytorch.org/whl/torch_stable.html'; \ | ||
elif [ "$framework" = "pytorch" ] ; then \ | ||
echo "Installing Pytorch GPU" \ | ||
&& cd /algorithmic-efficiency \ | ||
&& pip install -e '.[jax_cpu]' \ | ||
&& pip install -e '.[pytorch_gpu]' -f 'https://download.pytorch.org/whl/torch_stable.html'; \ | ||
elif [ "$framework" = "both" ] ; then \ | ||
echo "Installing Jax GPU and Pytorch GPU" \ | ||
&& cd /algorithmic-efficiency \ | ||
&& pip install -e '.[jax_gpu]' -f 'https://storage.googleapis.com/jax-releases/jax_cuda_releases.html' \ | ||
&& pip install -e '.[pytorch_gpu]' -f 'https://download.pytorch.org/whl/torch_stable.html'; \ | ||
else \ | ||
echo "Invalid build-arg $framework: framework should be either jax, pytorch or both." >&2 \ | ||
&& exit 1 ; \ | ||
fi | ||
|
||
cd /algorithmic-efficiency && pip install -e '.[wandb]' | ||
|
||
cd /algorithmic-efficiency && git fetch origin | ||
cd /algorithmic-efficiency && git pull | ||
|
||
# Todo: remove this, this is temporary for developing | ||
chmod a+x /algorithmic-efficiency/docker/scripts/startup.sh | ||
|
||
%runscript | ||
exec bash /algorithmic-efficiency/docker/scripts/startup.sh "$@" | ||
%startscript | ||
exec bash /algorithmic-efficiency/docker/scripts/startup.sh "$@" |
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,48 @@ | ||
""" | ||
This script is a modification of the | ||
``spython recipe Dockerfile &> Singularity.def`` command, implemented here: | ||
github.com/singularityhub/singularity-cli/blob/master/spython/client/recipe.py | ||
It converts the Docker recipe to Singularity, but suppressing any %files | ||
command. Usage example: | ||
python singularity_converter.py -i Dockerfile -o Singularity.def | ||
""" | ||
|
||
import argparse | ||
|
||
from spython.main.parse.parsers import get_parser | ||
from spython.main.parse.writers import get_writer | ||
|
||
# globals | ||
ENTRY_POINT = "/bin/bash" # seems to be a good default | ||
FORCE = False # seems to be a good default | ||
# | ||
parser = argparse.ArgumentParser(description="Custom Singularity converter") | ||
parser.add_argument( | ||
"-i", "--input", type=str, help="Docker input path", default="Dockerfile") | ||
parser.add_argument( | ||
"-o", | ||
"--output", | ||
type=str, | ||
help="Singularity output path", | ||
default="Singularity.def", | ||
) | ||
args = parser.parse_args() | ||
INPUT_DOCKERFILE_PATH = args.input | ||
OUTPUT_SINGULARITY_PATH = args.output | ||
|
||
# create Docker parser and Singularity writer | ||
parser = get_parser("docker") | ||
writer = get_writer("singularity") | ||
|
||
# parse Dockerfile into Singularity and suppress %files commands | ||
recipeParser = parser(INPUT_DOCKERFILE_PATH) | ||
recipeWriter = writer(recipeParser.recipe) | ||
(key,) = recipeParser.recipe.keys() | ||
recipeWriter.recipe[key].files = [] | ||
|
||
# convert to string and save to output file | ||
result = recipeWriter.convert(runscript=ENTRY_POINT, force=FORCE) | ||
with open(OUTPUT_SINGULARITY_PATH, "w") as f: | ||
f.write(result) |