id: 12680    nodeId: 12680    type: General    point: 174.0    linkPoint: 1.0    maker: cella    permission: linkable    made at: 2020.03.24 05:09    edited at: 2023.03.09 11:41
how to install and use Tensorflow docker container
https://www.tensorflow.org/install/docker
1. install Docker

2. run Docker daemon
in Mac, run Docker app.

3. pull docker container from https://hub.docker.com/r/tensorflow/tensorflow/tags
like 2.1.1, or 2.2.0-jupyter for machines without GPU OR 2.1.1-gpu with GPU.

$ docker pull tensorflow/tensorflow:2.4.0-jupyter
2.0 does not contain python3

4. check the container image

$ docker image ls

5. docker run the container

change the current directory to the working directory and then
(Don't use /tmp as working directory. It causes error since it conflicts to the original /tmp in Linux.)

$ docker run -it --rm -v $PWD:/w -w /w tensorflow/tensorflow:2.4.0-jupyter bash

or to execute a command in bash without docker prompt (you can logout from ssh in this way)
$ docker run -it --rm -v $PWD:/w -w /w tf2_4_1-pandas-seaborn bash -c "python ddpg_main.py &> o31" &

or to use GPU
$ docker run --runtime=nvidia -it --rm -v $PWD:/w -w /w tensorflow/tensorflow:latest-gpu-jupyter bash


6. customize the container like using "pip install" and save it

outside of container,
$ docker ps -a
list of docker images...

$ docker commit [CONTAINER_ID] [new_image_name]


======== customization history

-------- 2021-06-10 (this is with TF version 2.5.0)
$ docker run --runtime=nvidia -it --rm -v $PWD:/w -w /w tensorflow/tensorflow:latest-gpu-jupyter bash

# pip install pandas
# pip install seaborn
# pip install scikit-learn

$ docker commit [CONTAINER ID] tf2_5_0-sklearn

-------- 2023-03-09 (to run a container named tf2_9_1 and run python command)
$ docker run --gpus all -i --rm -v $PWD:/w -w /w tf2_9_1 /bin/bash -c "python main.py -m 0 &> oo; python main.py -m 2 >> oo 2>&1"

Return to Wadia 170iTransport iPod digital dock or how to install and use Tensorflow docker container