본문 바로가기

Useful command

nvidia-docker

반응형

1. Notations


a) image: a bag of programs, which you want to run in a container. The programs can be 'tensorflow', 'python' 'opencv' etc.

b) container: kinds of virtual machine you run in your real machine


2. How to use docker?


step1)  


You first create a container with one image using the following command

$ nvidia-docker run -it -d -p 8888:8888 --name container_name -v /data:/data image_name


you can list the images you have in your system by

$ nvidia-docker images



Once you run your container, it will run until you stop it. You can list all the containers that you have been created by 

$ nvidia-docker ps -a



If you want to remove the container, you first need to stop it by

$ nvidia-docker stop container_name


and then remove it by

$ nvidia-docker remove container_name


step2)


Now you can execute the container (which includes programs in image_name) by

$ nvidia-docker exec -it container_name /bin/bash


3. Finall Note


Assume that you create a container with an image, and execute the container in a new terminal. Unfortunately, the image doesn't contain 'opencv', which you want to use when deep-learning something. You can install it in the container by simply typing 'pip install python-opencv'. 


Everytime you execute the container, you can use the installed opencv in the container. However, if you remove the container, we need to create a new container with the image and re-install 'opencv' in the container.








'Useful command' 카테고리의 다른 글

TMUX 명령어/Command 모음  (1) 2023.03.20
nvidia docker commands  (0) 2017.08.16
Useful command  (0) 2017.07.18