0
0
PyTorchml~10 mins

Multi-GPU training in PyTorch - Interactive Code Practice

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

Complete the code to move the model to the GPU device.

PyTorch
model = MyModel()
model = model.[1]('cuda')
Drag options to blanks, or click blank then click option'
Acuda_device
Bcpu
Cto
Ddevice
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cpu' instead of 'cuda' moves the model to the CPU, not GPU.
Trying to use a non-existent method like 'cuda_device' or 'device'.
2fill in blank
medium

Complete the code to wrap the model for multi-GPU training.

PyTorch
model = MyModel().to('cuda')
model = torch.nn.[1](model)
Drag options to blanks, or click blank then click option'
ADataParallel
BDistributedDataParallel
CParallelData
DMultiGPUWrapper
Attempts:
3 left
💡 Hint
Common Mistakes
Using DistributedDataParallel without setting up distributed environment.
Using made-up wrappers like 'MultiGPUWrapper'.
3fill in blank
hard

Fix the error in the code to correctly move input data to the GPU.

PyTorch
inputs = inputs.[1]('cuda')
Drag options to blanks, or click blank then click option'
Ato
Bmove
Cdevice
Dcuda_device
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to use non-existent methods like 'cuda_device' or 'move'.
Forgetting to move inputs to the same device as the model.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores squared values for even numbers only.

PyTorch
squares = {x: x[1]2 for x in range(1, 11) if x [2] 2 == 0}
Drag options to blanks, or click blank then click option'
A**
B%
C//
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using // instead of % for checking even numbers.
Using + instead of ** for squaring.
5fill in blank
hard

Fill all three blanks to create a filtered dictionary with uppercase keys and values greater than zero.

PyTorch
result = [1]: [2] for k, v in data.items() if v [3] 0}
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using k.lower() instead of k.upper().
Using < instead of > for filtering.