How to accelerate transform.toTensor() and transform.normlize() with limited cpu cores?

wulongjian: <p>How to accelerate the speed of these two operators if the number of cpu cores is limited?<br>
same code with <strong>same GPU</strong> but <strong>different cpu cores</strong>, I get different time cost:<br>
when <strong>cpu cores=256</strong>, transform.totensor() and normalize() cost about 0.03s<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/a/aa6bd2bca85bbaba340d65b65ea2877203e6af6f.png" data-download-href="https://discuss.pytorch.org/uploads/default/aa6bd2bca85bbaba340d65b65ea2877203e6af6f" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/a/aa6bd2bca85bbaba340d65b65ea2877203e6af6f_2_690x206.png" alt="image" data-base62-sha1="ojCbaipj20h5lmQkclTOssA1UED" width="690" height="206" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/a/aa6bd2bca85bbaba340d65b65ea2877203e6af6f_2_690x206.png, https://discuss.pytorch.org/uploads/default/optimized/3X/a/a/aa6bd2bca85bbaba340d65b65ea2877203e6af6f_2_1035x309.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/a/aa6bd2bca85bbaba340d65b65ea2877203e6af6f.png 2x" data-dominant-color="262222"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1300×389 57.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
but when <strong>cpu cores = 12 ，</strong> 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<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/8/4/84cf607dca25e530473f78d8e9e68af7832c01d8.png" data-download-href="https://discuss.pytorch.org/uploads/default/84cf607dca25e530473f78d8e9e68af7832c01d8" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/8/4/84cf607dca25e530473f78d8e9e68af7832c01d8_2_690x205.png" alt="image" data-base62-sha1="iWTkp3JTumd5A6V9UvffJ4pW7rO" width="690" height="205" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/8/4/84cf607dca25e530473f78d8e9e68af7832c01d8_2_690x205.png, https://discuss.pytorch.org/uploads/default/optimized/3X/8/4/84cf607dca25e530473f78d8e9e68af7832c01d8_2_1035x307.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/8/4/84cf607dca25e530473f78d8e9e68af7832c01d8.png 2x" data-dominant-color="2F2828"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">1304×389 70.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
The simplified code is as follows，</p>
<pre><code class="lang-auto">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)
</code></pre>
<p>Can anyone help me improve the processing speed when the CPU cores are limited? Thanks a lot.</p>