Google Cloud Console + Jupyter Notebooks 讲解

要想在Google Cloud Console里创建和使用Jupyter,现在博主就将步骤写下来,供各位参考,如果有什么不对的,就请指出来!(Google Cloud Console上的命令和界面会有变化)

  • 在Google Cloud Console,选择已有的Google Cloud Project,或者创建新的Google Cloud Project.
    在这里插入图片描述
    点击"NEW PROJECT",就可以创建新的Google Cloud Project.
    在这里插入图片描述

  • 确保Google Cloud Project有billing account. Google Cloud Console有给$300的credit来使用,前提是得有信用卡!

  • Enable the AI Platform Notebooks API. 页面如下:
    在这里插入图片描述

  • 创建新的default notebook instance.
    [4.1] 前往AI Platform Notebooks 页面
    在这里插入图片描述 [4.2] 点击“NEW INSTANCE”,选择instance type, 选择是否需要包括GPU
    在这里插入图片描述
    [4.3] 如果你选择需要GPU,你必须得选择Install NVIDIA GPU driver automatically for me. 你可以更改GPUs的数量。
    在这里插入图片描述
    在这里插入图片描述

[4.4] 最后点击“CREATE
[4.5] AI Platform Notebooks 基于你的选择而创建一个新的instances.


  • 创建一个自定义的AI Platform Notebooks instance
    [5.1] 点击"NEW INSTANCE",之后选择Customize instance
    在这里插入图片描述
    [5.2] 在创建New notebook instance 页面,有提供了几个信息:

  • Instance name: 提供一个名字给你的新的instance

  • Region: 选择一个region给你的新的instance。选择一个离你在地里位置很近的region,这样能带来很好的performance

  • Zone: 选择一个zone在你的region里

  • Environment: 选择一个你想要的environment 和操作系统

  • Machine Type: 选择一个有多少数量的CPU和多少数量的RAM给你的新的instance。AI Platform Notebooks基于你所选择Machine type来进行收费

  • GPUs: 选择GPU type和GPU的数量给你的新的instance。选择Install NVIDIA GPU driver automatically for me。你未来也可以更改GPU的类型和数量。

[5.3] 如果你想改变default boot disk,你就在Disk(s) section选择Boot disk type和Boot disk size in GB, 来设置你想要的
在这里插入图片描述
[5.4] 如果你想改变encryption的设置, 就可以选择Customer-managed encryption keys (CMEK).
[5.5] 如果你想改变network 的设置,就得做以下步骤:

  • 进入Networking section
  • 选择任何一个Networks in this project还是Networks shared with me.
  • 在Network menu里,选择一个你想要的network. 你可以选择VPC network, 只要这个network有Private Google Access 被enabled或者可以使用internet.
  • 在Subnetwork menu里,选择你想要的subnetwork
  • 如果你想disable the external IP address, 设置External IP menu为None
  • 如果你想disable proxy access, 就clear the checkbox next to Allow proxy access when it’s available.
    在这里插入图片描述
    [5.6] 如果你想让所有的users有权限使用具体的Compute Engine service account或者具体的user,那就进入Permission section和完成任何一个以下的步骤:
  • 为了使用具体的某一个服务账号,点击Access to JupyterLab menu, 和选择Other service account. 接着在Service account field里填写。
  • 为了只给一个user的权限,点击Access to JupyterLab menu, 和选择Single user only。接着在User email field里填写就行。
    [5.7] 点击Create按钮
    [5.8] 基于你所选择属性, AI Platform Notebooks 创建一个新的instance。

如果想用command line来创建,也可以,下面就展示如何用command line来创建instance.
得先在GCP页面上,点击这个图标才能进入Cloud Shell
在这里插入图片描述

  1. Enable the Notebooks API
    命令:gcloud services enable notebooks.googleapis.com
    在这里插入图片描述
  2. 创建instance:
    命令:
    在这里插入图片描述

类似下面的截图:
在这里插入图片描述
3. 在AI Platform Notebooks就可以看到创建好的instance

在这里插入图片描述
4. 点击OPEN JUPYTERLAB,就能进入到Jupyter页面了
在这里插入图片描述
5. 当不使用Jupyter,必须删除instance,不然就会一直扣钱。
命令如下:
gcloud beta notebooks instances delete bq-jupyter-instance
–location LOCATION
像下面的截图一样
在这里插入图片描述

也可以在页面上进行删除:
在这里插入图片描述


如果觉得哪里写的不对,就麻烦指出来。或者如果觉得写的不错,就给个点赞或者五星好评吧或者关注博主吧~~
谢谢各位~

Jupyter notebooks 是一个交互式的计算环境,允许你使用 Python 进行数据分析、可视化和机器学习等。在 Jupyter notebooks 中读取 Excel 文件,通常我们会使用 Pandas 库,它是一个强大的数据分析工具库,提供了大量的数据结构和函数来处理表格数据。 下面是使用 Pandas 在 Jupyter notebooks 中读取 Excel 文件的基本步骤: 1. 首先确保你的 Jupyter notebooks 环境已经安装了 Pandas 和 `openpyxl` 或者 `xlrd` 这两个库。`openpyxl` 是读取 `.xlsx` 文件的,而 `xlrd` 可以读取 `.xls` 文件。你可以使用 pip 来安装这些库(如果尚未安装): ```python !pip install pandas openpyxl # 或者如果你需要读取.xls文件,则需要安装xlrd: # !pip install pandas xlrd ``` 2. 在 Jupyter notebooks 中导入 Pandas 库,并使用 `read_excel` 函数来读取 Excel 文件。假设你已经有了一个名为 `example.xlsx` 的 Excel 文件,并且它位于你的工作目录中,你可以这样做: ```python import pandas as pd # 读取 Excel 文件 df = pd.read_excel('example.xlsx') # 打印 DataFrame 的内容查看 print(df) ``` 3. 如果 Excel 文件中包含多个工作表(sheet),你还可以通过 `sheet_name` 参数来指定读取哪一个工作表: ```python df_sheet2 = pd.read_excel('example.xlsx', sheet_name='Sheet2') ``` 4. 如果你的 Excel 文件有特定的行列需要读取,你还可以通过 `usecols` 和 `skiprows` 等参数来进行设置。 通过以上步骤,你就可以在 Jupyter notebooks 中轻松读取和分析 Excel 文件中的数据了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值