Myc*_*cha 1 google-cloud-platform gcp-ai-platform-notebook
我的目标是能够使用 Python3.8 在 JupyterLab 中启动 JupyterNotebook
在 GCP AI Platform Jupyter Notebooks 中将 Python 版本更新为 3.8
AI Platform Notebooks 环境由您在创建实例时选择的容器映像提供。在此页面中,您将看到可用的容器映像类型。
为了指定要在笔记本上运行的容器映像,您可以选择使用上面提到的 Google Cloud 提供的列表之一,或者如果它们都没有随 Python 3.8 提供,您可以基于以下之一创建衍生容器标准 AI Platform 映像并编辑 Dockerfile 以设置 Python 3.8 安装命令。
为了测试它,我对提供的容器映像进行了小的修改,以在 JupyterLab 中加入 Python 3.8 内核。为了做到这一点,我创建了一个 Dockerfile,它执行以下操作:
构建映像并将其推送到 Google Container Registry 后,您将能够使用新内核创建 AI Platform Jupyter Notebook。
代码如下:
FROM gcr.io/deeplearning-platform-release/tf-gpu:latest
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y apt-
transport-https \
&& apt-get install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev
libnss3-dev libssl-dev libreadline-dev libffi-dev wget libbz2-dev \
&& wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
RUN tar xzf Python-3.8.0.tgz \
&& echo Getting inside folder \
&& cd Python-3.8.0 \
&& ./configure --enable-optimizations \
&& make -j 8 \
&& make altinstall \
&& apt-get install -y python3-venv \
&& echo Creating environment... \
&& python3.8 -m venv testenv \
&& echo Activating environment... \
&& . testenv/bin/activate \
&& echo Installing jupyter... \
&& pip install jupyter \
&& pip install ipython \
&& apt-get update -y \
&& apt-get upgrade -y \
&& ipython kernel install --name "Python3.8" --user
Run Code Online (Sandbox Code Playgroud)
如果您需要它,您还可以指定一个自定义映像,以允许您根据您的特定需求自定义环境。考虑到该产品处于测试阶段,可能会发生变化或支持有限。
| 归档时间: |
|
| 查看次数: |
999 次 |
| 最近记录: |