未验证 提交 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
import grpc
import sys
import collections
import subprocess
from multiprocessing import Pool, Process
from concurrent import futures
......@@ -330,12 +331,21 @@ class Server(object):
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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册