Skip to content

Instantly share code, notes, and snippets.

@Layoric
Created August 9, 2021 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Layoric/527dc2a604efc8be10610fd518150ad9 to your computer and use it in GitHub Desktop.
Save Layoric/527dc2a604efc8be10610fd518150ad9 to your computer and use it in GitHub Desktop.
AWS SageMaker running dotnet 5 and dotnet interactive - based on https://github.com/aws-samples/amazon-sagemaker-dotnet-image-classification
#!/bin/bash
set -e
wget https://download.visualstudio.microsoft.com/download/pr/8468e541-a99a-4191-8470-654fa0747a9a/cb32548d2fd3d60ef3fe8fc80cd735ef/dotnet-sdk-5.0.302-linux-x64.tar.gz
wget https://download.visualstudio.microsoft.com/download/pr/50687c84-e120-4410-bd4a-b1e0869d03f4/6038576259f95ef61d4d103ee3967130/dotnet-runtime-5.0.8-linux-x64.tar.gz
mkdir -p /home/ec2-user/dotnet && tar zxf dotnet-runtime-5.0.8-linux-x64.tar.gz -C /home/ec2-user/dotnet
export DOTNET_ROOT=/home/ec2-user/dotnet
export PATH=$PATH:/home/ec2-user/dotnet
export DOTNET_CLI_HOME=/home/ec2-user/dotnet
export HOME=/home/ec2-user
tar zxf dotnet-sdk-5.0.302-linux-x64.tar.gz -C /home/ec2-user/dotnet
dotnet tool install --global Microsoft.dotnet-interactive
export PATH=$PATH:/home/ec2-user/dotnet/.dotnet/tools
dotnet interactive jupyter install
jupyter kernelspec list
touch /etc/profile.d/jupyter-env.sh
cat << EOF > /etc/profile.d/jupyter-env.sh
export PATH=\$PATH:/home/ec2-user/dotnet/.dotnet/tools:/home/ec2-user/dotnet
EOF
touch /etc/profile.d/dotnet-env.sh
echo "export DOTNET_ROOT=/home/ec2-user/dotnet" >> /etc/profile.d/dotnet-env.sh
sudo chmod -R 777 /home/ec2-user/.dotnet
initctl restart jupyter-server --no-wait
@Layoric
Copy link
Author

Layoric commented Aug 9, 2021

This was updated from the AWS samples but to use dotnet 5 since dotnet interactive needs it.

It also needed to correctly escape the use of $PATH as the values in PATH are before jupyter-env.sh is run and when the on-startup.sh script is run, breaking the ability to restart the jupyter server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment