【发布时间】:2020-10-26 12:59:16
【问题描述】:
我在 tensorflow 中使用 jupyter 挂载本地文件夹时遇到问题。
我使用 Ubuntu 20.04。我为 tensorflow 容器安装了所有必需品。 但是当我尝试用它挂载本地文件夹时,我会打开默认文件夹而不是本地文件夹。
这是我的 bash 命令。
docker run --gpus all -it --rm v$(pwd)/home/peter/Documents/python:/tf/notebooks -p 8888:8888 tensorflow/tensorflow:latest-gpu-jupyter
有什么错误吗? 提前谢谢你。
编辑
这是我的狂欢。它仍然显示默认目录。
(base) peter@peterpc:~/Documents$ docker run -d --rm --gpus all -p 8888:8888 -v $PWD/python:/tf/notebooks tensorflow/tensorflow:latest-gpu-jupyter
dbf0debcaf3ebcd409ed3d2c73f61e12a59bef9d4cf31090656c6a9462a4acfb
(base) peter@peterpc:~/Documents$ docker log
docker: 'log' is not a docker command.
See 'docker --help'
(base) peter@peterpc:~/Documents$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dbf0debcaf3e tensorflow/tensorflow:latest-gpu-jupyter "bash -c 'source /et…" 26 seconds ago Up 24 seconds 0.0.0.0:8888->8888/tcp clever_solomon
(base) peter@peterpc:~/Documents$ docker logs dbf0debcaf3e
[I 12:12:15.498 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[I 12:12:15.698 NotebookApp] Serving notebooks from local directory: /tf
[I 12:12:15.698 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 12:12:15.698 NotebookApp] http://dbf0debcaf3e:8888/?token=066b76ca68eb22fe1cdd1e02f65c7a58f4cd713be19e3516
[I 12:12:15.698 NotebookApp] or http://127.0.0.1:8888/?token=066b76ca68eb22fe1cdd1e02f65c7a58f4cd713be19e3516
[I 12:12:15.698 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:12:15.701 NotebookApp]
To access the notebook, open this file in a browser:
file:///root/.local/share/jupyter/runtime/nbserver-1-open.html
Or copy and paste one of these URLs:
http://dbf0debcaf3e:8888/?token=066b76ca68eb22fe1cdd1e02f65c7a58f4cd713be19e3516
or http://127.0.0.1:8888/?token=066b76ca68eb22fe1cdd1e02f65c7a58f4cd713be19e3516
再次编辑
我在 root 的 notebooks 文件夹中找到了它。我不知道。谢谢你的回答。
【问题讨论】:
-
您正在交互式终端
-it模式下启动容器,因此您应该传递任何启动命令,例如 tensorflow 命令或 bash 或 sh。卷映射的参数是-v <host dir/file>:<container dir/file>。请将您的docker run命令更正为:docker run -d --rm --gpus all -p 8888:8888 -v $PWD/python:/tf/notebooks tensorflow/tensorflow:latest-gpu-jupyter,其中 $PWD 是您的当前目录(它代表 Linux 中的 打印工作目录) -
我尝试使用该命令,但它仍然显示默认目录。
-
谢谢你,我现在知道 $PWD 是当前目录。
标签: docker tensorflow jupyter-notebook