简体   繁体   English

通过在单独的 Z05B6053C41A2130AFDZ6FCDAE1 中运行的 R 实例在本地保存 R model

[英]Save R model locally through an R instance running in a separate docker container?

Hi I am currently building some models using R connected to a remote h2o instance running in a docker container.嗨,我目前正在使用 R 构建一些模型,该模型连接到在 docker 容器中运行的远程 h2o 实例。

I am at a point where I would like to iterate through a leaderboard of models and h2o.saveModel() each model to my local computer.我现在想通过模型排行榜和 h2o.saveModel() 每个 model 迭代到我的本地计算机。

However, since saveModel() saves to the computer running h2o, my models are being saved within the docker container.但是,由于 saveModel() 保存到运行 h2o 的计算机,我的模型被保存在 docker 容器中。

The solution I have come up with is to scp all the model files to my computer after h2o has finished running them, however I was wondering if anyone out there had run into this problem and had come up with a better solution.我想出的解决方案是在 h2o 完成运行后将所有 model 文件 scp 到我的计算机,但是我想知道是否有人遇到过这个问题并想出了更好的解决方案。

Note: Running a local h2o instance for building the models is not an option注意:运行本地 h2o 实例来构建模型不是一种选择

Thank you for the help感谢您的帮助

This implementation is a good use case to leverage docker volumes.此实现是利用 docker 卷的良好用例。

Create an external volume and mount/bind it to the location where the model is being saved.创建一个外部卷并将其安装/绑定到保存 model 的位置。

https://docs.docker.com/storage/volumes/ https://docs.docker.com/storage/volumes/

For anyone that might run into this problem in the future, I used the R ssh library ( https://www.rdocumentation.org/packages/ssh/versions/0.6 ) to solve the problem.对于将来可能遇到此问题的任何人,我使用了 R ssh 库( https://www.rdocumentation.org/packages )来解决问题。

After saving all my models I run a docker cp command to copy the files from the docker container to the host running the docker.保存所有模型后,我运行 docker cp 命令将文件从 docker 容器复制到运行 docker 的主机。

Then I used the scp_download function from the ssh library to download the files to my computer.然后我使用 ssh 库中的 scp_download function 将文件下载到我的计算机。

Finally, I ran 2 ssh_exec_wait functions to delete the folders created on the the docker host as well as in the docker container itself.最后,我运行了 2 个 ssh_exec_wait 函数来删除在 docker 主机以及 docker 容器本身中创建的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM