Step-by-Step Instructions for Mac OS X
February 6, 2019 ยท View on GitHub
These instructions enable you to run TensorFlow code from the comfort of interactive Jupyter notebooks. Jupyter is itself run from within a Docker container because this ensures that you'll have all of the software dependencies you need while simultaneously preventing these dependencies from clashing with the software you already have installed on your system.
Install
- Open the Terminal application (like this)
- To install in your home directory (this is my recommended default):
- Type
cd ~into the command-line prompt and - Execute the line by pressing the return key on your keyboard
- Type
- Retrieve all of the code for this LiveLessons by executing
git clone https://github.com/the-deep-learners/TensorFlow-LiveLessons.git(if you haven't usedgitbefore, you may be prompted to install Xcode -- do it!) - Install the Docker "Stable channel" (if you are already using an older version of Docker and run into installation issues downstream, try updating to the latest version of Docker)
- Start Docker, e.g., by using Finder to navigate to your Applications folder and double-clicking on the Docker icon
- Back in Terminal, execute
source TensorFlow-LiveLessons/installation/let_jovyan_write.shso that you can write to files in the TensorFlow-LiveLessons directory from inside the Docker container we'll be creating momentarily - Move into the TensorFlow-LiveLessons directory by executing
cd TensorFlow-LiveLessons - Build the Docker container by executing
sudo docker build -t tensorflow-ll-stack .(you'll get an error if you miss the final.!) - When that build process has finished, run the Docker container by executing
sudo docker run -v $(pwd):/home/jovyan/work -it --rm -p 8888:8888 tensorflow-ll-stack - In the web browser of your choice (e.g., Chrome), copy and paste the URL created by Docker (this begins with
http://localhost:8888/?token=and should be visible near the bottom of your Terminal window)
Shutdown
You can shutdown the Jupyter notebook by returning to the Terminal session that is running it and hitting the control and c keys simultaneously on your keyboard.
Restart
You can restart the Jupyter notebook later by following steps nine and ten alone.
Bonus: Training Models with an Nvidia GPU
You don't need to train your Deep Learning models with a GPU for this course, but some of the later notebooks in these LiveLessons will run much more quickly if you do.
- Install an Nvidia GPU on your machine or spin up a cloud instance that includes one (typically a Tesla K80)
- Install CUDA and cuDNN, e.g., per the Installing CUDA Toolkit and Installing cuDNN sections of this blog post (this step may be tricky if you're relatively new to working with the Unix command line)
- In the
TensorFlow-LiveLessons/installation/docker-stack-scriptsdirectory:- run
chmod 777 jupyter_notebook_config.py start*.sh
- run
- Replace step eight of my Install section above with
sudo docker build -f Dockerfile-gpu -t tfll-gpu-stack . - Replace step nine with
sudo nvidia-docker run -v $(pwd):/home/jovyan/work -it --rm -p 8888:8888 tfll-gpu-stack
Bonus: Using a Pre-Built Docker Image
Instead of building a Docker image on your own machine, Godefroy Clair is kindly hosting a pre-built Docker image. In place of the sudo docker build... steps in the above instructions, you could instead run:
docker pull godot80/tf-livelessons-no-gpu:latestfor the CPU-only version, ordocker pull godot80/tf-livelessons:latestfor the Nvidia GPU version