【问题标题】:How to make VM-instance with python3.5 in Google Cloud Platform如何在 Google Cloud Platform 中使用 python3.5 制作虚拟机实例
【发布时间】:2019-04-04 19:14:39
【问题描述】:

我已经使用 Python3.5.5 制作了 Tensorflow 模型。我想将它部署在 Google Cloud Platform 上。但是由于 Google Cloud Platform 支持 python 3.6 和 Python 3.7,我无法弄清楚如何去做。如果可能,请指导我如何在我的 tensorflow 模型中访问 Google Cloud Storage Bucket 数据。

提前致谢。

【问题讨论】:

    标签: google-cloud-platform python-3.5


    【解决方案1】:

    您可以搜索in here(如果存在具有该特定 Python 版本的映像),或者您可以选择任何 Linux 分发映像并在其中安装该特定 Python 版本。

    对于后一种情况,这是一个工作示例:

    ZONE=us-central1-a
    INSTANCE_ID=my-vm-00
    
    gcloud compute instances create $INSTANCE_ID --machine-type n1-standard-1 --image-project debian-cloud --image debian-9-stretch-v20190326 --metadata startup-script="sudo apt update && sudo apt install gcc make -y && wget https://www.python.org/ftp/python/3.5.5/Python-3.5.5.tgz && tar xvf Python-3.5.5.tgz && cd Python-3.5.5 && sudo ./configure --enable-optimizations && sudo make altinstall" --subnet default --zone $ZONE
    

    查看Google Cloud SDK 了解有关上述命令的更多背景信息。

    使用以下命令,您可以检查哪些 Python 3.5.x 可用(但在最后一个命令返回后您必须等待几秒钟)。

    gcloud compute ssh $INSTANCE_ID --command 'for pythonv in python3 python3.5; do type $pythonv; $pythonv --version; done' --zone $ZONE
    

    只记得在需要 Python 3.5.3 时使用 python3.5 可执行文件。

    要部署您的代码,您可以使用以下命令:

    gcloud compute scp --recurse my_code_local/ $INSTANCE_ID:~ --zone $ZONE
    

    或者按照Cloud Build 的思路研究解决方案。

    要从您的 Python 应用程序向 Google Cloud Storage Bucket 上传或下载数据,您只需使用Cloud Storage Client Libraries

    还有with links的例子,用它来进行下载和上传操作。

    【讨论】:

      猜你喜欢
      • 2018-02-16
      • 1970-01-01
      • 1970-01-01
      • 2023-02-23
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-15
      相关资源
      最近更新 更多