Swift for tensorflow using GPU with nvidia docker

(Stefano Giomo) #1

INSTALL

  1. Install nvidia docker from nvidia website: https://github.com/NVIDIA/nvidia-docker.

    NOTE: be sure to see the result of nvidia smi on test container after install.

  2. Clone https://github.com/google/swift-jupyter and build nvidia docker image

git clone https://github.com/google/swift-jupyter.git

cd swift-jupyter

# from inside the directory of this repository
docker build -f docker/Dockerfile -t swift-jupyter .
  1. Launch docker daemon:
sudo systemctl start docker

RUN

To run your docker container using –runtime=nvidia option:

# docker_swift_jupyter_start.sh
docker run --runtime=nvidia -p 8899:8888 --cap-add SYS_PTRACE -v /home/notebooks:/notebooks swift-jupyter
  • Tested on ubuntu 16.04.

nvidia-smi

It works like a charm, monitoring a new “PID” for any S4TF notebook using GPU.

SSH INTO RUNNING DOCKER

# docker_swift_jupyter_ssh_into_container.sh
containerId=$(sudo docker ps -qf "ancestor=swift-jupyter")
echo Connecting to container: ${containerId}
sudo docker exec -it ${containerId} /bin/bash

CAVEATS

If you get the error "expecting number but found string"

As @stas said in this posts:

...
"execution_count": null,
...

Run this script in the root of “fastai_docs” to fix the problem:

perl -pi -e 's|execution_count": null|execution_count": 1|g' dev_swift/*ipynb
8 Likes

After updating fastai library all dl1 notebooks are truncated