fix for TCC mode cards(tesla), was conflict with plaidML initialization.

This commit is contained in:
iperov 2019-04-19 10:37:43 +04:00
commit 7fe4cd4643

View file

@ -274,10 +274,14 @@ has_nvml_cap = False
#- CUDA build of DFL #- CUDA build of DFL
has_nvidia_device = os.environ.get("DFL_FORCE_HAS_NVIDIA_DEVICE", "0") == "1" has_nvidia_device = os.environ.get("DFL_FORCE_HAS_NVIDIA_DEVICE", "0") == "1"
plaidML_devices = [] plaidML_devices = None
def get_plaidML_devices():
# Using plaidML OpenCL backend to determine system devices and has_nvidia_device global plaidML_devices
try: global has_nvidia_device
if plaidML_devices is None:
plaidML_devices = []
# Using plaidML OpenCL backend to determine system devices and has_nvidia_device
try:
os.environ['PLAIDML_EXPERIMENTAL'] = 'false' #this enables work plaidML without run 'plaidml-setup' os.environ['PLAIDML_EXPERIMENTAL'] = 'false' #this enables work plaidML without run 'plaidml-setup'
import plaidml import plaidml
ctx = plaidml.Context() ctx = plaidml.Context()
@ -292,10 +296,12 @@ try:
'description' : d.description.decode() 'description' : d.description.decode()
}] }]
ctx.shutdown() ctx.shutdown()
except: except:
pass pass
return plaidML_devices
plaidML_devices_count = len(plaidML_devices) if not has_nvidia_device:
get_plaidML_devices()
#choosing backend #choosing backend
@ -324,7 +330,7 @@ if device.backend is None and not force_tf_cpu:
if force_plaidML or (device.backend is None and not has_nvidia_device): if force_plaidML or (device.backend is None and not has_nvidia_device):
#tensorflow backend was failed without has_nvidia_device , or forcing plaidML, trying to use plaidML backend #tensorflow backend was failed without has_nvidia_device , or forcing plaidML, trying to use plaidML backend
if plaidML_devices_count == 0: if len(get_plaidML_devices()) == 0:
#print ("plaidML: No capable OpenCL devices found. Falling back to tensorflow backend.") #print ("plaidML: No capable OpenCL devices found. Falling back to tensorflow backend.")
device.backend = None device.backend = None
else: else: