简体   繁体   English

如何远程连接到 GCP ML Engine/AWS Sagemaker 托管笔记本?

[英]How to remotely connect to GCP ML Engine/AWS Sagemaker managed notebooks?

GCP has finally released managed Jupyter notebooks. GCP 终于发布了托管的 Jupyter 笔记本。 I would like to be able to interact with the notebook locally by connecting to it.我希望能够通过连接到笔记本在本地与它进行交互。 Ie. IE。 i use PyCharm to connect to the externaly configured jupyter notebbok server by passing its URL & token param.我使用 PyCharm 通过传递其 URL 和令牌参数来连接到外部配置的 jupyter notebbok 服务器。

Question also applies to AWS Sagemaker notebooks.问题也适用于 AWS Sagemaker 笔记本。

GCP has finally released managed Jupyter notebooks. GCP 终于发布了托管 Jupyter 笔记本。 I would like to be able to interact with the notebook locally by connecting to it.我希望能够通过连接到笔记本在本地与笔记本进行交互。 Ie. IE。 i use PyCharm to connect to the externaly configured jupyter notebbok server by passing its URL & token param.我使用 PyCharm 通过传递其 URL 和令牌参数来连接到外部配置的 jupyter notebbok 服务器。

Question also applies to AWS Sagemaker notebooks.问题也适用于 AWS Sagemaker 笔记本。

GCP has finally released managed Jupyter notebooks. GCP 终于发布了托管 Jupyter 笔记本。 I would like to be able to interact with the notebook locally by connecting to it.我希望能够通过连接到笔记本在本地与笔记本进行交互。 Ie. IE。 i use PyCharm to connect to the externaly configured jupyter notebbok server by passing its URL & token param.我使用 PyCharm 通过传递其 URL 和令牌参数来连接到外部配置的 jupyter notebbok 服务器。

Question also applies to AWS Sagemaker notebooks.问题也适用于 AWS Sagemaker 笔记本。

GCP has finally released managed Jupyter notebooks. GCP 终于发布了托管 Jupyter 笔记本。 I would like to be able to interact with the notebook locally by connecting to it.我希望能够通过连接到笔记本在本地与笔记本进行交互。 Ie. IE。 i use PyCharm to connect to the externaly configured jupyter notebbok server by passing its URL & token param.我使用 PyCharm 通过传递其 URL 和令牌参数来连接到外部配置的 jupyter notebbok 服务器。

Question also applies to AWS Sagemaker notebooks.问题也适用于 AWS Sagemaker 笔记本。

GCP has finally released managed Jupyter notebooks. GCP 终于发布了托管 Jupyter 笔记本。 I would like to be able to interact with the notebook locally by connecting to it.我希望能够通过连接到笔记本在本地与笔记本进行交互。 Ie. IE。 i use PyCharm to connect to the externaly configured jupyter notebbok server by passing its URL & token param.我使用 PyCharm 通过传递其 URL 和令牌参数来连接到外部配置的 jupyter notebbok 服务器。

Question also applies to AWS Sagemaker notebooks.问题也适用于 AWS Sagemaker 笔记本。

There is a way to SSH into a Sagemaker notebook instance without having to use a third party reverse proxy like ngrok, nor setup an EC2 bastion, nor using AWS Systems Manager, here is how you can do it.有一种方法可以将 SSH 放入 Sagemaker 笔记本实例,而无需使用像 ngrok 这样的第三方反向代理,也无需设置 EC2 堡垒,也无需使用 AWS Systems Manager,您可以这样做。

Prerequisites先决条件

  • Use your own VPC and not the VPC managed by AWS/Sagemaker for the notebook instance为笔记本实例使用您自己的 VPC ,而不是 AWS/Sagemaker 管理的 VPC
  • Configure an ingress rule in the security group of your notebook instance to allow SSH traffic (port 22 over TCP)在笔记本实例的安全组中配置入口规则以允许 SSH 流量(端口 22 通过 TCP)

How to do it怎么做

  • Create a lifecycle script configuration that is executed when the instance starts创建实例启动时执行的生命周期脚本配置
  • Add the following snippet inside the lifecycle script:在生命周期脚本中添加以下代码段:
INSTANCE_IP=$(/sbin/ifconfig eth2 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
echo "SSH into the instance using : ssh ec2-user@$INSTANCE_IP" > ~ec2-user/SageMaker/ssh-instructions.txt
  • Add your public SSH key inside /home/ec2-user/.ssh/authorized_keys , either manually with the terminal of jupyterlab UI, or inside the lifecycle script above/home/ec2-user/.ssh/authorized_keys中添加您的公共 SSH 密钥,可以使用 jupyterlab UI 的终端手动添加,也可以在上面的生命周期脚本中添加

When your users open the Jupyter interface, they will find the ssh-instructions.txt file which gives the host and command to use: ssh ec2-user@<INSTANCE_IP>当您的用户打开 Jupyter 界面时,他们将找到ssh-instructions.txt文件,该文件提供了要使用的主机和命令: ssh ec2-user@<INSTANCE_IP>

If you want to SSH from a local environment, you'll probably need to connect to your VPN that routes your traffic inside your VPC.如果您想从本地环境访问 SSH,您可能需要连接到在您的 VPC 内路由您的流量的 VPN。

I've found not being able to SSH to notebook instances too limiting so I've build a guide to set it up by using the bastion box.我发现无法将 SSH 限制到笔记本实例,因此我建立了一个指南来使用堡垒盒进行设置。 https://ruslanmv.com/blog/How-to-connect-to-Sagemaker-Notebook-via-SSH I hope this can be helpful. https://ruslanmv.com/blog/How-to-connect-to-Sagemaker-Notebook-via-SSH我希望这会有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GCP 托管笔记本不会出现在虚拟机实例列表下,但用户托管笔记本会出现 - 为什么? - GCP Managed Notebook doesn't appear under VM instances list, but User Managed Notebooks do - Why? 如何在 aws EC2 中设置 Sockect.io 服务器,然后远程连接到服务器? - How to setup a Sockect.io server in aws EC2 and then connect remotely to the server? GCP 上的 ETL 机器学习 - ETL on GCP for ML 如何将气流 [docker] 连接到 GCP? - How to connect airflow[docker] to GCP? GCP App Engine - 如何提供最新文件 - GCP App Engine - How to serve newest files AWS SageMaker 上的数据预处理 - Data Preprocessing on AWS SageMaker 如何在等待响应时增加 AWS Sagemaker 调用超时 - How to increase AWS Sagemaker invocation time out while waiting for a response 当图像已经属于 AWS 链接时,如何在 Colab/AWS ML 实例上下载图像用于 ML 目的 - How to download images on Colab / AWS ML instance for ML purposes when Images already belong to AWS links 如何在 GCP 中为通配符主机名生成 Google 管理的证书? - How to generate a Google-managed certificates for wildcard hostnames in GCP? 如何将 aws 实例转换为托管实例? - how to make aws instance to managed instance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM