Docker GPU
How to get Docker working for GPU
Ref:
https://github.com/NVIDIA/nvidia-docker
https://github.com/NVIDIA/nvidia-docker/wiki/NVIDIA-driver
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/docker
https://github.com/floydhub/dl-dockerFIrst clone the tensorflow module
The directory inside this:
tensorflow/tools/docker
has the Dockerfile which we will use to install tensorflow for GPU
But, the tensorflow installation using pip does not work, so comment those lines as shown
# Install TensorFlow GPU version.
#RUN pip --no-cache-dir install \
#http://storage.googleapis.com/tensorflow/linux/gpu/tensorflow\_gpu-0.0.0-cp27-none-linux\_x86\_64.whl
And add this at the top of the file:
FROM gcr.io/tensorflow/tensorflow:latest-gpu
Latest setup for AWS p2.xlarge instance:
The modified Dockerfile for GPU looks like:
Next execute:
BUILD THE IMAGE:
docker build -t custom-agshift-docker-image-gpu .
RUN THE IMAGE
nvidia-docker run -p 8888:8888 -p 6006:6006 --name custy-agshift-gpu -it -v /home/ubuntu/tf_files:/tf_files custom-agshift-docker-image-gpu
THEN FROM DOCKER BASH, RUN
nohup ./run_jupyter.sh --allow-root > tf_files/nohup.out 2>&1 < /dev/null &
INSTALL OPENCV
Follow the instructions here: http://milq.github.io/install-opencv-ubuntu-debian/
The above did not work for me. So I created an install script following instructions on OpenCV website
AWS GPU instance
http://ec2-35-164-187-208.us-west-2.compute.amazonaws.com:8888/?token=927d17004747094e5d7aa123342e99e5afcd3ee6a65ea1ea
Note:
If the web browser does not connect to jupyter session, make sure that the EC2 instance has the correct 'security group' with the ports opened up.
STOP INSTANCE, RESTART INSTANCE, START DOCKER and then RE_RUN jupyter
When the GPU instance is stopped and then restarted, it assigns a new public DNS.
So the previous way of connecting to AWS EC2 instance won't work. Just change the DNS name in the 'ssh command'
Everything else remains the same. All files, docker stays intact. If we do the following we will see that everything is the same
To start another docker shell using the same container id, but avoiding clash with co-user
Enabling GPU's in container ecosystem
Last updated
Was this helpful?