0
0
TensorFlowml~5 mins

GPU vs CPU tensor placement in TensorFlow - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is the main difference between CPU and GPU in tensor placement?
CPU handles general tasks and is good for sequential operations, while GPU is specialized for parallel tasks, making it faster for large tensor operations in machine learning.
Click to reveal answer
beginner
How does TensorFlow decide where to place a tensor by default?
TensorFlow tries to place tensors on the GPU if available for faster computation; otherwise, it uses the CPU.
Click to reveal answer
intermediate
What is the TensorFlow command to explicitly place a tensor on the GPU?
Use with tf.device('/GPU:0'): to place tensors or operations explicitly on the first GPU device.
Click to reveal answer
intermediate
Why might you want to place tensors on the CPU instead of the GPU?
You might place tensors on the CPU if the GPU memory is limited, or for operations that are not efficient on GPU, like small or simple computations.
Click to reveal answer
advanced
What happens if you try to perform an operation on tensors placed on different devices?
TensorFlow will automatically copy data between devices, but this can slow down performance due to data transfer overhead.
Click to reveal answer
Which device is generally faster for large matrix multiplications in TensorFlow?
AHard disk
BGPU
CCPU
DRAM
How do you specify a tensor to be placed on the CPU in TensorFlow?
Awith tf.device('/DISK:0'):
Bwith tf.device('/GPU:0'):
Cwith tf.device('/TPU:0'):
Dwith tf.device('/CPU:0'):
What is a downside of placing tensors on different devices for operations?
ATensors get deleted
BTensorFlow crashes
CAutomatic data transfer slows performance
DNo downside
If no GPU is available, where does TensorFlow place tensors by default?
ACPU
BGPU
CTPU
DDisk
Which TensorFlow function helps you check available devices?
Atf.config.list_physical_devices()
Btf.device()
Ctf.Tensor()
Dtf.run()
Explain how TensorFlow manages tensor placement between CPU and GPU and why this matters.
Think about speed and where computations happen.
You got /4 concepts.
    Describe a situation where placing tensors on CPU might be better than GPU.
    Consider resource limits and operation size.
    You got /4 concepts.