未验证 提交 98278f0e 编写于 作者: T TeslaZhao 提交者: GitHub

Merge pull request #1277 from zhangjun/fix-avx-support

auto detect cpu avx instruction set
...@@ -35,6 +35,7 @@ import numpy as np ...@@ -35,6 +35,7 @@ import numpy as np
import grpc import grpc
import sys import sys
import collections import collections
import subprocess
from multiprocessing import Pool, Process from multiprocessing import Pool, Process
from concurrent import futures from concurrent import futures
...@@ -330,12 +331,21 @@ class Server(object): ...@@ -330,12 +331,21 @@ class Server(object):
def use_mkl(self, flag): def use_mkl(self, flag):
self.mkl_flag = 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): def get_device_version(self):
avx_flag = False avx_flag = False
mkl_flag = self.mkl_flag avx_support = self.check_avx()
r = os.system("cat /proc/cpuinfo | grep avx > /dev/null 2>&1") if avx_suppport:
if r == 0:
avx_flag = True avx_flag = True
self.use_mkl(True)
mkl_flag = self.mkl_flag
if avx_flag: if avx_flag:
if mkl_flag: if mkl_flag:
device_version = "cpu-avx-mkl" device_version = "cpu-avx-mkl"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册