keras-applications
keras-applications copied to clipboard
High CPU utilization upon model.predict()
I have performed transfer learning using MobileNet and have exported the model to be used in a different applications for prediction.
img = Image.open(path)
img = img.resize((224,224))
img = np.array(img, dtype="float32")
x = img.reshape((1,) + img.shape) # reshape image to 1x3x224x224
x = preprocess_input(x)
output = model.predict(x)
The code runs fine, but upon model.predict, my CPU utilization spikes up to 98%.
I'm currently using keras 2.2.4 within an Anaconda environment
@Terizian, Could you describe the details such as statistics of 100 runs? The analysis for CPU and GPU utilizations needs to be more sophisticated.
@Terizian, Could you describe the details such as statistics of 100 runs? The analysis for CPU and GPU utilizations needs to be more sophisticated.
@taehoonlee Thanks for your response. I would provide this information, but the system is offline so it's hard to pull out.
I have a script that fetches images from a database, processes each image, then runs it through the model for prediction. I commented the code, then removed the comments section by section, while monitoring CPU utilization. It seems that it spikes only when I uncomment model.predict()
. Does it use all the available system resources by default?
I wanted to perform multiple predictions at once and I'm finding it impossible to do so when running just one instance does that to CPU utilization.