0
0
TensorFlowml~20 mins

Installation and GPU setup in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
GPU Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding GPU availability in TensorFlow
Which TensorFlow command correctly checks if a GPU is available for use?
Atf.check_gpu()
Btf.device('GPU')
Ctf.gpu.is_available()
Dtf.config.list_physical_devices('GPU')
Attempts:
2 left
💡 Hint
Look for the TensorFlow function that lists physical devices.
Predict Output
intermediate
2:00remaining
Output of TensorFlow GPU memory growth setting
What is the output of this code snippet when run on a system with one GPU?
TensorFlow
import tensorflow as tf

gpus = tf.config.list_physical_devices('GPU')
if gpus:
    try:
        for gpu in gpus:
            tf.config.experimental.set_memory_growth(gpu, True)
        print('Memory growth set')
    except RuntimeError as e:
        print(e)
else:
    print('No GPU found')
AMemory growth set
BNo GPU found
CSyntaxError
DRuntimeError: Memory growth must be set before GPUs have been initialized
Attempts:
2 left
💡 Hint
If a GPU is present and memory growth is set before initialization, it prints confirmation.
Model Choice
advanced
2:00remaining
Choosing the correct TensorFlow version for GPU support
Which TensorFlow version is required to support GPU acceleration on CUDA 11.2?
ATensorFlow 1.15
BTensorFlow 2.4
CTensorFlow 2.5
DTensorFlow 2.3
Attempts:
2 left
💡 Hint
Check TensorFlow release notes for CUDA compatibility.
Hyperparameter
advanced
2:00remaining
Setting GPU device in TensorFlow
Which code snippet correctly sets TensorFlow to use only the first GPU device?
Atf.config.set_visible_devices([tf.config.list_physical_devices('GPU')[0]], 'GPU')
Btf.config.set_visible_devices(tf.config.list_physical_devices('GPU')[0], 'GPU')
Ctf.device('/GPU:0')
Dtf.config.set_visible_devices('GPU:0')
Attempts:
2 left
💡 Hint
The function expects a list of devices, not a single device.
🔧 Debug
expert
2:00remaining
Diagnosing TensorFlow GPU memory allocation error
Given this error message when running TensorFlow code on GPU: "ResourceExhaustedError: OOM when allocating tensor", what is the most likely cause?
ATensorFlow is not installed correctly
BThe GPU ran out of memory due to large batch size or model size
CThe CPU is overloaded and cannot handle the computation
DThe GPU driver is outdated and incompatible
Attempts:
2 left
💡 Hint
OOM means out of memory on the GPU device.