-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Jupyterhub blueprint updates for GPU and Neuron
- Loading branch information
Showing
43 changed files
with
2,448 additions
and
892 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
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 @@ | ||
#!/bin/bash | ||
|
||
# Set the AWS region and the name of the ECR repository | ||
|
||
REGION=us-west-2 | ||
ECR_REPO_NAME=jupyterhub-pytorch-neuron-pytorch | ||
DOCKER_FILE=docker/jupyterhub-pytorch-neuron-pytorch.Dockerfile | ||
|
||
# Check if the ECR repository exists | ||
if aws ecr describe-repositories --repository-names "$ECR_REPO_NAME" --region "$REGION" >/dev/null 2>&1; then | ||
echo "ECR repository '$ECR_REPO_NAME' already exists." | ||
|
||
# Get the ECR_REPO_URI for the existing repository | ||
ECR_REPO_URI=$(aws ecr describe-repositories --repository-name "$ECR_REPO_NAME" --query 'repositories[0].repositoryUri' --region "$REGION" --output text) | ||
echo "Repository URL: $ECR_REPO_URI" | ||
else | ||
# Create a new ECR repository with the specified name and region | ||
aws ecr create-repository --repository-name "$ECR_REPO_NAME" --region "$REGION" | ||
|
||
# Retrieve the URL of the newly created ECR repository | ||
ECR_REPO_URI=$(aws ecr describe-repositories --repository-name "$ECR_REPO_NAME" --query 'repositories[0].repositoryUri' --region "$REGION" --output text) | ||
echo "Repository URL: $ECR_REPO_URI" | ||
fi | ||
|
||
# Log in to Amazon ECR using docker | ||
echo -e "Logging in to Amazon ECR..." | ||
aws ecr get-login-password --region "$REGION" | docker login --username AWS --password-stdin "$ECR_REPO_URI" | ||
|
||
# Build the docker image using the provided jupyterhub-pytorch-neuron.Dockerfile and tag it with the ECR repository URI | ||
echo -e "Building, tagging and pushing docker image... $ECR_REPO_URI:latest" | ||
# docker build -f docker/jupyterhub-pytorch-neuron.Dockerfile-jupterhub-inferentia-pytorch -t "$ECR_REPO_URI:latest" . | ||
docker buildx build --push --tag "$ECR_REPO_URI:latest" -o type=image --platform=linux/amd64 -f $DOCKER_FILE . | ||
|
||
# Wait for 5 seconds | ||
sleep 5 | ||
echo -e "Sleeping for 5 seconds..." |
34 changes: 34 additions & 0 deletions
34
ai-ml/jupyterhub/examples/docker/jupyterhub-pytorch-neuron.Dockerfile
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,34 @@ | ||
# Use the Jupyter base notebook with Python 3.10 as the base image | ||
FROM jupyter/base-notebook:python-3.10 | ||
|
||
# Maintainer label | ||
LABEL maintainer="DoEKS" | ||
|
||
# Set environment variables to non-interactive (this prevents some prompts) | ||
ENV DEBIAN_FRONTEND=non-interactive | ||
|
||
# Switch to root to add Neuron repo and install necessary packages | ||
USER root | ||
|
||
# Install gnupg and other required packages | ||
RUN apt-get update -y && \ | ||
apt-get install -y gnupg git g++ | ||
|
||
RUN \ | ||
. /etc/os-release && \ | ||
echo "deb https://apt.repos.neuron.amazonaws.com ${VERSION_CODENAME} main" > /etc/apt/sources.list.d/neuron.list && \ | ||
wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add - && \ | ||
apt-get update -y && \ | ||
apt-get install aws-neuronx-collectives=2.* aws-neuronx-runtime-lib=2.* aws-neuronx-tools=2.* -y | ||
|
||
# Switch back to jovyan user for Python package installations | ||
USER jovyan | ||
|
||
# Set pip repository pointing to the Neuron repository and install required Python packages | ||
RUN pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com && \ | ||
pip install transformers-neuronx sentencepiece transformers wget awscli ipywidgets neuronx-cc==2.* torch-neuronx torchvision ipykernel environment_kernels && \ | ||
# Install new Jupyter Notebook kernel | ||
python -m ipykernel install --user --name aws_neuron_venv_pytorch --display-name "Python (torch-neuronx)" | ||
|
||
# Add Neuron path to PATH | ||
ENV PATH /opt/aws/neuron/bin:$PATH |
Oops, something went wrong.