FAQ

import Error

Error I: Cannot find the extension library(_C.so)

Solution:

  • Make sure that the horizon_plugin_pytorch version corresponds to the cuda version.
  • In python3, find the execution path of horizon_plugin_pytorch and check for .so files in that directory. There may be multiple versions of horizon_plugin_pytorch at the same time, so you need to uninstall it and keep only the one you need.

Error II: RuntimeError: Cannot load custom ops. Please rebuild the horizon_plugin_pytorch

Solution: check if the local CUDA environment is OK, such as path, version, etc.

Unable to prepare_calibration/qat

RuntimeError: Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol at the moment

Solution: generally it is the inclusion of a non-leaf tensor in the model that causes this error, try the following:

  • Set the inplace of prepare_calibration/qat to True.
  • This error does not occur with normal horizon_plugin_pytorch definitions operators, check if there is a non-leaf tensor defined for the customized operator in the model.

forward Error after prepare_qat

TypeError: when calling function <built-in method conv2d of type object at >

Solution: the customized operator inherits the Module operator of a torch, which results in prepare_qat not being converted to a qat module. it is recommended to use the submodule method to call conv2d.

Quantized Accuracy Anomaly

The QAT/Quantized accuracy is not as expected, there is a NAN, or the initial QAT loss is clearly anomalous with respect to float.

Solution: please refer to the section Accuracy Tuning Tool Guide.