gcp devops
By: Edward Krueger and Douglas Franklin.
作者: 爱德华·克鲁格 ( Edward Krueger)和道格拉斯·富兰克林 ( Douglas Franklin) 。
In this article, we will cover how to set up a cloud computing instance to run Python with or without Jupyter Notebook. Then we show how to connect that instance to Github for a smooth cloud workflow.
在本文中,我们将介绍如何设置云计算实例以在有或没有Jupyter Notebook的情况下运行Python。 然后,我们展示了如何将该实例连接到Github,以实现流畅的云工作流程。
We utilize cloud computing instances to get flexible Python and Jupyter environments while maintaining the reproducibility of enterprise data science platforms.
我们利用云计算实例来获得灵活的Python和Jupyter环境,同时保持企业数据科学平台的可重复性。
These AI platform notebooks come configured with many data science and analytics packages, including NumPy, Pandas, Scikit-learn and TensorFlow. Typically, we would discourage the use of bloated virtual machines. However, package bloat on our analytics machine isn’t as much of a problem because we only save the result (model, data, report) for later use. Needing only this result and the few packages needed to run our model allows us to disregard the numerous packages on the VM.
这些AI平台笔记本配置了许多数据科学和分析软件包,包括NumPy,Pandas,Scikit-learn和TensorFlow。 通常,我们不鼓励使用of肿的虚拟机。 但是,由于我们只保存结果(模型,数据,报告)供以后使用,因此我们的分析机上的软件包膨胀并不是什么大问题。 只需要这个结果和运行模型所需的几个软件包,就可以忽略VM上的众多软件包。
For example, in this Medium article, we push an NLP mode to the cloud without having to worry about dependencies.
例如,在这篇中型文章中,我们将NLP模式推到了云端,而不必担心依赖关系。
Note that AI platform notebooks have all of the client packages for GCP services installed and are already authenticated to allow easy access to anything within the same GCP project. Additionally, this platform gives us not just access to Jupyter Notebooks, but also a Python console and a CLI where we can run BASH commands.
请注意,AI平台笔记本电脑已安装了所有用于GCP服务的客户端软件包,并且已经过身份验证,可以轻松访问同一GCP项目中的任何内容。 此外,该平台使我们不仅可以访问Jupyter Notebook,而且还可以使用Python控制台和CLI来运行BASH命令。
取得GCP帐户 (Getting a GCP account)
Google’s AI Platform Notebooks offer a JupyterLab and Python environment for data scientists and machine learning developers to experiment, develop, and deploy models into production. Users can create instances running JupyterLab that come pre-installed with common packages.
Google的AI平台笔记本为数据科学家和机器学习开发人员提供JupyterLab和Python环境,以进行实验,开发并将模型部署到生产中。 用户可以创建预装有通用软件包的运行JupyterLab的实例。
Before we can set up an AI Platform Notebook, we will have to set up an account and billing, don’t worry new users get $300 in free credits!
在我们设置AI Platform Notebook之前,我们必须先设置一个帐户并进行结算,不要担心新用户将获得300美元的免费积分!
Visit GCP AI Platform and click ‘go to console.’
访问GCP AI平台 ,然后单击“转到控制台”。
Be sure to click ‘Enable API’ below to access notebooks.
确保单击下面的“启用API”以访问笔记本。
Once we have billing set up, we can start a project.
设置好帐单后,我们可以开始一个项目。
启动您的第一个GCP AI Platform Notebook实例 (Starting up your first GCP AI Platform Notebook Instance)
Now we need to select the hardware we want our virtual machine to run on. Be sure to set up the cheapest machine possible if you are testing this out!
现在,我们需要选择要在其上运行虚拟机的硬件。 如果要进行测试,请务必设置最便宜的机器!
Once we have the API enabled, the popup selections will change to those seen below, click ‘Go to instances page’ to get started.
启用API后,弹出式菜单选择将变为以下所示,单击“转到实例页面”开始使用。
The instances page might have you select ‘Enable API’ another time, be sure to do so. Then click on the ‘New Instance’ button and select ‘Python 2 and 3.’
实例页面可能会让您再次选择“启用API”,请务必选择。 然后点击“新实例”按钮并选择“ Python 2和3”。
This will open up an options menu where you’ll input the region you’d like to use. Note that different regions can have different pricing. Once you have a region selected, you will want to click ‘Customize’ and select the machine with the least RAM to have the lowest cost. In our case, it is the ‘n1-standard-1’ VM with 3.75GB of RAM.
这将打开一个选项菜单,您可以在其中输入要使用的区域。 请注意,不同地区的定价可能不同。 选定区域后,将需要单击“自定义”,然后选择RAM最少的机器以降低成本。 在我们的案例中,它是具有3.75GB RAM的“ n1-standard-1” VM。
This instance will only generate fees when it is running and can be easily paused at any time! If needed, you can swap out hardware with the dropdown menus seen below while the instance is paused.
该实例仅在运行时才会产生费用,并且可以随时轻松暂停! 如果需要,您可以在实例暂停时通过下面显示的下拉菜单交换硬件。
Now we can use SSH to connect our VM to GitHub to allow us to push
and pull
to our repositories with ease.
现在,我们可以使用SSH将虚拟机连接到GitHub,从而使我们可以轻松地push
存储库push
和pull
。
设置SSH (Setting Up SSH)
Be aware you will only have to do this once per instance.
请注意,每个实例只需执行一次。
使用SSH连接到GitHub (Connecting to GitHub with ssh)
Generate an ssh key by running
ssh-keygen
and accepting the defaults by leaving them blank and pressing the enter key. This command generates files atuser/.ssh/id_rsa
that you’ll need to enter into GitHub.通过运行
ssh-keygen
生成ssh密钥,并通过将其保留为空白并按Enter键来接受默认值。 此命令在user/.ssh/id_rsa
处生成文件,您需要将这些文件输入GitHub。
2. Copy your public key to your clipboard. One way to do this is by running cat ~/.ssh/id_rsa.pub
to return the public key text into your console, display its contents, and then copy with the mouse and keyboard.
2.将您的公钥复制到剪贴板。 一种方法是运行cat ~/.ssh/id_rsa.pub
将公钥文本返回到控制台,显示其内容,然后使用鼠标和键盘进行复制。
3. Go to github.com and sign in.
3.转到github.com并登录。
4. Click your profile image in the top right and then click “Settings.”
4.单击右上角的个人资料图片,然后单击“设置”。
5. On the left-hand side, click “SSH and GPG keys.”
5.在左侧,单击“ SSH和GPG密钥”。
6. On the top right, click “New SSH key.”
6.在右上方,单击“新建SSH密钥”。
7. Set the title to whatever you like. The “Title” is your choice, but it will help you identify what computer this authorization authorizes. Paste the copied key into the “Key” field and press “Add SSH key.”
7.将标题设置为任何您喜欢的名称。 您可以选择“标题”,但这将帮助您确定此授权授权的计算机。 将复制的密钥粘贴到“密钥”字段中,然后按“添加SSH密钥”。
8. Go back to your computer and run eval 'ssh-agent -s'
to start your ssh authentication agent.
8.返回计算机并运行eval 'ssh-agent -s'
以启动ssh身份验证代理。
9. Run ssh-add
to add your private key so that the agent can authenticate the public key.
9.运行ssh-add
添加您的私钥,以便代理可以验证公钥。
10. Set your git configuration so that GitHub knows who you are by running git config --global user.email you@email.com
and git config --global user.name username
, where the email and username are those attached to your GitHub account.
10.设置您的git配置,以便GitHub通过运行git config --global user.email you@email.com
和git config --global user.name username
知道您的git config --global user.name username
,其中电子邮件和用户名是附加到GitHub上的电子邮件和用户名帐户。
Now you can git clone
any repository you have access too right onto the VM, make changes to the code, and push them back to the repository!
现在,您可以git clone
任何有权访问的存储库直接git clone
到VM上,对代码进行更改,然后将其推回到存储库中!
结论 (Conclusion)
We’ve discussed how to set up a cloud computing instance to run Python, BASH, and Jupyter Notebooks and how to connect that instance to Github for an easy and secure cloud workflow.
我们已经讨论了如何设置一个云计算实例来运行Python,BASH和Jupyter Notebook,以及如何将该实例连接到Github,以实现简单而安全的云工作流程。
This workflow is great because it is so reproducible! Teams using VMs like this will encounter less of the ‘it works on my machine’ bugs. Using ssh to connect the cloud VM and our remote repositories provide a safe connection to protect your data. Additionally, if you want to run code on expensive hardware, you don’t have to buy that hardware! Instead, run what you need and pause your instance to save costs.
这个工作流程很棒,因为它是如此的可复制! 使用此类VM的团队将遇到较少的“在我的计算机上运行”错误。 使用ssh连接云VM和我们的远程存储库可提供安全的连接来保护您的数据。 此外,如果您想在昂贵的硬件上运行代码,则不必购买该硬件! 而是运行所需的内容并暂停实例以节省成本。
We hope this guide has been helpful and that your coding skills are leveling up with us!
我们希望本指南对您有所帮助,并且您的编码技能正在与我们一起发展!
翻译自: https://towardsdatascience.com/using-gcp-ai-platform-notebooks-as-reproducible-data-science-environments-964cba32737
gcp devops
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/392510.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!