如何解决错误:不创建XLA设备- tensorflow?



这是一个交通标志识别项目,我已经运行了训练代码并获得了训练精度。然后,当我运行测试代码时,它会给我一个错误。笔记本电脑的摄像头打开了,但我没有任何接口来测试我的输入。

代码为:

import img as img
import numpy as np
import cv2
import os
import pickle
from keras.models import load_model
import tensorflow as tf
#############################################
frameWidth = 640  # CAMERA RESOLUTION
frameHeight = 480
brightness = 180
threshold = 0.75  # PROBABLITY THRESHOLD
font = cv2.FONT_HERSHEY_SIMPLEX
##############################################
# SETUP THE VIDEO CAMERA
cap = cv2.VideoCapture(0)
cap.set(3, frameWidth)
cap.set(4, frameHeight)
cap.set(10, brightness)
#####IMPORT THE TRAINED MODEL#####
model = load_model('my_model.h5')
os.environ['TF_XLA_FLAGS'] = '--tf_xla_enable_xla_devices'

def grayscale(img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
return img

def equalize(img):
img = cv2.equalizeHist(img)
return img

def preprocessing(img):
img = grayscale(img)
img = equalize(img)
img = img / 255
return img

def getCalssName(classNo):
if classNo == 0:
return 'Speed Limit 20 km/h'
elif classNo == 1:
return 'Speed Limit 30 km/h'
.......
.......
elif classNo == 40:
return 'Roundabout mandatory'
elif classNo == 41:
return 'End of no passing'
elif classNo == 42:
return 'End of no passing by vechiles over 3.5 metric tons'

while True:
# READ IMAGE
success, imgOrignal = cap.read()
# PROCESS IMAGE
img = np.asarray(imgOrignal)
img = cv2.resize(img, (32, 32))
img = preprocessing(img)
cv2.imshow("Processed Image", img)
img = img.reshape(1, 32, 32, 1)
cv2.putText(imgOrignal, "CLASS: ", (20, 35), font,
0.75, (0, 0, 255), 2, cv2.LINE_AA)
cv2.putText(imgOrignal, "PROBABILITY: ", (20, 75),
font, 0.75, (0, 0, 255), 2, cv2.LINE_AA)
# PREDICT IMAGE
predictions = model.predict(img)
classIndex = model.predict_classes(img)
probabilityValue = np.amax(predictions)
if probabilityValue > threshold:
# print(getCalssName(classIndex))
cv2.putText(imgOrignal, str(classIndex) + " " + str(getCalssName(classIndex)),
(120, 35), font, 0.75, (0, 0, 255), 2, cv2.LINE_AA)
cv2.putText(imgOrignal, str(round(probabilityValue * 100, 2)) + "%",
(180, 75), font, 0.75, (0, 0, 255), 2, cv2.LINE_AA)
cv2.imshow("Result", imgOrignal)
if cv2.waitKey(1) and 0xFF == ord('q'):
"break"
cv2.waitkey(0) == ord(q)

错误是

2010-08-29 18:34:31.841473: Wtensorflow/stream_executor/平台//dso_loader违约。答:60)未加载动态库cudart64_110.dll;dlerror: cudart64_110.dll没有找到2013-08-29 18:34:31.843330: I tensorflow/stream_executor/cuda/cudart_stub。[00:29]忽略以上建议如果您的机器上没有设置GPU,则会出现此错误。2017-08-29 18:34:46.621957: I tensorflow/compiler/jit/xla_cpu_device。[00:41]没有创建XLA未设置tf_xla_enable_xla_devices2013-08-29 18:34:46.626059: wtensorflow/stream_executor/platform/default/dso_loader. exe答:60)未加载动态库nvcuda.dll;没有找到nvcuda.dll2013-08-29 18:34:46.626801: wtensorflow/stream_executor/cuda/cuda_driver. exe。抄送:326]呼叫失败cuInit:未知错误(303)2013-08-29 18:34:46.634015: I tensorflow/stream_executor/cuda/cuda_diagnostics。答:169]检索主机CUDA诊断信息:chowdhury - joy - ltp2012-08-29 18:34:46.634852: I tensorflow/stream_executor/cuda/cuda_diagnostics。答:176]主机名:CHOWDHURY-JOY-LPTP20121-08-29 18:34:46.641932: I tensorflow/core/platform/cpu_feature_guard。[j] [c] .北京:北京交通大学使用oneAPI深度神经网络库(oneDNN)对二进制进行优化。在性能关键的情况下使用以下CPU指令操作:AVX2要在其他操作中启用它们,请使用适当的编译器标志重新构建TensorFlow。20121-08-29 18:34:46.644266: I tensorflow/compiler/jit/xla_gpu_device。[00:99]没有创建XLA

这些警告发生在CuDNN.dll未找到(用于在GPU上运行)

您可以使用下面的代码超越这些警告:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

请查看此类似已解决的问题以获取更多详细信息。

最新更新