Skip to content

Instantly share code, notes, and snippets.

@eomiso
Last active April 19, 2022 13:38
Show Gist options
  • Select an option

  • Save eomiso/74b206668f3bab89de3b67c11b6dda36 to your computer and use it in GitHub Desktop.

Select an option

Save eomiso/74b206668f3bab89de3b67c11b6dda36 to your computer and use it in GitHub Desktop.
How to create docker for machine learning that supports tensorboard, and jupyter

How to create docker container for machine learning that supports tensorboard, and jupyter

When creating a container, forward two ports 22 (for ssh) and 6006 (for Tensorboard) and 8888 (for jupyter).

docker run -ti --runtime=nvidia --gpus all -p 8082:22 -p 8083:6006 -p 8084:8888 nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04 /bin/bash

you may need to install these

apt update
apt install net-tools
apt install openssh-server
service ssh start

When accessing by ssh

ssh <user>@<host> -p 8082

Access through localhost In a remote container, run Tensorboard with 6006 (the default port).

tensorboard --logdir lightning_logs
TensorFlow installation not found - running with reduced feature set.
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
TensorBoard 2.2.2 at http://localhost:6006/ (Press CTRL+C to quit)

In a local machine, bind local’s 8123 port to remote’s 6006 port.

ssh -L 8123:127.0.0.1:6006 <user>@<host> -p 8082

Now, we can access the Tensorboard web interface using the address localhost:8123 in a local machine.

You can use Jupyter in the same way. Just change 6006 to 8888 (the default port in Jupyter).

Access through IP address or domain name If you want to access the Tensorboard through the IP address or domain name of the server, add --host 0.0.0.0 to tensorboard command.

tensorboard --logdir lightning_logs --host 0.0.0.0

You can access the Tensorboard page with http://:8083 on any kind of machine connected to the internet.

@eomiso
Copy link
Author

eomiso commented Feb 21, 2022

eomiso2/ml-environments:v1 사용시 service ssh start 해줘야 함

@eomiso
Copy link
Author

eomiso commented Feb 21, 2022

eomiso2/ml-environments:v1.1 : git, curl, vim 설치

@eomiso
Copy link
Author

eomiso commented Feb 22, 2022

adding --shm-size 8G to the docker run will fix bus error

@eomiso
Copy link
Author

eomiso commented Apr 19, 2022

use them in a shell file

docker run -d -t --shm-size 8G --runtime=nvidia --gpus all -p 8082:22 -p 8083:6006 -p 8084:8888 \
--name uiseop -v /home/eomiso/style-transfer/workspace:/root/workspace eomiso/ml-cuda10.2:v1.0.0 /bin/bash -c "service ssh start && tail -f /dev/null"

@eomiso
Copy link
Author

eomiso commented Apr 19, 2022

scp -P 8082 -i diya-sum-rsa diya-sum-rsa [email protected]:~/.ssh

@eomiso
Copy link
Author

eomiso commented Apr 19, 2022

다시보니까, 8083:6006, 8084:8888 은 필요 없을 듯 함

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment