Training predictive models, especially neural networks with many parameters takes lots of computing power. To use a GPU the container must be configured to access the GPU from the container and contain drivers and libraries. The container in https://github.com/learniotai/iotai_container_env is configured to use Nvidia GPUs. Currently Tensorflow and Pytorch are built to use only Nvidia GPUs through the CUDA application programming interface (API) though support for AMD Radeon GPUs is in progress for Pytorch.
Setup Docker and computing environment.
Launch the Docker container with GPU support.
iotai_train
If you have a GPU check that it’s visible from inside the Docker image.
$ learniotai@546e6389eba7:/opt$ nvidia-smi
Wed Apr 28 02:10:39 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.56 Driver Version: 460.56 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 GeForce GTX 1070 Off | 00000000:01:00.0 On | N/A |
| 27% 36C P8 12W / 151W | 227MiB / 8119MiB | 38% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
Test machine learning tool kits can access GPU
Test Tensorflow GPU
$ python import tensorflow as tf tf.test.is_gpu_available() ... StreamExecutor device (0): GeForce GTX 1070, Compute Capability 6.1 True
Test Pytorch GPU
import torch torch.cuda.is_available() True