提交 0aee586a 编写于 作者: S syyxsxx

fix mkldnn

上级 ff90e5a0
...@@ -30,6 +30,9 @@ DEFINE_string(model_dir, "", "Path of inference model"); ...@@ -30,6 +30,9 @@ DEFINE_string(model_dir, "", "Path of inference model");
DEFINE_bool(use_gpu, false, "Infering with GPU or CPU"); DEFINE_bool(use_gpu, false, "Infering with GPU or CPU");
DEFINE_bool(use_trt, false, "Infering with TensorRT"); DEFINE_bool(use_trt, false, "Infering with TensorRT");
DEFINE_bool(use_mkl, true, "Infering with MKL"); DEFINE_bool(use_mkl, true, "Infering with MKL");
DEFINE_int32(mkl_thread_num,
omp_get_num_procs(),
"Number of mkl threads");
DEFINE_int32(gpu_id, 0, "GPU card id"); DEFINE_int32(gpu_id, 0, "GPU card id");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_string(image, "", "Path of test image file"); DEFINE_string(image, "", "Path of test image file");
...@@ -60,7 +63,7 @@ int main(int argc, char** argv) { ...@@ -60,7 +63,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num;
// Predict // Predict
int imgs = 1; int imgs = 1;
......
...@@ -32,6 +32,9 @@ DEFINE_string(model_dir, "", "Path of inference model"); ...@@ -32,6 +32,9 @@ DEFINE_string(model_dir, "", "Path of inference model");
DEFINE_bool(use_gpu, false, "Infering with GPU or CPU"); DEFINE_bool(use_gpu, false, "Infering with GPU or CPU");
DEFINE_bool(use_trt, false, "Infering with TensorRT"); DEFINE_bool(use_trt, false, "Infering with TensorRT");
DEFINE_bool(use_mkl, true, "Infering with MKL"); DEFINE_bool(use_mkl, true, "Infering with MKL");
DEFINE_int32(mkl_thread_num,
omp_get_num_procs(),
"Number of mkl threads");
DEFINE_int32(gpu_id, 0, "GPU card id"); DEFINE_int32(gpu_id, 0, "GPU card id");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_string(image, "", "Path of test image file"); DEFINE_string(image, "", "Path of test image file");
...@@ -65,7 +68,7 @@ int main(int argc, char** argv) { ...@@ -65,7 +68,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num);
int imgs = 1; int imgs = 1;
std::string save_dir = "output"; std::string save_dir = "output";
// Predict // Predict
......
...@@ -31,6 +31,9 @@ DEFINE_string(model_dir, "", "Path of inference model"); ...@@ -31,6 +31,9 @@ DEFINE_string(model_dir, "", "Path of inference model");
DEFINE_bool(use_gpu, false, "Infering with GPU or CPU"); DEFINE_bool(use_gpu, false, "Infering with GPU or CPU");
DEFINE_bool(use_trt, false, "Infering with TensorRT"); DEFINE_bool(use_trt, false, "Infering with TensorRT");
DEFINE_bool(use_mkl, true, "Infering with MKL"); DEFINE_bool(use_mkl, true, "Infering with MKL");
DEFINE_int32(mkl_thread_num,
omp_get_num_procs(),
"Number of mkl threads");
DEFINE_int32(gpu_id, 0, "GPU card id"); DEFINE_int32(gpu_id, 0, "GPU card id");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_string(image, "", "Path of test image file"); DEFINE_string(image, "", "Path of test image file");
...@@ -62,7 +65,7 @@ int main(int argc, char** argv) { ...@@ -62,7 +65,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num);
int imgs = 1; int imgs = 1;
// Predict // Predict
if (FLAGS_image_list != "") { if (FLAGS_image_list != "") {
......
...@@ -38,9 +38,9 @@ DEFINE_bool(use_trt, false, "Infering with TensorRT"); ...@@ -38,9 +38,9 @@ DEFINE_bool(use_trt, false, "Infering with TensorRT");
DEFINE_bool(use_mkl, true, "Infering with MKL"); DEFINE_bool(use_mkl, true, "Infering with MKL");
DEFINE_int32(gpu_id, 0, "GPU card id"); DEFINE_int32(gpu_id, 0, "GPU card id");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_int32(thread_num, DEFINE_int32(mkl_thread_num,
omp_get_num_procs(), omp_get_num_procs(),
"Number of preprocessing threads"); "Number of mkl threads");
DEFINE_bool(use_camera, false, "Infering with Camera"); DEFINE_bool(use_camera, false, "Infering with Camera");
DEFINE_int32(camera_id, 0, "Camera id"); DEFINE_int32(camera_id, 0, "Camera id");
DEFINE_string(video_path, "", "Path of input video"); DEFINE_string(video_path, "", "Path of input video");
...@@ -69,7 +69,7 @@ int main(int argc, char** argv) { ...@@ -69,7 +69,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num);
// Open video // Open video
cv::VideoCapture capture; cv::VideoCapture capture;
......
...@@ -43,9 +43,9 @@ DEFINE_string(video_path, "", "Path of input video"); ...@@ -43,9 +43,9 @@ DEFINE_string(video_path, "", "Path of input video");
DEFINE_bool(show_result, false, "show the result of each frame with a window"); DEFINE_bool(show_result, false, "show the result of each frame with a window");
DEFINE_bool(save_result, true, "save the result of each frame to a video"); DEFINE_bool(save_result, true, "save the result of each frame to a video");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_int32(thread_num, DEFINE_int32(mkl_thread_num,
omp_get_num_procs(), omp_get_num_procs(),
"Number of preprocessing threads"); "Number of mkl threads");
DEFINE_string(save_dir, "output", "Path to save visualized image"); DEFINE_string(save_dir, "output", "Path to save visualized image");
DEFINE_double(threshold, DEFINE_double(threshold,
0.5, 0.5,
...@@ -71,7 +71,7 @@ int main(int argc, char** argv) { ...@@ -71,7 +71,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num);
// Open video // Open video
cv::VideoCapture capture; cv::VideoCapture capture;
if (FLAGS_use_camera) { if (FLAGS_use_camera) {
......
...@@ -38,9 +38,9 @@ DEFINE_bool(use_trt, false, "Infering with TensorRT"); ...@@ -38,9 +38,9 @@ DEFINE_bool(use_trt, false, "Infering with TensorRT");
DEFINE_bool(use_mkl, true, "Infering with MKL"); DEFINE_bool(use_mkl, true, "Infering with MKL");
DEFINE_int32(gpu_id, 0, "GPU card id"); DEFINE_int32(gpu_id, 0, "GPU card id");
DEFINE_string(key, "", "key of encryption"); DEFINE_string(key, "", "key of encryption");
DEFINE_int32(thread_num, DEFINE_int32(mkl_thread_num,
omp_get_num_procs(), omp_get_num_procs(),
"Number of preprocessing threads"); "Number of mkl threads");
DEFINE_bool(use_camera, false, "Infering with Camera"); DEFINE_bool(use_camera, false, "Infering with Camera");
DEFINE_int32(camera_id, 0, "Camera id"); DEFINE_int32(camera_id, 0, "Camera id");
DEFINE_string(video_path, "", "Path of input video"); DEFINE_string(video_path, "", "Path of input video");
...@@ -69,7 +69,7 @@ int main(int argc, char** argv) { ...@@ -69,7 +69,7 @@ int main(int argc, char** argv) {
FLAGS_use_mkl, FLAGS_use_mkl,
FLAGS_gpu_id, FLAGS_gpu_id,
FLAGS_key, FLAGS_key,
FLAGS_thread_num); FLAGS_mkl_thread_num);
// Open video // Open video
cv::VideoCapture capture; cv::VideoCapture capture;
if (FLAGS_use_camera) { if (FLAGS_use_camera) {
......
...@@ -80,7 +80,7 @@ class Model { ...@@ -80,7 +80,7 @@ class Model {
bool use_mkl = true, bool use_mkl = true,
int gpu_id = 0, int gpu_id = 0,
std::string key = "", std::string key = "",
int thread_num = 1, int mkl_thread_num = 4,
bool use_ir_optim = true) { bool use_ir_optim = true) {
create_predictor( create_predictor(
model_dir, model_dir,
...@@ -89,7 +89,7 @@ class Model { ...@@ -89,7 +89,7 @@ class Model {
use_mkl, use_mkl,
gpu_id, gpu_id,
key, key,
thread_num, mkl_thread_num,
use_ir_optim); use_ir_optim);
} }
...@@ -99,7 +99,7 @@ class Model { ...@@ -99,7 +99,7 @@ class Model {
bool use_mkl = true, bool use_mkl = true,
int gpu_id = 0, int gpu_id = 0,
std::string key = "", std::string key = "",
int thread_num = 1, int mkl_thread_num = 4,
bool use_ir_optim = true); bool use_ir_optim = true);
/* /*
......
...@@ -31,7 +31,7 @@ void Model::create_predictor(const std::string& model_dir, ...@@ -31,7 +31,7 @@ void Model::create_predictor(const std::string& model_dir,
bool use_mkl, bool use_mkl,
int gpu_id, int gpu_id,
std::string key, std::string key,
int thread_num, int mkl_thread_num,
bool use_ir_optim) { bool use_ir_optim) {
paddle::AnalysisConfig config; paddle::AnalysisConfig config;
std::string model_file = model_dir + OS_PATH_SEP + "__model__"; std::string model_file = model_dir + OS_PATH_SEP + "__model__";
...@@ -68,7 +68,7 @@ void Model::create_predictor(const std::string& model_dir, ...@@ -68,7 +68,7 @@ void Model::create_predictor(const std::string& model_dir,
} }
if (use_mkl && name != "HRNet" && name != "DeepLabv3p") { if (use_mkl && name != "HRNet" && name != "DeepLabv3p") {
config.EnableMKLDNN(); config.EnableMKLDNN();
config.SetCpuMathLibraryNumThreads(12); config.SetCpuMathLibraryNumThreads(mkl_thread_num);
} }
if (use_gpu) { if (use_gpu) {
config.EnableUseGpu(100, gpu_id); config.EnableUseGpu(100, gpu_id);
......
...@@ -126,6 +126,7 @@ yaml-cpp.zip文件下载后无需解压,在cmake/yaml.cmake中将`URL https:// ...@@ -126,6 +126,7 @@ yaml-cpp.zip文件下载后无需解压,在cmake/yaml.cmake中将`URL https://
| use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) | | use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) |
| use_trt | 是否使用 TensorRT 预测, 支持值为0或1(默认值为0) | | use_trt | 是否使用 TensorRT 预测, 支持值为0或1(默认值为0) |
| use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) | | use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) |
| mkl_thread_num | MKL推理的线程数,默认为cpu处理器个数 |
| gpu_id | GPU 设备ID, 默认值为0 | | gpu_id | GPU 设备ID, 默认值为0 |
| save_dir | 保存可视化结果的路径, 默认值为"output",**classfier无该参数** | | save_dir | 保存可视化结果的路径, 默认值为"output",**classfier无该参数** |
| key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 | | key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 |
...@@ -143,12 +144,12 @@ yaml-cpp.zip文件下载后无需解压,在cmake/yaml.cmake中将`URL https:// ...@@ -143,12 +144,12 @@ yaml-cpp.zip文件下载后无需解压,在cmake/yaml.cmake中将`URL https://
| use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) | | use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) |
| use_trt | 是否使用 TensorRT 预测, 支持值为0或1(默认值为0) | | use_trt | 是否使用 TensorRT 预测, 支持值为0或1(默认值为0) |
| use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) | | use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) |
| mkl_thread_num | MKL推理的线程数,默认为cpu处理器个数 |
| gpu_id | GPU 设备ID, 默认值为0 | | gpu_id | GPU 设备ID, 默认值为0 |
| show_result | 对视频文件做预测时,是否在屏幕上实时显示预测可视化结果(因加入了延迟处理,故显示结果不能反映真实的帧率),支持值为0或1(默认值为0) | | show_result | 对视频文件做预测时,是否在屏幕上实时显示预测可视化结果(因加入了延迟处理,故显示结果不能反映真实的帧率),支持值为0或1(默认值为0) |
| save_result | 是否将每帧的预测可视结果保存为视频文件,支持值为0或1(默认值为1) | | save_result | 是否将每帧的预测可视结果保存为视频文件,支持值为0或1(默认值为1) |
| save_dir | 保存可视化结果的路径, 默认值为"output"| | save_dir | 保存可视化结果的路径, 默认值为"output"|
| key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 | | key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 |
| thread_num | 预测的线程数,默认为cpu处理器个数 |
**注意:若系统无GUI,则不要将show_result设置为1。当使用摄像头预测时,按`ESC`键可关闭摄像头并推出预测程序。** **注意:若系统无GUI,则不要将show_result设置为1。当使用摄像头预测时,按`ESC`键可关闭摄像头并推出预测程序。**
......
...@@ -110,6 +110,7 @@ cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release ...@@ -110,6 +110,7 @@ cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release
| image_list | 按行存储图片路径的.txt文件 | | image_list | 按行存储图片路径的.txt文件 |
| use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) | | use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) |
| use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) | | use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) |
| mkl_thread_num | MKL推理的线程数,默认为cpu处理器个数 |
| gpu_id | GPU 设备ID, 默认值为0 | | gpu_id | GPU 设备ID, 默认值为0 |
| save_dir | 保存可视化结果的路径, 默认值为"output",classifier无该参数 | | save_dir | 保存可视化结果的路径, 默认值为"output",classifier无该参数 |
| key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 | | key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 |
...@@ -126,12 +127,12 @@ cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release ...@@ -126,12 +127,12 @@ cd D:\projects\PaddleX\deploy\cpp\out\build\x64-Release
| video_path | 视频文件的路径 | | video_path | 视频文件的路径 |
| use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) | | use_gpu | 是否使用 GPU 预测, 支持值为0或1(默认值为0) |
| use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) | | use_mkl | 是否使用 MKL加速CPU预测, 支持值为0或1(默认值为1) |
| mkl_thread_num | MKL推理的线程数,默认为cpu处理器个数 |
| gpu_id | GPU 设备ID, 默认值为0 | | gpu_id | GPU 设备ID, 默认值为0 |
| show_result | 对视频文件做预测时,是否在屏幕上实时显示预测可视化结果(因加入了延迟处理,故显示结果不能反映真实的帧率),支持值为0或1(默认值为0) | | show_result | 对视频文件做预测时,是否在屏幕上实时显示预测可视化结果(因加入了延迟处理,故显示结果不能反映真实的帧率),支持值为0或1(默认值为0) |
| save_result | 是否将每帧的预测可视结果保存为视频文件,支持值为0或1(默认值为1) | | save_result | 是否将每帧的预测可视结果保存为视频文件,支持值为0或1(默认值为1) |
| save_dir | 保存可视化结果的路径, 默认值为"output" | | save_dir | 保存可视化结果的路径, 默认值为"output" |
| key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 | | key | 加密过程中产生的密钥信息,默认值为""表示加载的是未加密的模型 |
| thread_num | 预测的线程数,默认为cpu处理器个数 |
**注意:若系统无GUI,则不要将show_result设置为1。当使用摄像头预测时,按`ESC`键可关闭摄像头并推出预测程序。** **注意:若系统无GUI,则不要将show_result设置为1。当使用摄像头预测时,按`ESC`键可关闭摄像头并推出预测程序。**
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
# limitations under the License. # limitations under the License.
import os import os
import os.path as osp import os.path as osp
import psutil
import cv2 import cv2
import numpy as np import numpy as np
import yaml import yaml
...@@ -31,7 +30,7 @@ class Predictor: ...@@ -31,7 +30,7 @@ class Predictor:
use_gpu=True, use_gpu=True,
gpu_id=0, gpu_id=0,
use_mkl=False, use_mkl=False,
mkl_thread_num=psutil.cpu_count(), mkl_thread_num=4,
use_trt=False, use_trt=False,
use_glog=False, use_glog=False,
memory_optimize=True): memory_optimize=True):
......
...@@ -2,7 +2,6 @@ tqdm ...@@ -2,7 +2,6 @@ tqdm
colorama colorama
sklearn sklearn
cython cython
psutil
pycocotools pycocotools
visualdl >= 2.0.0b visualdl >= 2.0.0b
paddleslim == 1.0.1 paddleslim == 1.0.1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册