- ๋งค๋ด์ผ ์์ฑ์: ์ปดํจํฐ๊ณตํ๋ถ ์ด์ฌ์ฑ ๊ต์๋ ์ฐ๊ตฌ์ค ์์ฌ ๊ณผ์ ๋ฏผ์ ํ(sunhongmin@snu.ac.kr), ์ธํด ๋ฐฑ์ฐํ(baneling100@snu.ac.kr)
- ๋ง์ง๋ง ์์ ์ผ: 2022๋ 5์ 18์ผ
- ๋ณธ ๋งค๋ด์ผ์ ์ปดํจํฐ๊ณตํ๋ถ์ DGX-A100 ๋จธ์ ์ ๊ธฐ์ค์ผ๋ก ์์ฑ๋์์ต๋๋ค.
- ํด๋น ๋จธ์ ์ x86_64 ์ํคํ ์ฒ๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ๊ทธ ์์ Ubuntu 20.04.4 LTS ์ด์์ฒด์ ๊ฐ ์ค์น๋์ด ์์ต๋๋ค.
- ํด๋น ๋จธ์ ์๋ GPU ์ฌ์ฉ์ ์ํ NVIDIA Cuda Toolkit์ด ์ค์น๋์ด ์์ต๋๋ค. ์๋์ ๊ฐ์ด
nvidia-smi๋ช ๋ น์ด๋ฅผ ํตํด NVIDIA Cuda Toolkit ์ค์น ์ฌ๋ถ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค. ๋ง์ฝ ์ค์น๊ฐ ๋์ด์์ง ์์ผ๋ฉด NVIDIA Cuda Toolkit 11.6 Update 2 Downloads๋ฅผ ํตํด ์ค์นํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. - CUDA๋ ํฌ๊ฒ driver ๋จ์์์ ๋ฒ์ ๊ณผ toolkit์ ๋ฒ์ ์ผ๋ก ๋๋ฉ๋๋ค. ์ ์๋
nvidia-smi๋ฅผ ์คํํด์ ํ์ธํ ์ ์๊ณ , ํ์๋nvcc --version์ผ๋ก ํ์ธํ ์ ์์ต๋๋ค. Toolkit์ ๋ฒ์ ์ด driver์ ๋ฒ์ ๋ณด๋ค ๋ฎ๊ฑฐ๋ ๊ฐ์ ๋์๋ ๋ฌธ์ ๊ฐ ์์ง๋ง, ๋ ํฐ ๊ฒฝ์ฐ์๋ ํธํ์ด ๋์ง ์์ ์ ์์ต๋๋ค. ํ์ฌ CUDA toolkit์ด 11.7๊น์ง ๋์์ต๋๋ค๋ง, driver ๋ฒ์ ๊ณผ์ ํธํ์ ์ํด ์ต์ ์ผ๋ก ์ ๋ฐ์ดํธํ๋ ๊ฑด ์ง์ํ์๊ธธ ๋ฐ๋๋๋ค.
nvadmin@dgx-a100:~$ nvidia-smi
Mon May 16 11:16:19 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA A100-SXM... On | 00000000:07:00.0 Off | 0 |
| N/A 28C P0 54W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA A100-SXM... On | 00000000:0F:00.0 Off | 0 |
| N/A 28C P0 52W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
...
+-------------------------------+----------------------+----------------------+
| 7 NVIDIA A100-SXM... On | 00000000:BD:00.0 Off | 0 |
| N/A 30C P0 58W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+- ์๋ ์ค๋ช ์ ๋ฐ๋ผํ์๊ฑฐ๋ Official Docker Engine Installation Manual์ ์ฐธ๊ณ ํด์ฃผ์ธ์.
- ์๋ ๋ช ๋ น์ด๋ฅผ ํตํด Docker(>= 19.03)๊ฐ ์ด๋ฏธ ์ค์น๋์ด ์๋ ๊ฒ์ ํ์ธํ์ จ๋ค๋ฉด 5. Docker Engine ์ค์น ํ์ธํ๊ธฐ๋ก ๋์ด๊ฐ์ฃผ์ธ์.
nvadmin@dgx-a100:~$ docker version --format '{{.Server.Version}}'
20.10.15
nvadmin@dgx-a100:~$ docker version --format '{{.Client.Version}}'
20.10.15- Repository ์ค์ ํ๊ธฐ
$ sudo apt-get update
$ sudo apt-get install -y ca-certificates curl gnupg lsb-release- Docker์ official GPG key ์ถ๊ฐํ๊ธฐ
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg- Stable version repository ์ค์ ํ๊ธฐ
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null- Docker Engine ์ค์นํ๊ธฐ
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin- Docker Engine ์ค์น ํ์ธํ๊ธฐ
nvadmin@dgx-a100:~$ sudo docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
...- ์๋ ์ค๋ช ์ ๋ฐ๋ผํ์๊ฑฐ๋ Official NVIDIA Container Toolkit Installation Manual์ ์ฐธ๊ณ ํด์ฃผ์ธ์.
- ์๋ ๋ช ๋ น์ด๋ฅผ ํตํด NVIDIA Docker(>= 2.8.0)๊ฐ ์ด๋ฏธ ์ค์น๋์ด ์๋ ๊ฒ์ ํ์ธํ์ จ๋ค๋ฉด 5. Base CUDA Container ์คํ์ ํตํ ์ค์น ํ์ธํ๊ธฐ๋ก ๋์ด๊ฐ์ฃผ์ธ์.
nvadmin@dgx-a100:~$ nvidia-docker version | grep "NVIDIA Docker"
NVIDIA Docker: 2.10.0- Docker ์ค์ ํ๊ธฐ
$ curl https://get.docker.com | sh && sudo systemctl --now enable dockerWarning: the "docker" command appears to already exist on this system.์ด ๋์ค๋ฉด Ctrl+C๋ฅผ ๋๋ฌ ํด๋น ์คํ์ ๋ฉ์ถฅ๋๋ค.
nvadmin@dgx-a100:~$ curl https://get.docker.com | sh && sudo systemctl --now enable docker
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 19305 100 19305 0 0 204k 0 --:--:-- --:--:-- --:--:-- 204k
# Executing docker install script, commit: 614d05e0e669a0577500d055677bb6f71e822356
Warning: the "docker" command appears to already exist on this system.
If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.
You may press Ctrl+C now to abort this script.
+ sleep 20
^C- ํจํค์ง repository์ GPG key ์ค์ ํ๊ธฐ
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list- NVIDIA Docker ์ค์นํ๊ธฐ
$ sudo apt-get update
$ sudo apt-get install -y nvidia-docker2- Docker daemon ์ฌ์์ํ๊ธฐ
$ sudo systemctl restart docker- Base CUDA Container ์คํ์ ํตํ ์ค์น ํ์ธํ๊ธฐ
์๋์ ๊ฐ์ด --gpus all ์ต์
์ ์ฃผ๊ณ ์คํํ์ ๋ ๋ชจ๋ GPU๊ฐ ๋ณด์ด๋ฉด ์ ๋๋ก ์ค์น๊ฐ ๋ ๊ฒ์
๋๋ค.
nvadmin@dgx-a100:~$ sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
Unable to find image 'nvidia/cuda:11.0.3-base-ubuntu20.04' locally
11.0.3-base-ubuntu20.04: Pulling from nvidia/cuda
d5fd17ec1767: Already exists
136ed510ad77: Pull complete
c7f8ead1f79b: Pull complete
be868dff62ae: Pull complete
61470f7d15cf: Pull complete
Digest: sha256:96422d2730adcb0cfcb260d2b1e96186ba5f05cb295b265631d98ea03d423a17
Status: Downloaded newer image for nvidia/cuda:11.0.3-base-ubuntu20.04
Mon May 16 03:18:49 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA A100-SXM... On | 00000000:07:00.0 Off | 0 |
| N/A 34C P0 55W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA A100-SXM... On | 00000000:0F:00.0 Off | 0 |
| N/A 34C P0 53W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
...
+-------------------------------+----------------------+----------------------+
| 7 NVIDIA A100-SXM... On | 00000000:BD:00.0 Off | 0 |
| N/A 36C P0 61W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+๊ธฐ๋ณธ์ ์ผ๋ก DGX-A100 ๋จธ์ ์ ๋์คํฌ๋ ext4 file system์ผ๋ก ์ค์ ๋์ด ์๊ณ , Docker๋ overlay2 storage driver๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๊ทธ๋ฌ๋ overlay2 storage driver์ ๊ฒฝ์ฐ ํธ์คํธ์ backing file system์ด ext4๊ฐ ์๋ xfs(with ftype=1, pquota mount option)๋ก ๋์ด ์์ด์ผ disk allocation์ด ๊ฐ๋ฅํฉ๋๋ค. ๋ฐ๋ผ์ ์ฌ์ ์์
์ผ๋ก DGX-A100 ๋จธ์ ๋ด์ raid0์ผ๋ก ๋ฌถ์ฌ์๋ /dev/md1 ๋์คํฌ๋ฅผ xfs file system์ผ๋ก ์ด๊ธฐํํฉ๋๋ค. ํด๋น ์์
์ ์งํํ๋ฉด /dev/md1 ๋์คํฌ์ ๋ด์ฉ์ด ์ ๋ถ ์ด๊ธฐํ๋๋ฏ๋ก mount point๋ฅผ ํ์ธํ๊ณ ํ์ํ ๋ฐ์ดํฐ๊ฐ ์๋ค๋ฉด ๋ฐ๋์ ๋ฐฑ์
ํด๋์๊ธฐ ๋ฐ๋๋๋ค.
- ์๋ ๋ช
๋ น์ด๋ฅผ ํตํด DGX-A100 ๋จธ์ ์ 4๊ฐ์ 3.5TiB์ง๋ฆฌ SSD๊ฐ
raid0์ต์ ์ผ๋ก ๋ฌถ์ฌ์ 14TiB์ ๊ณต๊ฐ์ ํ์ฑํ๊ณ ์์์ ์ ์ ์์ต๋๋ค.
nvadmin@dgx-a100:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
nvme0n1 259:6 0 3.5T 0 disk
โโmd1 9:1 0 14T 0 raid0 /raid
nvme4n1 259:7 0 3.5T 0 disk
โโmd1 9:1 0 14T 0 raid0 /raid
nvme5n1 259:8 0 3.5T 0 disk
โโmd1 9:1 0 14T 0 raid0 /raid
nvme3n1 259:9 0 3.5T 0 disk
โโmd1 9:1 0 14T 0 raid0 /raid๋ํ, ๋ค์ ๋ช
๋ น์ด๋ฅผ ํตํด /dev/md1 ๋์คํฌ๊ฐ ext4 file system์ผ๋ก ๋์ด ์์์ ์ ์ ์์ต๋๋ค. ์ด๊ฒ์ xfs (with ftype=1) ๋ก ๋ณ๊ฒฝํ๋ ์์
์ ์งํํ ๊ฒ์
๋๋ค.
nvadmin@dgx-a100:~$ sudo parted -l
...
Model: Linux Software RAID Array (md)
Disk /dev/md1: 15.4TB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 15.4TB 15.4TB ext4- ์ฐ์
lsblk๋ก ํ์ธํMOUNTPOINT์ธ/raid์ mount๋ฅผ ํด์ ํฉ๋๋ค.
nvadmin@dgx-a100:~$ sudo umount /raid/dev/md1๋์คํฌ๋ฅผxfs๋ก ํฌ๋งทํฉ๋๋ค. ์ด ๋-n ftype=1์ต์ ์ ๋ฐ๋์ ์ฃผ๋๋ก ํฉ๋๋ค.-f์ต์ ์ ๋์คํฌ ๋ด์ ๋ด์ฉ๋ฌผ์ด ์์ด๋ ๊ฐ์ ๋ก overwriteํ๋ ์ต์ ์ ๋๋ค.
nvadmin@dgx-a100:~$ sudo mkfs.xfs -f -n ftype=1 /dev/md1์ด ์์ ์ ๋ค์ sudo parted -l์ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ด file system์ด ๋ณ๊ฒฝ๋์์์ ํ์ธํ ์ ์์ต๋๋ค.
nvadmin@dgx-a100:~$ sudo parted -l
...
Model: Linux Software RAID Array (md)
Disk /dev/md1: 15.4TB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:
Number Start End Size File system Flags
1 0.00B 15.4TB 15.4TB xfs- ๋ค์ ๋ช
๋ น์ด๋ก
/dev/md1์/raid๋๋ ํ ๋ฆฌ๋ก mount ์ํต๋๋ค.-o pquota์ต์ ์ ๋ฐ๋์ ํฌํจํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.df๋ช ๋ น์ด๋ก ์ ๋๋ก mount๊ฐ ๋๋์ง ํ์ธํ ์ ์์ต๋๋ค.
nvadmin@dgx-a100:~$ sudo mount -o pquota /dev/md1 /raid
nvadmin@dgx-a100:~$ df -h /raid/
Filesystem Size Used Avail Use% Mounted on
/dev/md1 14T 100G 14T 1% /raid- ๋ชจ๋ Docker container์ image๋ฅผ ์ญ์ ํฉ๋๋ค.
$ sudo docker rm -f $(docker ps -aq); docker rmi -f $(docker images -q)- Docker service๋ฅผ ์ค์งํฉ๋๋ค.
$ sudo systemctl stop docker- Docker storage ๋๋ ํ ๋ฆฌ ๋ด๋ถ๋ฅผ ๋น์๋๋ค.
$ sudo rm -rf /var/lib/docker
$ sudo mkdir /var/lib/docker/raid๋ด์ ์๋ก์ด ๋๋ ํ ๋ฆฌ๋ฅผ ๋ง๋ค์ด์ bind mount ํฉ๋๋ค.
$ sudo mkdir /raid/docker
$ sudo mount --rbind /raid/docker /var/lib/docker- Docker service๋ฅผ ๋ค์ ์์ํฉ๋๋ค.
$ sudo systemctl start docker- (Opt.) Reboot์ ํ ๊ฒฝ์ฐ์ mount ํ๋ ๊ฒ์ด ํด์ ๋๋ฉด์ ์์ ์์
์ ๋ค์ ํด์ค์ผ ํฉ๋๋ค. ์ด๋ฅผ ๋ฐฉ์งํ๊ธฐ ์ํด
crontab -e๋ฅผ ํตํด reboot ์์ ์๋์ผ๋ก ์คํ๋ script๋ฅผ ์ค์ ํ ์ ์์ต๋๋ค.
์ฐ์ executable shell script๋ฅผ ๋ง๋ญ๋๋ค.
nvadmin@dgx-a100:~$ touch raid_fs.sh
nvadmin@dgx-a100:~$ chmod +x raid_fs.shํด๋น ํ์ผ ์์ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ ์์ฑํด์ ์ ์ฅํฉ๋๋ค.
nvadmin@dgx-a100:~$ cat raid_fs.sh
#!/bin/sh
sudo mount -o pquota /dev/md1 /raid
sudo docker rm -f $(docker ps -aq); docker rmi -f $(docker images -q)
sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo mkdir /var/lib/docker
sudo mount --rbind /raid/docker /var/lib/docker
sudo systemctl start dockercrontab -e๋ฅผ ์คํํ๊ณ ์ ์ผ ๋ ์ค์ ๋ค์ ๋ฌธ์ฅ์ ์ถ๊ฐํฉ๋๋ค.
@reboot /home/nvadmin/raid_fs.sh-
๊ธฐ๋ณธ ์ธ์ ์ฌํญ ์ธ์ ์ํ๋ 1) GPU ๊ฐ์, 2) Disk ์ฉ๋, 3) ์ด์์ฒด์ , 4) CUDA Toolkit ๋ฒ์ , 5) cuDNN ๋ฒ์ (์ ํ ์ฌํญ)์ ์กฐ์ฌํ ํ์๊ฐ ์์ต๋๋ค.
-
CPU ์ฝ์ด ๊ฐ์์ Memory ์ฉ๋์ ๊ธฐ๋ณธ์ ์ผ๋ก GPU 1๊ฐ๋น ๊ฐ๊ฐ 32๊ฐ์ 128GB๋ฅผ ๋ฐฐ๋ถํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค. CPU ์ฝ์ด์ Memory๋ฅผ ๋ฐฐ๋ถํ ๋ GPU NUMA Affinity๋ฅผ ๊ณ ๋ คํด์ผํ๋ฏ๋ก ์ด ๋์ ์์ ์กฐ์ฌ๋ฅผ ํตํด ์ ํ๊ธฐ๋ณด๋ค๋ ์ด๋ฐ ์์ผ๋ก ๊ฐ์์ ์ฉ๋์ ์ ํด๋๋ ๊ฒ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. GPU NUMA Affinity์ ๋ํ ๊ณ ๋ ค๋ III. ๊ฐ ์ฌ์ฉ์์๊ฒ ๋๋ ์ค container ๋ง๋ค๊ธฐ์์ ์์๋ฅผ ํตํด ์์ธํ ๋ค๋ฃน๋๋ค.
-
II. Dockerfile์ ํตํ image ๋น๋ํ๊ธฐ์์ ์ฌ์ฉํ๊ฒ ๋ Dockerfile์ ๋ช ๋ น์ด๊ฐ ํ์ฌ๋ก์๋ Ubuntu ์ด์์ฒด์ ๋ฅผ ๊ฐ์ ํ๊ณ ์์ฑ๋์์ผ๋ฏ๋ก ์ด์์ฒด์ ๋ก๋ Ubuntu ๊ณ์ด๋ง์ ๋ณด๊ธฐ๋ก ๋ฃ์ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค.
-
์์ ์กฐ์ฌ ์์: https://forms.gle/gyPDd95oU1aySiTs9
- ์์: ์ฌ์ฉ์๊ฐ Ubuntu 18.04, CUDA 11.4.0, cuDNN 8 Developer์ ์ ํํ ๊ฒฝ์ฐ
- ๋น ๋๋ ํ ๋ฆฌ(
cd ~๋ฑ)์์ ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์Dockerfileํ์ผ์ ์์ฑํฉ๋๋ค. (๋น ๋๋ ํ ๋ฆฌ๊ฐ ์๋๋ผ๋ฉด.dockerignoreํ์ผ์ ์์ฑํด์ ๋ค๋ฅธ ํด๋ ๋ฐ ํ์ผ์ ๋ฌด์ํ๋๋ก ํฉ๋๋ค.)Dockerfile์ ๋ด์ฉ์nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04๋ผ๋ base image์ ํฌํธ๋ฅผ ํตํ SSH ์ ์์ด ๊ฐ๋ฅ์ผํ ์๋ก์ด image๋ฅผ ๋น๋ํ๊ธฐ ์ํด ์์ฑ๋์์ต๋๋ค. Base image ์ด๋ฆ ๋ฐ ํ๊ทธ๋ฅผ ๊ฒ์ํ๋ ค๋ฉด ์ด ๊ณณ์ ์ด์ฉํด์ฃผ์ธ์.
nvadmin@dgx-a100:~$ cat Dockerfile
# Instruction for Dockerfile to create a new image on top of the base image (nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04)
FROM nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04
ARG root_password
RUN apt-get update || echo "OK" && apt-get install -y openssh-server
RUN mkdir /var/run/sshd
RUN echo "root:${root_password}" | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"].dockerignore ํ์ผ ์์
nvadmin@dgx-a100:~$ cat .dockerignore
folder_to_ignore
file_to_ignore
ignore_me*Dockerfile์ ์ด์ฉํด ์๋ก์ด image๋ฅผ ๋น๋ํฉ๋๋ค. ํด๋น image๋ฅผ ์ด์ฉํ container์ ๋น๋ฐ๋ฒํธ๋password๋ก ์ด๊ธฐํ๋์ด ์์ผ๋ฉฐ ์ดํ์ ๊ฐ ์ฌ์ฉ์๊ฐ ์์ ํ ์ ์์ต๋๋ค.
$ docker image build --build-arg root_password=password --tag nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04-ssh .- ์์: ์ฌ์ฉ์๊ฐ GPU 2๊ฐ, Disk 512GB๋ฅผ ์ ํํ ๊ฒฝ์ฐ
- ์ฌ์ฉ์๊ฐ ์ ํํ ์๊ตฌ์ฌํญ์ ๋ง๊ฒ container๋ฅผ ๋ง๋ญ๋๋ค. (์ฌ์ฉ์๋ช
์
user1์ด๋ผ๊ณ ๊ฐ์ )
์ฐ์ GPU Numa Affinity๋ฅผ ํ์ธํ์ฌ Affinity rule์ ์๋ฐฐ๋์ง ์๋ GPU, CPU, Memory ์กฐํฉ์ด availableํ์ง ํ์ธํฉ๋๋ค.
nvadmin@dgx-a100:~$ lscpu
...
NUMA node0 CPU(s): 0-15,128-143
NUMA node1 CPU(s): 16-31,144-159
NUMA node2 CPU(s): 32-47,160-175
NUMA node3 CPU(s): 48-63,176-191
NUMA node4 CPU(s): 64-79,192-207
NUMA node5 CPU(s): 80-95,208-223
NUMA node6 CPU(s): 96-111,224-239
NUMA node7 CPU(s): 112-127,240-255
...์๋ฅผ ๋ค์ด, ์์ ๊ฐ์ ๊ฒฝ์ฐ์ GPU Node 1๋ฒ์ ํ ๋นํ๋ค๋ฉด CPU๋ 16-31๋ฒ ํน์ 144-159๋ฒ ๋ด์์ ํ ๋นํด์ค๋๋ค. Memory ๋ ธ๋๋ GPU ๋ ธ๋ ๋ฒํธ์ ๋ง์ฐฌ๊ฐ์ง๋ก 1๋ฒ์ ํ ๋นํด์ค๋๋ค. ์๋์ ๊ฐ์ ๋ช ๋ น์ด๋ก ํ ๋น์ ์๋ฃํฉ๋๋ค.
$ docker container run --gpus '"device=0,1"' --cpus=64 --cpuset-cpus 0-31,128-159 --cpuset-mems 0,1 -m 256G --storage-opt size=512G -d -P --name user1 nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04-ssh- Container ํฌํธ๊ฐ ๋ช ๋ฒ์ธ์ง ํ์ธํ๊ณ ๊ธฐ๋กํด๋ก๋๋ค.
nvadmin@dgx-a100:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
24ad5af18c98 nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04-ssh "/usr/sbin/sshd -D" 12 minutes ago Up 12 minutes 0.0.0.0:49160->22/tcp, :::49160->22/tcp user1์ด์ ssh -p 49160 root@147.46.92.213์ ๊ฐ์ด SSH๋ฅผ ํตํด ํด๋น container์ ์ ์ํ ์ ์์ต๋๋ค.
OOO๋, ์ ์ฒญํ์ DGX-A100 ์์์ด ํ ๋น๋์์ต๋๋ค. ์ ์ฒญํ์ ์์์ NVIDIA Docker Container๋ก ๋ง๋ค์ด์ก์ผ๋ฉฐ ์๋์ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ์ ์ํ์ค ์ ์์ต๋๋ค. ์ด๊ธฐ ๋น๋ฐ๋ฒํธ๋ password์
๋๋ค.
ssh -p 49160 root@147.46.92.213-
Container์ ์ ์ํ์ ํ ๊ผญ
passwd๋ช ๋ น์ด๋ฅผ ํตํด ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณ๊ฒฝํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค. ๋น๋ฐ๋ฒํธ๋ฅผ ๋ณ๊ฒฝํ์ง ์์์ ์๊ธฐ๋ ๋ณด์, ๋ฐ์ดํฐ ์์ ๋ฑ์ ๋ฌธ์ ๋ ์ ํฌ๊ฐ ์ฑ ์์ง์ง ์์ต๋๋ค. -
Container๋ก ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด๊ณ ๋ฐ์ผ์ค ๋์๋ ๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ์๋ฉด ๋ฉ๋๋ค.
- Container๋ก ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ผ ๊ฒฝ์ฐ
user@desktop:~$ scp -P 49156 -r folder_to_send root@147.46.92.213:/root
- Container์์ ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ผ ๊ฒฝ์ฐ
root@194b0519ada6:~# scp -r folder_to_send user@<IP_ADDRESS>:/home/user
-
ํ ๋น๋ ์์์ ํ์ธํ์ค ๋
lscpu,free๋ฑ์ ๋ช ๋ น์ด๋ฅผ ์ด์ฉํ์๋ฉด container๊ฐ ์๋ host ๋จธ์ ์ ์ฒด์ ์์์ด ๋ณด์ด๊ฒ ๋๋ฏ๋ก ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ ์ผ ํฉ๋๋ค. ์๋์ ๊ฐ์ด ์๋ด๋๋ฆฝ๋๋ค.
- GPU
root@24ad5af18c98:~# nvidia-smi
Tue May 17 10:00:30 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA A100-SXM... On | 00000000:07:00.0 Off | 0 |
| N/A 31C P0 54W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA A100-SXM... On | 00000000:0F:00.0 Off | 0 |
| N/A 30C P0 52W / 400W | 0MiB / 40960MiB | 0% Default |
| | | Disabled |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+- CPU: ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํด์ ๋์จ ๊ฒฐ๊ณผ๋ฅผ
100000๋ก ๋๋.
root@24ad5af18c98:~# cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us
6400000- Memory: ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํด์ ๋์จ ๊ฒฐ๊ณผ๋ฅผ
1024 * 1024 * 1024๋ก ๋๋ (GiB ๋จ์).
root@24ad5af18c98:~# apt-get update && apt-get install -y cgroup-tools
root@24ad5af18c98:~# cgget -n --values-only --variable memory.limit_in_bytes /
274877906944- Disk
root@24ad5af18c98:~# df -h /
Filesystem Size Used Avail Use% Mounted on
overlay 512G 2.7M 512G 1% /- ๊ธฐํ ๊ถ๊ธํ์ ์ฌํญ์ด ์์ผ๋ฉด XXX๋ก ์ฐ๋ฝ์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.
์ฌ์ฉ์๊ฐ container๋ฅผ ๋ฐ๋ฉํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋ช ๋ น์ด๋ก ๊ฐ์ ์ญ์ ํ ์ ์์ต๋๋ค.
nvadmin@dgx-a100:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
24ad5af18c98 nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04-ssh "/usr/sbin/sshd -D" 45 minutes ago Up 45 minutes 0.0.0.0:49160->22/tcp, :::49160->22/tcp user1
nvadmin@dgx-a100:~$ docker rm --force user1
user1
nvadmin@dgx-a100:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES๋ง๋ค์ด๋๋ image๋ ์ฌ์ฌ์ฉ์ด ๊ฐ๋ฅํ๋ฏ๋ก ํน๋ณํ ๊ฒฝ์ฐ๊ฐ ์๋๋ฉด image๋ ๋ฐ๋ก ์ญ์ ํ์ง๋ ์๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค. ์์ ์กฐ์ฌ ๊ฒฐ๊ณผ ์ฌ์ฉ์๋ค์ ์๊ตฌ์ฌํญ์ด ๋น์ทํ๋ค๋ฉด ๊ฐ์ image๋ก container๋ง ๋ค๋ฅด๊ฒ ๋ง๋ค์ด์ ๋ฐฐํฌํ๋ ๊ฒ์ด ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์
๋๋ค. Image๊ฐ ๋๋ฌด ๋ง์ด ์์ฌ์ ์ฉ๋์ ๋ง์ด ์ฐจ์งํ๊ณ ์๋ค๋ฉด (docker images ๋ช
๋ น์ด๋ก ํ์ธ ๊ฐ๋ฅ) ๋ค์๊ณผ ๊ฐ์ ๋ช
๋ น์ด๋ก image๋ฅผ ๊ฐ์ ์ญ์ ํ์๊ธฐ ๋ฐ๋๋๋ค. ๋จ, image๊ฐ ์ญ์ ๊ฐ๋ฅํ๋ ค๋ฉด ํด๋น image๋ก ๋ง๋ container๊ฐ ์์ด์ผ ํฉ๋๋ค. ๋ํ ์์์์ฒ๋ผ base image์ ํฌํธ๋ฅผ ํตํ SSH ์ ์์ด ๊ฐ๋ฅ์ผํ ์๋ก์ด image๋ฅผ ๋ง๋ ๊ฒฝ์ฐ, ๊ทธ ์๋ก์ด image๋ฅผ ๋จผ์ ์ญ์ ํ๊ณ , ๊ทธ ๋ค์์ base image๋ฅผ ์ญ์ ํด์ผ ํฉ๋๋ค.
nvadmin@dgx-a100:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nvidia/cuda 11.4.0-cudnn8-devel-ubuntu18.04-ssh 29e620c892e6 50 minutes ago 9.13GB
nvidia/cuda 11.4.0-cudnn8-devel-ubuntu18.04 d94cc7c49eef 2 weeks ago 8.98GB
nvadmin@dgx-a100:~$ docker rmi 29e620c892e6
Untagged: nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04-ssh
Deleted: sha256:29e620c892e6b7b3cd5f14772aece043ef10487ce3e9303f6d3408bedf2dce07
...
nvadmin@dgx-a100:~$ docker rmi d94cc7c49eef
Untagged: nvidia/cuda:11.4.0-cudnn8-devel-ubuntu18.04
Untagged: nvidia/cuda@sha256:867af080c04292bbab9b5971432c9f7955978f3c9e61cd613e86d95ea7926577
Deleted: sha256:d94cc7c49eef65a0c5eca81d6a88b067687baf1b4138ceebe22e5eb27a8007f3
...
nvadmin@dgx-a100:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZEI. Container ํ์ ๋ฐ ์ญ์ ์์ ์ด ๋๋๋ฉด ํด๋น ์ฌ์ฉ์์ ๊ฐ์ธ์ ๋ณด๋ฅผ ํ๊ธฐํด์ฃผ์๊ธฐ ๋ฐ๋๋๋ค.