NVIDIA GPU Cloud (NGC) adalah ekosistem pembelajaran mendalam yang dikembangkan oleh NVIDIA dan menyediakan akses gratis ke tumpukan perangkat lunak pembelajaran mendalam untuk membangun lingkungan pengembangan. Topik ini menjelaskan langkah-langkah menyebarkan lingkungan NGC pada instans yang dipercepat GPU dengan menggunakan TensorFlow sebagai contoh.
Informasi latar belakang
-
Situs web NGC menyediakan gambar berbagai versi framework pembelajaran mendalam utama, seperti Caffe, Caffe2, Microsoft Cognitive Toolkit (CNTK), MXNet, TensorFlow, Theano, dan Torch. Pilih gambar sesuai kebutuhan Anda untuk menyebarkan lingkungan kontainer NGC. Topik ini menggunakan TensorFlow sebagai contoh.
-
Alibaba Cloud menyediakan gambar kontainer NGC yang dioptimalkan untuk GPU NVIDIA Pascal di Alibaba Cloud Marketplace. Anda dapat memilih gambar tersebut saat membuat instans yang dipercepat GPU untuk menyebarkan lingkungan kontainer NGC secara cepat dengan framework pembelajaran mendalam yang telah dioptimalkan dan diperbarui secara berkala.
Batasan
Lingkungan NGC dapat disebarkan pada instans dari keluarga tipe instans berikut:
-
gn5i, gn6v, gn6i, gn6e, gn7i, gn7e, dan gn7s
-
ebmgn6i, ebmgn6v, ebmgn6e, ebmgn7i, dan ebmgn7e
Untuk informasi lebih lanjut, lihat Keluarga instans komputasi yang dioptimalkan dengan percepatan GPU.
Prasyarat
Sebelum memulai, pastikan Anda telah membuat akun NGC di situs web NGC.
Dapatkan URL gambar kontainer TensorFlow sebelum memulai.
-
Pada kotak pencarian, masukkan TensorFlow.
Pada hasil pencarian, klik kartu kontainer TensorFlow.
-
Pada halaman TensorFlow, klik tab Tags dan salin path versi gambar kontainer TensorFlow yang diinginkan.
Pada contoh ini, URL gambar
22.05-tf1-py3adalah nvcr.io/nvidia/tensorflow:22.05-tf1-py3, yang akan Anda gunakan untuk mengunduh gambar tersebut pada instans yang dipercepat GPU.PentingVersi CUDA dalam gambar TensorFlow harus sesuai dengan versi driver instans yang dipercepat GPU. Jika tidak, penerapan akan gagal. Untuk informasi tentang kompatibilitas versi, lihat TensorFlow Release Notes.
Prosedur
Contoh berikut menggunakan instans gn7i untuk menyebarkan lingkungan NGC.
-
Buat instans yang dipercepat GPU.
Untuk informasi lebih lanjut, lihat Membuat instans pada tab Custom Launch. Konfigurasikan parameter utama berikut:
Parameter
Deskripsi
Region
Pilih wilayah yang menyediakan instans yang dipercepat GPU.
Untuk memeriksa ketersediaan instans yang dipercepat GPU di setiap wilayah, lihat Tipe instans yang tersedia untuk setiap wilayah.
Instance
Pilih tipe instans. Pada contoh ini, digunakan gn7i.
Images
-
Pada tab Marketplace Images, klik Select from Alibaba Cloud Marketplace.
-
Pada kotak dialog yang muncul, masukkan NVIDIA GPU Cloud Virtual Machine Image dan klik Search.
-
Temukan gambar tersebut dan klik Select.
Public IP Address
Pilih Assign Public IPv4 Address.
CatatanJika tidak ada alamat IP publik yang ditetapkan, asosiasikan elastic IP address (EIP) dengan instans setelah instans dibuat. Untuk informasi lebih lanjut, lihat Mengasosiasikan satu atau beberapa EIP dengan instans.
Security Group
Pilih security group dengan port TCP 22 diaktifkan. Jika instans Anda memerlukan HTTPS atau Deep Learning GPU Training System (DIGITS) 6, aktifkan juga port TCP 443 untuk HTTPS atau port TCP 5000 untuk DIGITS 6.
-
-
Gunakan salah satu metode yang dijelaskan dalam tabel berikut untuk menghubungkan ke instans.
Metode
Referensi
Workbench
Menghubungkan ke instans Linux menggunakan password atau kunci
VNC
-
Jalankan perintah
nvidia-smiuntuk melihat informasi tentang GPU saat ini.Output menunjukkan bahwa Driver Version adalah 515.48.07, yang kompatibel dengan CUDA 11.7 sebagaimana dipersyaratkan oleh gambar TensorFlow
22.05-tf1-py3.root@xxxszfZ:~# nvidia-smi Sun Apr 7 11:01:55 2024 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 515.48.07 Driver Version: 515.48.07 CUDA Version: 11.7 | |-------------------------------+----------------------+----------------------+ | 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 A10 On | 00000000:00:07.0 Off | 0 | | N/A 32C P8 14W / 150W | 2MiB / 23028MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+ -
Jalankan perintah berikut untuk mengunduh gambar kontainer TensorFlow:
docker pull nvcr.io/nvidia/tensorflow:22.05-tf1-py3PentingMengunduh gambar kontainer TensorFlow mungkin memerlukan waktu yang lama.
-
Jalankan perintah berikut untuk melihat informasi tentang gambar kontainer TensorFlow yang telah diunduh:
docker image lsKolom TAG menampilkan
22.05-tf1-py3, yang mengonfirmasi bahwa gambar telah diunduh.root@xxx lz:~# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE nvcr.io/nvidia/tensorflow 22.05-tf1-py3 7c92d95961e9 2 years ago 14.4GB -
Jalankan perintah berikut untuk menyebarkan lingkungan pengembangan TensorFlow dengan menjalankan kontainer:
docker run --gpus all --rm -it nvcr.io/nvidia/tensorflow:22.05-tf1-py3Jika berhasil, output yang mirip dengan berikut akan ditampilkan:
================ == TensorFlow == ================ NVIDIA Release 22.05-tf1 (build 18410160) TensorFlow Version 1.15.5 Container image Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. Copyright 2017-2020 The TensorFlow Authors. All rights reserved. NVIDIA Deep Learning Profiler (dlprof) Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. Various files include modifications (c) NVIDIA CORPORATION. All rights reserved. NVIDIA modifications are covered by the license terms that apply to the underlying project or file. NOTE: MOFED driver for multi-node communication was not detected. Multi-node communication performance may be reduced. -
Jalankan perintah-perintah berikut secara berurutan untuk menjalankan pengujian sederhana untuk TensorFlow:
pythonimport tensorflow as tf hello = tf.constant('Hello, TensorFlow!') with tf.compat.v1.Session() as sess: result = sess.run(hello) print(result.decode())Jika TensorFlow memuat perangkat GPU sebagaimana diharapkan, string
Hello, TensorFlow!akan dicetak, seperti yang ditunjukkan pada output berikut.2024-08-21 04:17:14.076698: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1351] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 20427 MB memory) -> physical GPU (device: 0, name: NVIDIA A10, pci bus id: 0000:00:07.0, compute capability: 8.6) 2024-08-21 04:17:14.077064: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1082] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2024-08-21 04:17:14.077724: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1351] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 20427 MB memory) -> physical GPU (device: 1, name: NVIDIA A10, pci bus id: 0000:00:08.0, compute capability: 8.6) 2024-08-21 04:17:14.078021: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1082] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2024-08-21 04:17:14.078688: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1351] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:2 with 20427 MB memory) -> physical GPU (device: 2, name: NVIDIA A10, pci bus id: 0000:00:09.0, compute capability: 8.6) 2024-08-21 04:17:14.078955: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1082] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2024-08-21 04:17:14.079624: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1351] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:3 with 20427 MB memory) -> physical GPU (device: 3, name: NVIDIA A10, pci bus id: 0000:00:0a.0, compute capability: 8.6) Hello, TensorFlow! >>> -
Simpan gambar TensorFlow yang telah dimodifikasi.
-
Pada halaman koneksi GPU, buka jendela baru untuk koneksi jarak jauh.
-
Jalankan perintah berikut untuk menanyakan
CONTAINER_ID:docker psroot@xxxg9dZ:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f76a5a4347df nvcr.io/nvidia/tensorflow:22.05-tf1-py3 "/opt/nvidia/nvidia_..." 46 seconds ago Up 45 seconds 6006/tcp, 6064/tcp, 8888/tcp reverent_brattain 68xxxxxxfba nvcr.io/nvidia/tensorflow:22.05-tf1-py3 "/opt/nvidia/nvidia_..." 9 minutes ago Up 9 minutes 6006/tcp, 6064/tcp, 8888/tcp jolly_liskov -
Jalankan perintah berikut untuk menyimpan gambar TensorFlow yang telah dimodifikasi:
# Ganti CONTAINER_ID dengan ID kontainer yang diperoleh dari perintah docker ps, misalnya f76a5a4347d. docker commit -m "commit docker" CONTAINER_ID nvcr.io/nvidia/tensorflow:20.01-tf1-py3PentingPastikan gambar TensorFlow yang telah dimodifikasi disimpan. Jika tidak, perubahan mungkin hilang saat Anda login kembali ke instans.
-