python - 如何在创建 ai 平台笔记本时安装 python 库
问题描述
当我在 GCP 中创建笔记本实例时,我想使用“选择要在创建后运行的脚本”。
具体来说,我想用它来安装 python 包。
我需要编写什么样的脚本(扩展名和内容)?
解决方案
这将是安装 Voila 的 Post 启动脚本的示例。将此文件保存在 GCS 存储桶中,并在创建 Notebook 时定义路径,例如:
gcloud notebooks instances create nb-1 \
'--vm-image-project=deeplearning-platform-release' \
'--vm-image-family=tf2-latest-cpu' \
'--metadata=post-startup-script=gs://ai-platform-notebooks-tools/install-voila.sh' \
'--location=us-central1-a'
脚本内容:
#!/bin/bash -eu
# Installs Voila in AI Platform Notebook
function install_voila() {
echo 'Installing voila...'
/opt/conda/condabin/conda install -y -c conda-forge ipywidgets ipyvolume bqplot scipy
/opt/conda/condabin/conda install -y -c conda-forge voila
/opt/conda/bin/jupyter lab build
systemctl restart jupyter.service || echo 'Error restarting jupyter.service.'
}
function download_samples() {
echo 'Downloading samples...'
cd /home/jupyter
git clone https://github.com/voila-dashboards/voila
}
function main() {
install_voila || echo 'Error installing voila.'
download_samples || echo 'Error downloading voila samples.'
}
main
推荐阅读
- docker - 无法启动 docker-deploy-hdp30.sh 并出现错误:没有这样的容器:sandbox-hdp
- javascript - JS:不确定何时使用 Promise.resolve() 与返回新的 Promise
- google-drive-api - Google Drive Api 无法列出我的评论
- python-3.x - 如何将列表排序为给定大小的块?
- codenameone - How to get Content-Length from response headers in CN1?
- termux - How to get "$" on termux terminal?
- r - R devtools: package documentation on first page of the manual
- python - pandas - series.str.extract is dropping the first character of the capture group
- json - 如何根据其他 JSON 值获取 JSON 值
- python - How can I write a algorithm that finds how many of a certain number is in a row in a list in python?