[英]Can you use a Jupyter notebook on my GCP VM to run TPU training in Google Cloud?
我正在從在 colab 中運行 TPU 切換到在谷歌雲中運行 TPU。 我習慣在 colab jupyter notebook 中運行訓練,但根據 GCP TPU 快速入門指南,我需要使用 shell 腳本,並將我的代碼轉換為腳本。
https://cloud.google.com/tpu/docs/quickstart
有沒有辦法打開我的 GCP VM 的 Jupyter 筆記本版本?
是的,您在 GCP VM 上打開並運行 Jupyter notebook。 必須有其他方法可以做到這一點,但這是我遵循並為我工作的方法 -
第 1 階段 - 確保您已設置 GCP 項目並在支持 TPU 的區域中設置 VM 實例。 對於我的,我使用了 us-central1-f。
第 2 階段 - 確保您的 VM(計算引擎)、Cloud TPU 和 Cloud Storage 已根據此處提供的說明進行設置和鏈接 - https://cloud.google.com/tpu/docs/quickstart
第 3 階段 - 對於 VM,您需要通過以下方式啟用防火牆設置
- 姓名:
- 目標:.network 中的所有實例
- 來源 IP 范圍:0.0.0.0/0
- 協議和端口:Select“指定的協議和端口”選項。
- tcp: 8888 其他配置保持默認。
階段 4 - 您需要安裝以下內容:
- Anaconda
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
bash Anaconda3-4.2.0-Linux-x86_64.sh
- Tensorflow、Keras 和您需要的任何其他圖書館
source ~/.bashrc
pip install tensorflow
pip install keras
第 5 階段 - 確保設置 Jupyter 配置
$ jupyter notebook --generate-config
$ nano ~/.jupyter/jupyter_notebook_config.py # I use nano editor
將這四行放在這個配置文件的頂部並保存
c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
就是這樣。 你只需要跑
$ jupyter notebook
並在瀏覽器中輸入 http://your_external_IP:8888
如果您在 GKE 上使用 JupyterHub 的 helm 圖表,您似乎也可以使用 JupyterHub 的配置文件。 確保為 kubeSpawner 設置設置正確的覆蓋:
singleuser:
profileList:
scheduler_name: default-scheduler
extra_annotations:
tf-version.cloud-tpus.google.com: "pytorch-1.11"
extra_resource_limits:
cloud-tpus.google.com/v2: 8
它沒有記錄,但您需要使用“默認調度程序”,因為 GKE 需要它來生成 TPU 實例。
此處的其他文檔:
https://cloud.google.com/tpu/docs/kube.netes-engine-setup#job-spec
https://jupyterhub-kubespawner.readthedocs.io/en/latest/spawner.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.