Inference
Q: MindSpore 1.3 is installed on the Ascend 310 hardware platform. When I run the add_model.py
sample in mindspore_serving, an error message is displayed. Why?
A: Ascend 310 supports model export and Serving inference, but does not support direct inference using the MindSpore frontend Python script. In the add
sample, the code for direct inference using the MindSpore frontend Python script is added. You only need to comment out the code in the Ascend 310 scenario.
def export_net():
"""Export add net of 2x2 + 2x2, and copy output model `tensor_add.mindir` to directory ../add/1"""
x = np.ones([2, 2]).astype(np.float32)
y = np.ones([2, 2]).astype(np.float32)
add = Net()
# Comment out the MindSpore frontend Python script used for direct inference in the Ascend 310 scenario.
# output = add(ms.Tensor(x), ms.Tensor(y))
ms.export(add, ms.Tensor(x), ms.Tensor(y), file_name='tensor_add', file_format='MINDIR')
dst_dir = '../add/1'
try:
os.mkdir(dst_dir)
except OSError:
pass
dst_file = os.path.join(dst_dir, 'tensor_add.mindir')
copyfile('tensor_add.mindir', dst_file)
print("copy tensor_add.mindir to " + dst_dir + " success")
print(x)
print(y)
# print(output.asnumpy()).
Q: What should I do when error /usr/bin/ld: warning: libxxx.so, needed by libmindspore.so, not found
prompts during application compiling?
A: Find the directory where the missing dynamic library file is located, add the path to the environment variable LD_LIBRARY_PATH
, and refer to Inference Using the MindIR Model on Ascend 310 AI Processors#Building Inference Code for environment variable settings.
Q: What should I do when error ModuleNotFoundError: No module named 'te'
prompts during application running?
A: First confirm whether the system environment is installed correctly and whether the whl packages such as te
and topi
are installed correctly. If there are multiple Python versions in the user environment, such as Conda virtual environment, you need to execute ldd name_of_your_executable_app
to confirm whether the application link libpython3.7m.so.1.0
is consistent with the current Python directory, if not, you need to adjust the order of the environment variable LD_LIBRARY_PATH
.
Q: What should I do when error error while loading shared libraries: libge_compiler.so: cannot open shared object file: No such file or directory
prompts during application running?
A: While installing Ascend 310 AI Processor software packages,the CANN
package should install the full-featured toolkit
version instead of the nnrt
version.
Q: How to set high-precision or high-performance mode when performing inference on Ascend 310 AI Processor?
A: Set in the inference code through the SetPrecisionMode interface of Ascend310DeviceInfo. Optional: force_fp16,allow_fp32_to_fp16,must_keep_origin_dtype,allow_mix_precision. The default value is force_fp16, which refers to the high-performance mode. High precision mode can be set to allow_fp32_to_fp16 or must_keep_origin_dtype.
Q: How to configure AIPP files?
A: AIPP (artistic intelligence pre-processing) AI preprocessing is used to complete image preprocessing on AI core, including changing image size, color gamut conversion (converting image format), subtracting mean / multiplication coefficient (changing image pixels), and real-time inference after data processing. The related configuration introduction is complex. Please refer to AIPP enable chapter of ATC tool
Q: How to set the log level in the inferenct process of Ascend 310 AI Processor?
A: Use ASCEND_GLOBAL_LOG_LEVEL to set log level, 0: debug level; 1: Info level; 2: Warning level; 3: Error level; 4: Null level, no log output; Other values are illegal. Configuration example: export ASCEND_GLOBAL_LOG_LEVEL=1. If there are errors in the inference process, you can modify the log level to obtain more detailed log information.