如何使用Docker与Tensorflow在Mac终端上运行Python脚本? [英] How to run Python Scripts on Mac Terminal using Docker with Tensorflow?

查看:365
本文介绍了如何使用Docker与Tensorflow在Mac终端上运行Python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从Mac转移到Windows,并使用Docker安装了Tensorflow,并且一切正常,但是我想要运行一个我以前的python脚本。有没有办法使用终端在Mac上的docker中运行python脚本?

I just got a Mac and shifted from Windows and installed Tensorflow using Docker and everything is working fine, but I want to run a python script that I have from before. Is there any way to run a python script in docker on a Mac, using the terminal?

推荐答案

...

创建具有以下内容的Docker文件:

Create a Dockerfile with the below content:

FROM gcr.io/tensorflow/tensorflow:latest
COPY script.py /usr/bin/
CMD ["python", "/usr/bin/script.py"]

构建图像:

$ docker build -t mytensorflow .

运行它:

$ docker run -it --rm mytensorflow

如果你想保留运行脚本后的容器不要--rm它...

if you want to keep the container going after the script is run don't --rm it...

这篇关于如何使用Docker与Tensorflow在Mac终端上运行Python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