简体   繁体   English

如何在Windows上的Docker中运行Tensorflow运行python脚本?

[英]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.

相关问题 我如何安排Python脚本在Windows XP运行时一直运行? - How do I schedule a Python script to run as long as Windows XP is running? 如何在 Docker 容器中运行本地 Python 脚本? - How do I run a local Python script in a Docker container? 如何检测我的 Python 脚本是否在“Windows 终端”中运行 - How do I detect if my Python script is running in the 'Windows Terminal' 如何使用已经运行的blender运行python脚本? - How do I run a python script using an already running blender? 如何打包在Windows上运行的python脚本? - How do I package a python script to run on Windows? 如何在Windows上运行python脚本? - How can I run a python script on windows? 如何从在 docker 容器中运行的 python selenium 脚本在主机上打开 chrome? - How do I open chrome on the host from a python selenium script running in a docker container? 如何使用在 docker 容器中运行的 python 脚本创建(dockerized)Elasticsearch 索引? - How do I create a (dockerized) Elasticsearch index using a python script running in a docker container? 如何限制在docker容器中运行的ffmpeg的资源(从python脚本调用)? - How do I limit resources for ffmpeg, called from a python-script, running in a docker container? 如何像运行Windows服务一样运行python服务脚本? - How can I run python service script like a running windows service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM