Go back

How to get Multiuser Python Jupyter notebook for AI/ML on AWS

This section describes how to launch and connect to Multiuser Python Jupyter notebook for AI/ML in Amazon Web Services (AWS).

Note: Now the Multiuser Python Jupyter notebook for AI/ML is available with Jupyter AI and GPU Acceleration support. To provision this VM with the GPU instance, please select the instance from g4dn family available on configuration page (Please see below configuration screenshot in step 2.).

  1. Open Multiuser Python Jupyter notebook for AI/ML VM listing on AWS marketplace

/img/aws/jupyter-python-notebook/marketplace-new.png

  1. Click on Continue to subscribe.
  • Login with your credentials and follow the instruction.
  • Subscribe to the product and click on Continue to configuration button.
  • Select a Region where you want to launch the VM(such as US East (N.Virginia))

/img/aws/jupyter-python-notebook/region.png

  • Click on Continue to Launch Button.
  • Choose Action: You can launch it through EC2 or from Website.(Let’s choose Launch from website)

/img/aws/jupyter-python-notebook/launch.png

  • Optionally change the EC2 instance type. (This defaults to t2.large instance type, 2 vCPUs and 8 GB RAM.)

  • For GPU instance, Please select instance from G4 family.

  • Optionally change the network name and subnetwork names.

/img/aws/jupyter-python-notebook/vpc.png /img/aws/aiml-gpu-instance.png

  • Select the Security Group. Be sure that whichever Security Group you specify have ports 22 (for ssh), 3389 (for RDP) and 80 (for HTTP) exposed.

  • Be sure to download the key-pair which is available by default, or you can create the new key-pair and download it. /img/aws/jupyter-python-notebook/SG.png

Click on Launch.

Multiuser Python Jupyter notebook for AI/ML will begin deploying.

  1. A summary page displays.To see this instance on EC2 Console click on EC2 Console link.

/img/aws/jupyter-python-notebook/deployed.png

  1. On the EC2 Console page, instance is up and running. To connect to this instance through putty, copy the IPv4 Public IP Address

/img/aws/jupyter-python-notebook/public-ip.png

  1. Open putty, paste the IP address and browse your private key you downloaded while deploying the VM, by going to **SSH- >Auth **, click on Open. Enter ubuntu as userid

/img/aws/desktop-linux/putty-01.png

/img/aws/desktop-linux/putty-02.png

  1. Once connected, change the password for ubuntu user using below command
sudo passwd ubuntu

/img/aws/desktop-linux/ssh.png

  1. Now the password for ubuntu user is set, you can connect to the VM’s desktop environment from any local Windows Machine using RDP protocol or Linux Machine using Remmina.

From your local windows machine, goto “start” menu, in the search box type and select “Remote desktop connection”. In the “Remote Desktop connection” wizard, copy the public IP address and click connect

/img/aws/desktop-linux/rdp.png

  1. This will connect you to the VM’s desktop environment. Provide the username (e.g “ubuntu”) and the password set in the above “Reset password” step to authenticate. Click OK

/img/aws/desktop-linux/rdp-login.png

  1. Now you are connected to the out of box Multiuser Python Jupyter notebook for AI/ML environment via Windows Machine.

/img/aws/jupyter-python-notebook/rdp-desktop.png

  1. To connect using RDP via Linux machine, first note the external IP of the VM from VM details page,then from your local Linux machine, goto menu, in the search box type and select “Remmina”.

    Note: If you don’t have Remmina installed on your Linux machine, first Install Remmina as per your linux distribution.

/img/gcp/common/remmina-search.png

  1. In the “Remmina Remote Desktop Client” wizard, select the RDP option from dropdown and paste the external ip and click enter.

/img/gcp/common/remmina-external-ip.png

  1. This will connect you to the VM’s desktop environment. Provide “ubuntu” as the userid and the password set in above reset password step to authenticate. Click OK

