Using EC2-Deep Learning AMI - connecting to G Co1ab issues and solutions
Tags: deeplearning, aws, jupyter
Published: 2021-08-21 19:46:36

Jupyter notebooks are one of the important tools used by data scientist, DevOps and Data Analyst in building models. There are issues using notebooks when ran into long asynchronous task typical in deep learning model can take a long hours and times out errors. 

![dl](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wrw11y402rrsjt1p98r.jpg)
 
This article cite challenges that author encounter from sources on connecting EC2 Deep Learning AMI Ubuntu 18.04 to Google Colab local host. 

What are the AWS resources needed?

1.) Launch Amazon EC2 - Use Deep Learning AMI (Ubuntu 18.04 ). Select the "Configure Instance Details" p3 | p32xlarge | 8 | 61 EBS only | Yes | Up to 10 Gigabit | Yes , then launch your instance. 

AWS Documentation : "AWS Service Quotas" to check your EC2 resource limits https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html

2.) Prepare to load your private key from EC2 using PuttyKey Generator save your private key. Then open putty configuration to SSH your ec2 instance  

What are the challenges ?

1.) Error message when type 'jupyter notebook'' "[W 18:22:04.741 NotebookApp] No web browser found: could not locate runnable bro                                                                                                             wser.[C 18:22:04.741 NotebookApp]"

Solution#1: 
Input in command line 'pip install --upgrade 
 'jupyter_http_over_ws>=0.0.7 &&   jupyter serverextension enable --py jupyter_http_over_ws

Then input again in command 'jupyter notebook \ 
 --NotebookApp.allow_origin='https://colab.research.google.com'   
 --port=8888   --NotebookApp.port_retries=0'

2.)  For this error:  [C 18:13:01.047 NotebookApp] Bad config encountered during initialization: The 'kernel_spec_manager_class' trait of <notebook.notebookapp.NotebookApp object at 0x7f0adb9f6310> instance must be a type, but 'environment_kernels.EnvironmentKernelSpecManager' could not be imported.

Solution#2: input in command line # means "number of line" 
 # pip list|grep jupyter|cut -f 1 -d ' ' | xargs pip install -U --force-reinstall
 #  jupyter nbextensions__configurator enable --user
 #  jupyter serverextension enable --py jupyter_http_over_ws enable --user
 #  jupyter serverextension enable --py jupyter_http_over_ws
 #  jupyter notebook
 
3.) Troubleshooting local connection - ensure that jupyter_http_over_ws_enabled and updates on your instance.

'''pip install --upgrade jupyter_http_over_ws>=0.0.7 && \
  jupyter serverextension enable --py jupyter_http_over_ws'''

Moreover jupyter should be running on port 8889 and accepting http request from G co1ab 


Now, connect to Google collab in the top right then select Connect to local runtime. Enjoy Deep learning model proessing! 

'''jupyter notebook \
  --NotebookApp.allow_origin='https://colab.research.google.com' \
  --port=8889 \
  --NotebookApp.port_retries=0'''

Here's all copy of screenshot of steps above and reference :
https://colab.research.google.com/drive/1A9-z1iqrc81IaLacd4m7DiqOmSY3ccTL#scrollTo=cgescazxASML&forceEdit=true&sandboxMode=true


### DONT FORGET TO STOP YOUR EC2 INSTANCE!!!!