0
0
TensorFlowml~10 mins

Installation and GPU setup in TensorFlow - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to install TensorFlow using pip.

TensorFlow
pip install [1]
Drag options to blanks, or click blank then click option'
Atensorflow
Bnumpy
Cpandas
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to install unrelated packages like numpy or pandas instead of tensorflow.
2fill in blank
medium

Complete the code to check if TensorFlow can access a GPU device.

TensorFlow
import tensorflow as tf
print(tf.config.list_physical_devices('[1]'))
Drag options to blanks, or click blank then click option'
ADISK
BCPU
CTPU
DGPU
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CPU' instead of 'GPU' will list only CPUs, not GPUs.
3fill in blank
hard

Fix the error in the code to enable memory growth for the first GPU device.

TensorFlow
gpus = tf.config.list_physical_devices('GPU')
if gpus:
    try:
        tf.config.experimental.[1](gpus[0], True)
    except RuntimeError as e:
        print(e)
Drag options to blanks, or click blank then click option'
Aconfigure_memory_growth
Benable_memory_growth
Cset_memory_growth
Dallow_memory_growth
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like 'enable_memory_growth' which do not exist.
4fill in blank
hard

Fill both blanks to import TensorFlow and print the TensorFlow version.

TensorFlow
import [1] as tf
print(tf.[2].VERSION)
Drag options to blanks, or click blank then click option'
Atensorflow
Bkeras
Cversion
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'keras' instead of 'tensorflow' for import.
Using incorrect attributes like 'config'.
5fill in blank
hard

Fill all three blanks to list GPU physical devices and print their names.

TensorFlow
devices = tf.config.list_physical_devices([1])
for device in devices:
    print(device.[2])

# Check if any device is a GPU
has_gpu = any(device.device_type == [3] for device in devices)
print('GPU available:', has_gpu)
Drag options to blanks, or click blank then click option'
A'GPU'
Bname
D'CPU'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CPU' instead of 'GPU' when listing devices or checking device type.
Trying to print 'device_type' instead of 'name' for device names.