/img/gcp/common/remmina-rdp-login.png

  1. Now you are connected to out of box Multiuser Python Jupyter notebook for AI/ML environment via Linux machine.

/img/aws/jupyter-python-notebook/rdp-desktop.png

  1. You can use the remote desktop you connected in above step for using the VM, however, more convenient and better method is to use the Jupyter/Ipython notebook which comes with the VM.

The Notebook is available on the same public IP you used for remote desktop and accessible via any browser. Just open the browser and type the public IP address and you will get below screen for login.

The Jupyter Notebook is configured with the ubuntu as an admin user. Login with ubuntu as username and use a ubuntu user password set in the above step 6.

Note : Make sure you use “http” and not “https” in the url

/img/aws/aws_jupyterhub_login.png

  1. After Login , you will see below screen. This is JupyterLab. You will find various options here. You can Access Jupyter Notebook, Console, Files and Folders, etc.

/img/gcp/jupyter-python-notebook/jupyterlab.png

  1. This VM comes with the JuputerAI plugin installed out of the box which allow you to access Chat UI in the JupyterLab. This can be used for AI-conversation with lots of LLMs via APIs. It has support for chatgpt and lots of other LLMs.

/img/gcp/jupyter-python-notebook/chatui.png

  1. To configure your Jupyternaut(ChatUI official name), You need to select a language model and an embedding model to chat. Once you have made your selections, the UI may display text boxes for one or more settings keys. So keep your keys ready with you. click on Start Here.

/img/gcp/jupyter-python-notebook/start-here.png

  1. Select a Language Model and Embedding model from the dropdown. If your selected model needs API keys, provide the API Keys. You need to get the API keys from the selected model providers. For example, for OpenAI provider you can get the API keys as explained here.

Select the Input Type.

/img/gcp/jupyter-python-notebook/configure-chat-ui.png

  1. Click on Save Changes. Once settings are saved successfully, click the “back” (left arrow) button in the upper-left corner of the Jupyter AI side panel. The chat interface now appears.

/img/gcp/jupyter-python-notebook/save.png

  1. Now your personal assistance is ready. Seek code suggestions, debugging tips, or even have code snippets generated for you by interacting with the chat UI.

/img/gcp/jupyter-python-notebook/jupyternaut.png

For more details on how to use Chat UI , please refer The chat interface Documentations.

  1. This VM also comes with the magics package jupyter_ai_magics installed out of the box. These magic commands %%ai and %ai turns your Jupyter into a generative AI playground anywhere the IPython kernel runs. Before you send your first prompt to an AI model, load the IPython extension by running the following code in a notebook cell or IPython shell: -
   %load_ext jupyter_ai_magics

To use these magic commands, open Jupyter Notebook. Run %ai help for help with syntax.

   %ai help

/img/gcp/jupyter-python-notebook/magic-commands-help.png

  1. The %%ai cell magic allows you to invoke a language model of your choice with a given prompt.The model is identified with a global model ID, which is a string with the syntax provider-id:local-model-id, where provider-id is the ID of the provider and local-model-id is the ID of the model scoped to that provider Set your model API keys using environment variable and your model of choice as shown below. Reload the IPython extension.
  %env OPENAI_API_KEY=Your API Key
  %%ai <provider-id>:<local-model-id>
  %reload_ext jupyter_ai_magics

/img/gcp/jupyter-python-notebook/env.png

  1. Now you can invoke a model as follows. The prompt begins on the second line of the cell.
   %%ai model
   Your prompt here

/img/gcp/jupyter-python-notebook/prompt.png

  1. Jupyter AI also includes multiple subcommands, which may be invoked via the %ai line magic. The %ai list subcommand prints a list of available providers and models.
   %ai list

/img/gcp/jupyter-python-notebook/list.png

Please refer The %ai and %%ai magic commands Documentations for more details.

Additional resources:

How to enable HTTPS for JupyterHub

Enable Multiuser Environment

How to install additional packages

Go back