使用Docker从源代码构建Tensorflow [英] Building tensorflow from source with Docker
问题描述
很抱歉这个基本问题,这里有点Docker noob.
Sorry for this basic question, bit of a Docker noob here.
我正在尝试按照Docker指令从源代码构建tensorflow :
I'm trying to build tensorflow from source following the Docker instructions:
docker pull tensorflow/tensorflow:开发
docker pull tensorflow/tensorflow:devel
docker run -it -w/tensorflow -v $ PWD:/mnt -e HOST_PERMS ="$(id -u):$(id -g)" \tensorflow/tensorflow:开发bash
docker run -it -w /tensorflow -v $PWD:/mnt -e HOST_PERMS="$(id -u):$(id -g)" \ tensorflow/tensorflow:devel bash
在容器中使用git pull#,下载最新的源代码
git pull # within the container, download the latest source code
以下是我在终端(在Ubuntu上)中运行的命令以及它们的输出:
Here are the commands I run in the terminal (on Ubuntu), along with their output:
$ docker --version
Docker version 19.03.2, build 6a30dfc
$ docker pull tensorflow/tensorflow:devel
devel: Pulling from tensorflow/tensorflow
Digest: sha256:0ee065743f0001f922561bcba914013929a88263ec2a5af21ba35899c3ac85a7
Status: Image is up to date for tensorflow/tensorflow:devel
docker.io/tensorflow/tensorflow:devel
$ docker run -it -w /tensorflow -v $PWD:/mnt -e HOST_PERMS="$(id -u):$(id -g)" \
> tensorflow/tensorflow:devel bash
________ _______________
___ __/__________________________________ ____/__ /________ __
__ / _ _ \_ __ \_ ___/ __ \_ ___/_ /_ __ /_ __ \_ | /| / /
_ / / __/ / / /(__ )/ /_/ / / _ __/ _ / / /_/ /_ |/ |/ /
/_/ \___//_/ /_//____/ \____//_/ /_/ /_/ \____/____/|__/
WARNING: You are running this container as root, which can cause new files in
mounted volumes to be created as the root user on your host machine.
To avoid this, run the container by specifying your user's userid:
$ docker run -u $(id -u):$(id -g) args...
root@4746a002f18e:/tensorflow#
但是现在,如果我按照指示运行 git pull
,我会得到
But now, if I run git pull
as instructed, I get
fatal: not a git repository (or any of the parent directories): .git
我应该如何运行这些命令?
How should I instead be running these commands?
推荐答案
您所引用的文档似乎与图像的当前布局未对齐.安装tensorflow源的正确文件夹是/tensorflow_src
.
It looks like the doc your referenced is not aligned with the current layout of the image. The correct folder where tensorflow sources are installed is /tensorflow_src
.
只需在您的 docker run
命令行中更改选项=> -w/tensorflow_src
(或在容器中一次
Just change the option in your docker run
command line => -w /tensorflow_src
(or cd /tensorflow_src
once in the container), and you should immediately be able to pull.
我这边的测试
$ docker run -it --rm -w /tensorflow_src -v $PWD:/mnt -e HOST_PERMS="$(id -u):$(id -g)" tensorflow/tensorflow:devel bash
________ _______________
___ __/__________________________________ ____/__ /________ __
__ / _ _ \_ __ \_ ___/ __ \_ ___/_ /_ __ /_ __ \_ | /| / /
_ / / __/ / / /(__ )/ /_/ / / _ __/ _ / / /_/ /_ |/ |/ /
/_/ \___//_/ /_//____/ \____//_/ /_/ /_/ \____/____/|__/
WARNING: You are running this container as root, which can cause new files in
mounted volumes to be created as the root user on your host machine.
To avoid this, run the container by specifying your user's userid:
$ docker run -u $(id -u):$(id -g) args...
root@2f5660528e98:/tensorflow_src# git pull
remote: Enumerating objects: 7328, done.
remote: Counting objects: 100% (7328/7328), done.
remote: Total 12261 (delta 7328), reused 7328 (delta 7328), pack-reused 4933
Receiving objects: 100% (12261/12261), 8.59 MiB | 8.19 MiB/s, done.
Resolving deltas: 100% (10031/10031), completed with 2861 local objects.
这篇关于使用Docker从源代码构建Tensorflow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!