简体   繁体   English

无法更改在 tensorflow docker 容器上运行的 jupyter 笔记本的工作目录

[英]Unable to change working directory for a jupyter notebook running on a tensorflow docker container

I have followed the steps in the official CUDA on WSL tutorial ( https://docs.nvidia.com/cuda/wsl-user-guide/index.html#ch05-sub02-jupyter ) to set up a jupyter notebook.我已按照官方 CUDA on WSL 教程 ( https://docs.nvidia.com/cuda/wsl-user-guide/index.html#ch05-sub02-jupyter ) 中的步骤设置了一个 jupyter notebook。 However, I can't figure out how to change the initial working directory.但是,我不知道如何更改初始工作目录。 I tried mounting a local directory with the -v switch as well as appending to the launch command --notebook-dir , but neither one of these solutions worked.我尝试使用-v开关安装本地目录以及附加到启动命令--notebook-dir ,但这些解决方案都没有奏效。 The jupyter notebook will always start under "/tf" no matter what I do.无论我做什么,jupyter 笔记本都将始终在“/tf”下启动。 Ideally, I would like this to be the same working directory as the one I have on Windows (C:\Users\MyUser).理想情况下,我希望它与我在 Windows 上的工作目录 (C:\Users\MyUser) 相同。

The only thing I haven't tried is changing the WORKDIR in the docker image "tensorflow/tensorflow:latest-gpu-py3-jupyter" supplied by hub.docker.com as I am not even sure if it is possible to edit it (line 57).我唯一没有尝试过的是更改 hub.docker.com 提供的 docker 映像“tensorflow/tensorflow:latest-gpu-py3-jupyter”中的 WORKDIR,因为我什至不确定是否可以编辑它(第 57 行)。

Here is a sample command I have tried running:这是我尝试运行的示例命令:

docker run -it --gpus all -p 8888:8888 -v /c/Users/MyUser/MyFolder:/home/MyFolder/ tensorflow/tensorflow:latest-gpu-py3-jupyter jupyter notebook --allow-root --ip=0.0.0.0 --NotebookApp.allow_origin='https://colab.research.google.com' --notebook-dir=/c/Users/MyUser/

What is the easiest way to achieve this?实现这一目标的最简单方法是什么?

I was able to solve this problem by mounting the directory I want to work in under the local directory that is given in the command "Serving notebooks from local directory:/tf".我能够通过在命令“从本地目录提供笔记本:/tf”中给出的本地目录下安装我想要工作的目录来解决这个问题。 In my case it's ' /tf ', but yours could be different.就我而言,它是“ /tf ”,但您的可能会有所不同。 In addition, I changed the first '/' to '//'.另外,我把第一个'/'改成了'//'。 Also, the container name should be the last argument (per https://stackoverflow.com/a/34503625 ).此外,容器名称应该是最后一个参数(根据https://stackoverflow.com/a/34503625 )。 So in your case, the command looks like:因此,在您的情况下,命令如下所示:

docker run -it --gpus all -p 8888:8888 -v //c/Users/MyUser/MyFolder:/tf/home/MyFolder tensorflow/tensorflow:latest-gpu-py3-jupyter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM