0
0
Computer Visionml~10 mins

TensorRT acceleration in Computer Vision - Interactive Code Practice

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

Complete the code to import the TensorRT Python module.

Computer Vision
import [1]
Drag options to blanks, or click blank then click option'
Atensorrt
Btensorflow
Ccv2
Dtorch
Attempts:
3 left
💡 Hint
Common Mistakes
Importing TensorFlow or PyTorch instead of TensorRT.
Using OpenCV (cv2) which is unrelated to TensorRT.
2fill in blank
medium

Complete the code to create a TensorRT logger with warning level.

Computer Vision
logger = tensorrt.Logger([1])
Drag options to blanks, or click blank then click option'
Atensorrt.Logger.ERROR
Btensorrt.Logger.WARNING
Ctensorrt.Logger.INFO
Dtensorrt.Logger.VERBOSE
Attempts:
3 left
💡 Hint
Common Mistakes
Using INFO or VERBOSE which produce too many messages.
Using ERROR which hides warnings.
3fill in blank
hard

Fix the error in building a TensorRT engine from a network definition.

Computer Vision
builder = tensorrt.Builder(logger)
network = builder.create_network()
config = builder.create_builder_config()
engine = builder.[1](network, config)
Drag options to blanks, or click blank then click option'
Abuild_cuda_engine
Bbuild_engine
Ccreate_engine
Dcompile_engine
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent methods like 'build_engine' or 'create_engine'.
Confusing engine building with network creation.
4fill in blank
hard

Fill both blanks to create an execution context and allocate device memory for input.

Computer Vision
context = engine.[1]()
input_memory = cuda.mem_alloc(engine.[2](0))
Drag options to blanks, or click blank then click option'
Acreate_execution_context
Bexecute
Cget_binding_shape
Dallocate_memory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute' instead of creating context.
Allocating memory without knowing the correct size.
5fill in blank
hard

Fill all three blanks to run inference and copy output from device to host.

Computer Vision
context.execute_v2(bindings=[input_memory, [1]])
cuda.memcpy_dtoh([2], [3])
Drag options to blanks, or click blank then click option'
Ainput_memory
Boutput_host
Coutput_device
Dinput_host
Attempts:
3 left
💡 Hint
Common Mistakes
Passing host memory instead of device memory in bindings.
Copying data from host to device instead of device to host.