Complete the code to print the current GPU hardware version using the NVIDIA System Management Interface.
import subprocess result = subprocess.run(['nvidia-smi', '--query-gpu=hardware_version', '--format=csv,noheader'], capture_output=True, text=True) print(result.[1])
stderr instead of stdout to get output.The stdout attribute contains the output of the command, which includes the hardware version.
Complete the code to get the installed TensorFlow version.
import tensorflow as tf print(tf.[1])
version or get_version which do not exist.The TensorFlow version is accessed via the __version__ attribute.
Fix the error in the code to correctly log hardware and framework versions to a file.
with open('version_log.txt', 'w') as f: f.write('GPU Version: ' + gpu_version + '\n') f.write('TensorFlow Version: ' + [1] + '\n')
tf.version which is not a string.The correct attribute to get TensorFlow version is tf.__version__. The others are incorrect or do not exist.
Fill both blanks to create a dictionary that maps hardware and framework versions for tracking.
version_info = {
'gpu': [1],
'framework': [2]
}The dictionary keys should map to the variables holding GPU and TensorFlow versions respectively.
Fill all three blanks to write a function that returns hardware and framework versions as a dictionary.
def get_versions(): gpu = [1] framework = [2] return [3]
The function assigns the GPU and framework versions to variables and returns a dictionary with those values.