Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

A Whirlwind Tour of RNNs with Docker (the easy way)

Tags: docker

RNN on Windows 10: Docker

I created an Azure Container Registry (ACR) to store a Docker container image of Cristian Baldi’s Docker-torch-rnn (which uses Justin Johnson’s “torch-rnn” project, a refactoring of Andrej Karpathy’s “char-rnn.”) An ACR allows for the use of open-source Docker command line interface (CLI) tools, and keeps container images near deployments to reduce latency and costs.

Step 0) Prerequisites

  • Docker CLI. To set up your local computer as a Docker host and access the Docker CLI commands, install Docker Engine before starting this workshop. https://docs.docker.com/engine/installation/
  • Windows. This workshop contains screenshots from a Windows 10 Enterprise PC with the latest updates.
  • Bash on Ubuntu on Windows is the preferred CLI for this workshop. https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10

Step 1) Start Docker

Start Docker by clicking the Whale icon. Bash on Ubuntu on Windows is preferred for typing Docker commands. If your Docker commands don’t work in Bash, try restarting your computer, or using Windows PowerShell.

Note: Make sure the white whale in your task bar is set for using Linux. If you right click it and it says “Switch to Windows containers,” leave it alone; you are good to go.

Docker must be running with "Expose daemon on tcp://localhost:2375 without TLS" enabled. (Right click on the system tray icon then "Settings..."). This is not checked by default, so you must check it.

Step 2) Run Image

Writing “docker -v” as your first command will ensure your Docker commands are working by showing you which version and build of Docker your machine is running.

To connect a docker client to Docker for Windows, keep in mind that Docker for Windows runs a Linux Hyper-V VM where it starts the daemon.

export DOCKER_HOST=tcp://127.0.0.1:2375 

To pull or run Sarah’s pre-trained Docker snapshot to avoid waiting for hours, type:

docker pull saelia/rnn-js
docker run -it saelia/rnn-js /bin/bash

Adding ./bin/bash to the end will give you a bash terminal to work in.

To show all docker containers - sudo docker ps -a
To start docker container - sudo docker start
To attach to docker container - sudo docker attach

Step 3) Sample Text

The way to actually make the RNN generate new text is with the data sampling script[1]:

th sample.lua -gpu -1 -checkpoint cv/checkpoint_12900.t7 -length 150 -temperature .7

Figure 1: "The mind the same hath so much but promise the brother." - Catesby, William Fakespeare

Sample Flags

GPU: Setting the flag gpu to -1 tells the code to train using CPU; otherwise it defaults to GPU 0.
Length: An important flag is -length. 100 would generate a body of text 100 characters in length. The default is 2000.
Temperature: An important parameter you may want to play with is -temperature, which takes a number in range (0 to 1, 0 not included), default = 1. Lower temperature will cause the model to make more “likely” but more boring and conservative predictions. Higher temperatures cause the model to take more chances and increase diversity of results, but at a cost of more mistakes.
[1] sample.lua

Shutting Down

How to turn off Docker: Type “exit”, Close PowerShell. Right click the white whale in your task bar. Sign out / quit Docker.

Share the post

A Whirlwind Tour of RNNs with Docker (the easy way)

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×