在表 1.5.1中,我們討論了過去二十年計算的快速增長。簡而言之,自 2000 年以來,GPU 性能每十年增加 1000 倍。這提供了巨大的機(jī)會,但也表明提供這種性能的巨大需求。
在本節(jié)中,我們將開始討論如何在您的研究中利用這種計算性能。首先是使用單個 GPU,然后是如何使用多個 GPU 和多個服務(wù)器(具有多個 GPU)。
具體來說,我們將討論如何使用單個 NVIDIA GPU 進(jìn)行計算。首先,確保您至少安裝了一個 NVIDIA GPU。然后,下載NVIDIA驅(qū)動和CUDA,根據(jù)提示設(shè)置合適的路徑。這些準(zhǔn)備工作完成后,nvidia-smi
就可以通過命令查看顯卡信息了。
Fri Feb 10 06:11:13 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.106.00 Driver Version: 460.106.00 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| 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 Tesla V100-SXM2... Off | 00000000:00:17.0 Off | 0 |
| N/A 35C P0 76W / 300W | 1534MiB / 16160MiB | 53% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 Tesla V100-SXM2... Off | 00000000:00:18.0 Off | 0 |
| N/A 34C P0 42W / 300W | 0MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 2 Tesla V100-SXM2... Off | 00000000:00:19.0 Off | 0 |
| N/A 36C P0 80W / 300W | 3308MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 3 Tesla V100-SXM2... Off | 00000000:00:1A.0 Off | 0 |
| N/A 35C P0 200W / 300W | 3396MiB / 16160MiB | 4% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 4 Tesla V100-SXM2... Off | 00000000:00:1B.0 Off | 0 |
| N/A 32C P0 56W / 300W | 1126MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 5 Tesla V100-SXM2... Off | 00000000:00:1C.0 Off | 0 |
| N/A 40C P0 84W / 300W | 1522MiB / 16160MiB | 47% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 6 Tesla V100-SXM2... Off | 00000000:00:1D.0 Off | 0 |
| N/A 34C P0 57W / 300W | 768MiB / 16160MiB | 3% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 7 Tesla V100-SXM2... Off | 00000000:00:1E.0 Off | 0 |
| N/A 32C P0 41W / 300W | 0MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 18049 C ...l-en-release-1/bin/python 1531MiB |
| 2 N/A N/A 41102 C ...l-en-release-1/bin/python 3305MiB |
| 3 N/A N/A 41102 C ...l-en-release-1/bin/python 3393MiB |
| 4 N/A N/A 44560 C ...l-en-release-1/bin/python 1123MiB |
| 5 N/A N/A 18049 C ...l-en-release-1/bin/python 1519MiB |
| 6 N/A N/A 44560 C ...l-en-release-1/bin/python 771MiB |
+-----------------------------------------------------------------------------+
在 PyTorch 中,每個數(shù)組都有一個設(shè)備,我們通常將其稱為上下文。到目前為止,默認(rèn)情況下,所有變量和相關(guān)計算都已分配給 CPU。通常,其他上下文可能是各種 GPU。當(dāng)我們跨多個服務(wù)器部署作業(yè)時,事情會變得更加棘手。通過智能地將數(shù)組分配給上下文,我們可以最大限度地減少設(shè)備之間傳輸數(shù)據(jù)所花費(fèi)的時間。例如,在帶有 GPU 的服務(wù)器上訓(xùn)練神經(jīng)網(wǎng)絡(luò)時,我們通常更希望模型的參數(shù)存在于 GPU 上。
Fri Feb 10 08:10:21 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.106.00 Driver Version: 460.106.00 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| 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 Tesla V100-SXM2... Off | 00000000:00:17.0 Off | 0 |
| N/A 36C P0 56W / 300W | 1996MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 Tesla V100-SXM2... Off | 00000000:00:18.0 Off | 0 |
| N/A 44C P0 59W / 300W | 2000MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 2 Tesla V100-SXM2... Off | 00000000:00:19.0 Off | 0 |
| N/A 46C P0 59W / 300W | 1810MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 3 Tesla V100-SXM2... Off | 00000000:00:1A.0 Off | 0 |
| N/A 43C P0 58W / 300W | 0MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 4 Tesla V100-SXM2... Off | 00000000:00:1B.0 Off | 0 |
| N/A 37C P0 57W / 300W | 1834MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 5 Tesla V100-SXM2... Off | 00000000:00:1C.0 Off | 0 |
| N/A 49C P0 60W / 300W | 0MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 6 Tesla V100-SXM2... Off | 00000000:00:1D.0 Off | 0 |
| N/A 44C P0 59W / 300W | 1842MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 7 Tesla V100-SXM2... Off | 00000000:00:1E.0 Off | 0 |
| N/A 37C P0 57W / 300W | 1806MiB / 16160MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 67249 C ...l-en-release-1/bin/python 1993MiB |
| 1 N/A N/A 67249 C ...l-en-release-1/bin/python 1997MiB |
| 2 N/A N/A 28134 C ...l-en-release-1/bin/python 1807MiB |
| 4 N/A N/A 75456 C ...l-en-release-1/bin/python 1831MiB |
| 6 N/A N/A 75456 C ...l-en-release-
評論
查看更多