Skip to content

Commit

Permalink
Merge pull request #1277 from zhangjun/fix-avx-support
Browse files Browse the repository at this point in the history
auto detect cpu avx instruction set
  • Loading branch information
TeslaZhao authored Jun 10, 2021
2 parents 603380d + 83a01a7 commit 98278f0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions python/paddle_serving_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import grpc
import sys
import collections
import subprocess

from multiprocessing import Pool, Process
from concurrent import futures
Expand Down Expand Up @@ -330,12 +331,21 @@ def load_model_config(self, model_config_paths_args):
def use_mkl(self, flag):
self.mkl_flag = flag

def check_avx(self):
p = subprocess.Popen(['cat /proc/cpuinfo | grep avx 2>/dev/null'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = p.communicate()
if err == '' and len(out) > 0:
return True
else:
return False

def get_device_version(self):
avx_flag = False
mkl_flag = self.mkl_flag
r = os.system("cat /proc/cpuinfo | grep avx > /dev/null 2>&1")
if r == 0:
avx_support = self.check_avx()
if avx_suppport:
avx_flag = True
self.use_mkl(True)
mkl_flag = self.mkl_flag
if avx_flag:
if mkl_flag:
device_version = "cpu-avx-mkl"
Expand Down

0 comments on commit 98278f0

Please sign in to comment.