Skip to content

y-kage/docker_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. Preparation

Install

Docker

Follow the instructions

NVIDIA Container Toolkit

Follow the instructions here

Docker Image

2. Getting Started

Before Build

Modify files. Be careful os version and python version.
(ex. Ubuntu 20.04 -> python 3.9, Ubuntu 22.04 -> python 3.10)
See here or here

  • Modify docker_template.env

    • COMPOSE_PROJECT_NAME : project name
    • UID : UID
    • GID : GID
    • USER_NAME : user name used in container
    • WORKDIR_CONTAINER : container WORKDIR, directory where local WORKDIR mounted to
    • WORKDIR_LOCAL : local WORKDIR, directory mounted to container
    • BASE_IMAGE : Docker Image
    • PYTHON_VERSION : Python version
    • IMAGE_LABEL : label to cache docker image with label, if exist, load, if not, build.
    • CONTAINER_NAME : CONTAINER NAME, used to get in the container
    • HOST_PORT : HOST_PORT, use port not used at other containers
    • CONTAINER_PORT : CONTAINER_PORT, use port not used at other containers

    Commands to search your UID, GID

    id -u # UID
    id -g # GID
  • docker-compose.yaml Change image, container_name, volumes, shm_size if needed.

    • image : name of image cached to local. if exist, load, if not, build.
    • container_name : name used to get in the container.
    • volumes : Correspondence. {local_dir}:{container_dir}
    • shm_size : shared memory size. check your spec.
  • Dockerfile Change apt libraries, Pytorch.

Useful Commands

  • Docker compose up
    Use command at the directory where docker-compose.yaml is

    docker compose up -d

    If Dockerfile changed, Docker compose up with build

    docker compose up -d --build
  • Execute command in Docker

    docker exec -it {container_name} bash
    # or
    docker exec -it -w {WORK_DIR_PATH} {container_name} bash
    # example
    docker exec -it template bash

    As root

    docker exec -it -u 0 -w {WORK_DIR_PATH} {container_name} bash
  • Using JupyterLab (Optional)

    python -m jupyterlab --ip 0.0.0.0 --port {CONTAINER_PORT} --allow-root
  • Using Tensorboard

    tensorboard --logdir=/workspace/PytorchLightning/lightning_logs --host=0.0.0.0 --port={CONTAINER_PORT}
    # or
    python /home/{USER}/.local/lib/python3.9/site-packages/tensorboard/main.py --logdir=/workspace/PytorchLightning/lightning_logs --host=0.0.0.0 --port={CONTAINER_PORT}
  • Login W & D

    wandb login
    # or
    python3 -m wandb login
    # or
    /usr/bin/python3 -m wandb login

3. Reference

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages