[英]How do I run a python script with Tensorflow running in a Docker on Windows?
Imagine I manage to install Tensorflow on Windows, using Docker as in these two links, for example: 想象一下,我设法在Windows上安装Tensorflow,使用Docker作为这两个链接,例如:
TensorFlow on Windows Windows上的TensorFlow
How to install and run TensorFlow on a Windows PC 如何在Windows PC上安装和运行TensorFlow
In both links, they're able to use Tensorflow on a shell python (don't know exactly what version, I have Anaconda installed). 在这两个链接中,他们能够在shell python上使用Tensorflow(不知道究竟是什么版本,我安装了Anaconda)。
But what if I want to run a script that I made on my local machine that has Tensorflow in it? 但是,如果我想在我的本地机器上运行一个包含Tensorflow的脚本呢? How do I call the script from docker? 如何从docker调用脚本? I mean, how do I find the script (located on my desktop, for instance) from docker to run it? 我的意思是,如何从docker中找到脚本(例如,位于我的桌面上)来运行它?
If you want your container (that has Tensorflow already preinstalled, since it is running from the Tensorflow image) to access your script, you need to mount that script from your host onto a local path in your container. 如果您希望容器(已预先安装Tensorflow,因为它是从Tensorflow映像运行)来访问您的脚本,则需要将该脚本从主机安装到容器中的本地路径上。
docker run -v /path/to/your/script:/path/to/script
See " Mount a host file as a data volume ". 请参阅“ 将主机文件挂载为数据卷 ”。
The
-v
flag can also be used to mount a single file - instead of just directories - from the host machine.-v
标志还可用于从主机安装单个文件 - 而不仅仅是目录。
$ docker run --rm -it -v ~/.bash_history:/.bash_history ubuntu /bin/bash
Then, from your container, you will access the same script in /path/to/script
. 然后,从容器中,您将访问/path/to/script
的相同/path/to/script
。
Alex Pryiomka gives an example of running such a script in tensorflow with " How to run Python Scripts on Mac Terminal using Docker with Tensorflow? " Alex Pryiomka给出了一个在tensorflow中运行这样一个脚本的例子:“ 如何使用具有Tensorflow的Docker在Mac终端上运行Python脚本? ”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.