App Running
The sample procedure applies to the following products:
- Atlas 200/300/500 Inference Product
- Atlas Training Series Product
Model Conversion
- Log in to the development environment as the HwHiAiUser user (running user).
- Obtain the ATC tool and set environment variables by referring to ATC Instructions.
- Prepare data.
Obtain the ResNet-50 weight file (.caffemodel) and model file (resnet50.prototxt) from the following link and upload the files to the caffe_model directory under the resnet50_async_imagenet_classification directory sample in the development environment as the HwHiAiUser user (running user).
- Convert the ResNet-50 network into an offline model (.om file) adapted to the Ascend AI Processor.
Go to the resnet50_async_imagenet_classification directory and run the following command: Ascendxxx indicates the Ascend AI Processor version. Replace it with the actual one.
atc --model=caffe_model/resnet50.prototxt --weight=caffe_model/resnet50.caffemodel --framework=0 --output=model/resnet50 --soc_version=Ascendxxx --input_format=NCHW --input_fp16_nodes=data --output_type=FP32 --out_nodes=prob:0
- --output: The generated resnet50.om file is stored in the resnet50_async_imagenet_classification/model directory.
- Before running the atc command, ensure that you have the write permission on the resnet50_async_imagenet_classification directory.
- If the soc_version of the current device cannot be determined, run the npu-smi info command on the server where the NPU driver package is installed and add Ascend information before the queried Name. For example, if the value of Name is xxxyy, the actual soc_version is Ascendxxxyy.
- As the HwHiAiUser running user, upload the sample directory in the development environment to the operating environment.
App Running
- Log in to the operating environment.
- Prepare test data. Click the following links to download the input images of this sample and upload the images to the resnet50_async_imagenet_classification/data directory in the development environment as the running user. If the directory does not exist, create it.
- Configure the operating environment by referring to Environment Variable Configuration.
- Run the following command in resnet50_async_imagenet_classification:
python3 ./src/acl_net.py
- Check the execution result. You should find the following information upon execution success:
Using device id:0 execute_times:4 callback_interval:1 mem_pools:4 model path:./model/resnet50.om images path:./data init resource stage: init resource stage success data interaction from host to device data interaction from host to device success execute stage: execute stage success callback func stage: ======== top5 inference results: ============= [161]: 0.767578 [162]: 0.154785 [167]: 0.038513 [163]: 0.021606 [166]: 0.011658 callback func stage success callback func stage: ======== top5 inference results: ============= [267]: 0.935547 [266]: 0.041107 [265]: 0.018829 [219]: 0.002607 [160]: 0.000295 callback func stage success callback func stage: ======== top5 inference results: ============= [161]: 0.767578 [162]: 0.154785 [167]: 0.038513 [163]: 0.021606 [166]: 0.011658 callback func stage success callback func stage: ======== top5 inference results: ============= [267]: 0.935547 [266]: 0.041107 [265]: 0.018829 [219]: 0.002607 [160]: 0.000295 callback func stage success exit acl.rt.process_report run finish!!! release source stage: release source stage success