How to run a new Jupyter Notebook file that's

2019-09-15 05:53发布

问题:

I am new to Docker. In order to take the Udacity Deep Learning course, I had to set up TensorFlow on my Windows machine using Docker. (Although TensorFlow is now available on Windows, it only supports Python 3.5, however the Udacity course material requires Python 2.7. Therefore, I have to stick with the Docker way of using TensorFlow.)

To work on the assignments, I followed the instructions here as detailed below:

  • First, I installed docker toolbox.
  • Then, I launch Docker using the Docker Quickstart Terminal. For the first time, I ran:

docker run -p 8888:8888 --name tensorflow-udacity -it gcr.io/tensorflow/udacity-assignments:0.6.0.

Each time after, I just run this in my docker terminal:

docker start -ai tensorflow-udacity

  • Finally, in the address bar, with http://192.168.99.100:8888 I get the assignment Jupyter notebooks up and running (see image below).

However, what I want now is to run the final project of the course which is not part of the pre-built Udacity docker image. How can I do that? The final project can be found here, with the "digit_recognition.ipynb" specifically being the file to run in docker.

Any guidance is much appreciated.

回答1:

First of all, you need a way to get this Jupyter notebook (final project) on your Docker instance.

What is an easy way to copy a file inside of a Docker container? Well, not a lot.

  • We could attach a volume.
  • We could rewrite the Dockerfile to include the final project.
  • We could also enter in the Docker container and download the file.

I am going to detail the last one, but, don't forget that there are many solutions to one problem.

How do we enter in the Docker container?

docker exec -it [container-id] bash

How can we get the [container-id] ?

docker ps

It will show you a list of containers, match the one you want to enter in.

Once you're in your container. How can we download the file we want?

We should try to figure out if we have wget or curl utilities to download a file. If we don't, we have to install them from any package manager available (try apt-get, if it works, do: apt-get install wget).

Once we have something to download files from the Internet, we have to find out where the notebooks are stored. That is the difficult part.

Look for any folder which might contain, there could also be some kind of magic one liner to type using find, unfortunately, I am no magic wizard anymore.

Let's assume you are in the good folder.

wget https://raw.githubusercontent.com/udacity/machine-learning/master/projects/digit_recognition/digit_recognition.ipynb

That's all! Reload your page and you should see the notebook displayed.

Side-note: You might also need to install extra dependencies in the container.



回答2:

An alternative and much easier way is this:

  • Just start up your container like this: $ docker start -ai tensorflow-udacity
  • Then, click the upload button and locate the final project iPython Notebook file and upload it.

That's it. Whatever changes you make will be retained and you'll be able to see the new file in the container going forward!