How to accelerate the speed of these two operators if the number of cpu cores is limited?
same code with same GPU but different cpu cores, I get different time cost:
when cpu cores=256, transform.totensor() and normalize() cost about 0.03s
but when cpu cores = 12 , The time consumed by transform.CenterCrop() and Resize() has not increased significantly。transform.totensor() and normalize() cost about 0.3s: The time taken increased by 10 times
The simplified code is as follows,
from PIL import Image
import torchvision.transforms as transforms
import numpy as np
from time import time
import os
import torch
# 读取 PIL 图片
pil_image = Image.open('templates/trucks/double_deck_truck_1.jpg')
# 定义转换操作
transform = transforms.Compose([
transforms.Resize((224, 224), interpolation=Image.BILINEAR),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
tensor_image = transform(pil_image)
Can anyone help me improve the processing speed when the CPU cores are limited? Thanks a lot.