4

To install Jupyter Lab Extension on AWS sagemaker, You need to follow https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/tree/master/scripts. And then create the lifecycle configuration accordingly.

I did it and this is my on-start.sh file.

#!/bin/bash

set -e

# OVERVIEW
# This script installs a jupyterlab extension package in SageMaker Notebook Instance

sudo -u ec2-user -i <<'EOF'
# PARAMETERS
EXTENSION_NAME=@jupyter-widgets/jupyterlab-manager
source /home/ec2-user/anaconda3/bin/activate JupyterSystemEnv
jupyter labextension install $EXTENSION_NAME
source /home/ec2-user/anaconda3/bin/deactivate
EOF

Everything should went smooth except for this extension it raises an error.

This is the error log from cloud watch.

/bin/bash: /tmp/OnStart_2019-06-26-23-3260vo0j6p: /bin/bash^M: bad interpreter: No such file or directory

This one is the error message shown in the sagemaker console.

Failure reason
Notebook Instance Lifecycle Config 'arn:aws:sagemaker:ap-southeast-1:658055165324:notebook-instance-lifecycle-config/jupyter-widgets-for-jupyterlab-copy' for Notebook Instance 'arn:aws:sagemaker:ap-southeast-1:658055165324:notebook-instance/test' took longer than 5 minutes. Please check your CloudWatch logs for more details if your Notebook Instance has Internet access.

I had done several attempts to locate the bug in the script file and the setup file of ipywidgets concerning the 'bad interpreter' error. I cannot find any traces of error in both.

I tried to upgrade my instance to T2 largest instance just in case the error came from the timeout.

The weirdest thing is that I am able to install it via the terminal from the terminal on jupyterlab. I measured the total time it takes to install and found it is around 4 mins just enough time(AWS should allow more time since this is only one extension install). Noted that this installation was performed under the T2 medium instance(the cheapest instance type you could get). If you install it this way to have to reboot the jupyter lab to make it work, then you reboot your instance and everything reverts back to the not-yet-install state. This suggests that there is no way to install jupyter lab extension rather than using the lifecycle cycle configurations which will lead you back to the error.

At this point, I gave up and use the jupyter notebook instead if I really want to use the ipywidgets.


Normally, this should be raised as technical support on AWS, but I have the basic plan so I decided to file it in StackOverflow for others that might encounter the same thing.

CircleOnCircles
  • 3,646
  • 1
  • 25
  • 30
  • 1
    Hi Ben, thanks for using Amazon SageMaker! I followed the steps you provided and it actually seemed to work for me. I wonder if there is something specific about the way the Lifecycle Configuration is being created. The error message "bad interpreter" leads me to believe that there is a formatting issue when you create the Lifecycle Configuration. I performed the test above using a Mac, in FireFox 69.0 (64-bit). Is your environment different? I wonder if you could try this in a different browser and see if it works. – Kevin McCormick Sep 04 '19 at 17:13
  • @KevinMcCormick I tried on FireFox and it works too. – CircleOnCircles Sep 05 '19 at 10:41
  • @KevinMcCormick The lifecycle configuration created with FireFox works while the one created with Chrome fails. – CircleOnCircles Sep 05 '19 at 10:47
  • Great to hear that it worked for you in FireFox! I'll make sure that this problem is reported so that it gets fixed in Chrome, too! – Kevin McCormick Sep 05 '19 at 19:44

1 Answers1

2

copy to notepad++ view>show symbol>show all symbols replace "/r" with nothing CRLF should become LF which is valid in unix copy and paste as plain text!!!

adrshm91
  • 111
  • 1
  • 1
  • 9