我已经使用 Google Colab 来计算我的 Kaggle 比赛,现在我决定看看它是否可以使用 Google Cloud 上的服务更快地工作。我有一个*.ipybn
来自 Google Cloud的文件,已下载并尝试将其上传到 Google Cloud 实例。
我使用以下链接在 Google Colab 上创建了所有连接:https ://towardsdatascience.com/setting-up-kaggle-in-google-colab-ebb281b61463并且运行良好。
使用本教程:https : //towardsdatascience.com/how-to-use-jupyter-on-a-google-cloud-vm-5ba1b473f4c2 我为 Jupyter notebook 启动了一个新实例。上传了一个*ipybn
文件,我尝试安装 Kaggle 并运行我的笔记本,但我通常会出现以下错误:
kaggle: command not found error
ensure that your python binaries are on your path
如何将所有内容设置为在 Google Cloud 服务上运行?
使用第一个教程注意将根目录路径从 更改content
为/home/jupyter/
,例如:
import zipfile
zip_ref = zipfile.ZipFile("/home/jupyter/Airbus_competition/input/test_v2.zip", 'r')
zip_ref.extractall("/home/jupyter/Airbus_competition/input/test_v2")
zip_ref.close()
有关安装kaggle的问题,您不必访问来自Jupyter笔记本根文件夹,但您可以安装并使用Kaggle API,当你从改变命令!kaggle
来!~/.local/bin/kaggle
,例如(从教程命令改变为工作GCS):
!mkdir ~/.kaggle
import json
token = {"your_TOKEN"}
with open('/home/jupyter/.kaggle/kaggle.json', 'w') as file:
json.dump(token, file)!cp /home/jupyter/.kaggle/kaggle.json
~/.kaggle/kaggle.json
!~/.local/bin/kaggle config set -n path -v{home/jupyter/Airbus_competition}
!chmod 600 /home/jupyter/.kaggle/kaggle.json
!~/.local/bin/kaggle competitions download -c airbus-ship-detection -p /home/jupyter/Airbus_competition/input --force
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句