Tensorflow

Introduction

Tensorflow is free software for AI/ML applications. In this page you will learn how to use tensorflow on ARC that utilizes GPUs.

Availability

You can use TensorFlow through a conda or a Python environment. The following code explains how to create a conda environment that includes TensorFlow as part of its packages.

[jdoe2@tc-dgx006 ~]$ conda create -n tf_env tensorflow
[jdoe2@tc-dgx006 ~]$ source activate tf_env

Now list the already installed TensorFlow packages:

(tf_env) [jdoe2@tc-dgx006 ~]$ conda list | grep tensor
tensorboard               2.16.2             pyhd8ed1ab_0    conda-forge
tensorboard-data-server   0.7.0           py312h241aef2_1    conda-forge
tensorflow                2.16.1          cuda120py312hee4d333_0    conda-forge
tensorflow-base           2.16.1          cuda120py312h3a81633_0    conda-forge
tensorflow-estimator      2.16.1          cuda120py312hfa0f5ef_0    conda-forge

Note

You cannot use a conda environment that was created on a specific partition on another partition. You can learn more about managing environments on ARC at Using Anaconda on ARC systems.

Utilizing a GPU in TensorFlow

First, open the Python interpreter associated with the conda environment. Then import TensorFlow, and list available GPUs:

(tf_env) [jdoe2@tc-dgx006 ~]$ python
Python 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
Num GPUs Available:  1
>>> print("GPUs Available: \n", tf.test.gpu_device_name())
GPUs Available:
2024-06-26 18:33:00.887354: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1928] Created device /device:GPU:0 with 79091 MB memory:  -> device: 0, name: NVIDIA A100-SXM4-80GB, pci bus id: 0000:bd:00.0, compute capability: 8.0
'/device:GPU:0'

Note

You can learn more about using TensorFlow over GPUs at TensorFlow GPU Guide.