xuebinqin / U-2-Net

The code for our newly accepted paper in Pattern Recognition 2020: "U^2-Net: Going Deeper with Nested U-Structure for Salient Object Detection."
Apache License 2.0
8.61k stars 1.48k forks source link

gpu cpu inference time is about the same? #283

Open dbAIStudio opened 2 years ago

dbAIStudio commented 2 years ago

I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this?

xuebinqin commented 2 years ago
  1. make sure you input image is 320x320
  2. make sure you are not taking the image loading and resizing time into consideration
  3. run the inference several times and get the average, usually the deep learning frameworks like pytorch and tensorflow need to initialize the computation when feeding the first image, so the time costs for the first fed image usually takes much more time.
  4. make sure your code is running exactly on GPU not CPU.

On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.***> wrote:

I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this?

— Reply to this email directly, view it on GitHub https://github.com/xuebinqin/U-2-Net/issues/283, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/

dbAIStudio commented 2 years ago

1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 我把初始化模型放到了前面,我想要单张图像进行推理,代码中 if torch.cuda.is_available(): 是进入的,确认时gpu版本的torch 我在下面这段代码中加的时间,dataloader 比较耗时并且d1,d2,d3,d4,d5,d6,d7= net(inputs_test)耗时700ms

--------- 2. dataloader ---------

1. dataloader

test_salobj_dataset = SalObjDataset(img_name_list = img_name_list, lbl_name_list = [], transform=transforms.Compose([RescaleT(320), ToTensorLab(flag=0)]) ) test_salobj_dataloader = DataLoader(test_salobj_dataset, batch_size=1, shuffle=False, num_workers=1)

--------- 4. inference for each image ---------

for i_test, data_test in enumerate(test_salobj_dataloader):

    print("inferencing:",img_name_list[i_test].split(os.sep)[-1])

    inputs_test = data_test['image']
    inputs_test = inputs_test.type(torch.FloatTensor)

    if torch.cuda.is_available():
        inputs_test = Variable(inputs_test.cuda())
    else:
        inputs_test = Variable(inputs_test)

    d1,d2,d3,d4,d5,d6,d7= net(inputs_test)
dbAIStudio commented 2 years ago

1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/

首先感谢您的回复,我上面的情况拿cpu的torch和gpu的torch测试的耗时基本都差不多,但是我看其他人测试的帧率都不会是我这个单张图1s多,因为我想单张图进行推理,测试目录下只放了一张图进行的,我想知道是什么原因,我如果就单张图做模型推理代码应该如何做调整

xuebinqin commented 2 years ago

try to just count the time of this line: d1,d2,d3,d4,d5,d6,d7= net(inputs_test)

On Sat, Jan 15, 2022 at 3:54 PM dbAIStudio @.***> wrote:

1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 … <#m-6488284796971335845> On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283 https://github.com/xuebinqin/U-2-Net/issues/283>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 我把初始化模型放到了前面,我想要单张图像进行推理,代码中 if torch.cuda.is_available(): 是进入的,确认时gpu版本的torch 我在下面这段代码中加的时间,dataloader 比较耗时并且d1,d2,d3,d4,d5,d6,d7= net(inputs_test)耗时700ms

--------- 2. dataloader ---------

1. dataloader

test_salobj_dataset = SalObjDataset(img_name_list = img_name_list,

                                lbl_name_list = [],

                                transform=transforms.Compose([RescaleT(320),

                                                              ToTensorLab(flag=0)])

                                )

test_salobj_dataloader = DataLoader(test_salobj_dataset,

                                batch_size=1,

                                shuffle=False,

                                num_workers=1)

--------- 4. inference for each image ---------

for i_test, data_test in enumerate(test_salobj_dataloader):

print("inferencing:",img_name_list[i_test].split(os.sep)[-1])

inputs_test = data_test['image']

inputs_test = inputs_test.type(torch.FloatTensor)

if torch.cuda.is_available():

    inputs_test = Variable(inputs_test.cuda())

else:

    inputs_test = Variable(inputs_test)

d1,d2,d3,d4,d5,d6,d7= net(inputs_test)

— Reply to this email directly, view it on GitHub https://github.com/xuebinqin/U-2-Net/issues/283#issuecomment-1013669125, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

-- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/

dbAIStudio commented 2 years ago

try to just count the time of this line: d1,d2,d3,d4,d5,d6,d7= net(inputstest) On Sat, Jan 15, 2022 at 3:54 PM dbAIStudio @.***> wrote: 1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 … <#m-6488284796971335845_> On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283 <#283>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 我把初始化模型放到了前面,我想要单张图像进行推理,代码中 if torch.cuda.is_available(): 是进入的,确认时gpu版本的torch 我在下面这段代码中加的时间,dataloader 比较耗时并且d1,d2,d3,d4,d5,d6,d7= net(inputs_test)耗时700ms --------- 2. dataloader --------- #1. dataloader test_salobj_dataset = SalObjDataset(img_name_list = img_name_list, lbl_name_list = [], transform=transforms.Compose([RescaleT(320), ToTensorLab(flag=0)]) ) test_salobj_dataloader = DataLoader(test_salobj_dataset, batch_size=1, shuffle=False, num_workers=1) # --------- 4. inference for each image --------- for i_test, data_test in enumerate(test_salobj_dataloader): print("inferencing:",img_name_list[i_test].split(os.sep)[-1]) inputs_test = data_test['image'] inputs_test = inputs_test.type(torch.FloatTensor) if torch.cuda.is_available(): inputs_test = Variable(inputs_test.cuda()) else: inputs_test = Variable(inputs_test) d1,d2,d3,d4,d5,d6,d7= net(inputs_test) — Reply to this email directly, view it on GitHub <#283 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 耗时700ms左右,cpu和gpu时间没有明显差别,我显卡是1070

xuebinqin commented 2 years ago

you may have to check if you are always running on CPU

On Sat, Jan 15, 2022 at 4:05 PM dbAIStudio @.***> wrote:

try to just count the time of this line: d1,d2,d3,d4,d5,d6,d7= net(inputstest) … <#m-80561680867756588> On Sat, Jan 15, 2022 at 3:54 PM dbAIStudio @.*> wrote: 1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 … <#m-6488284796971335845_> On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283 https://github.com/xuebinqin/U-2-Net/issues/283 <#283 https://github.com/xuebinqin/U-2-Net/issues/283>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ https://xuebinqin.github.io/ 我把初始化模型放到了前面,我想要单张图像进行推理,代码中 if torch.cuda.is_available(): 是进入的,确认时gpu版本的torch 我在下面这段代码中加的时间,dataloader 比较耗时并且d1,d2,d3,d4,d5,d6,d7= net(inputs_test)耗时700ms --------- 2. dataloader --------- #1 https://github.com/xuebinqin/U-2-Net/issues/1. dataloader test_salobj_dataset = SalObjDataset(img_name_list = img_name_list, lbl_name_list = [], transform=transforms.Compose([RescaleT(320), ToTensorLab(flag=0)]) ) test_salobj_dataloader = DataLoader(test_salobj_dataset, batch_size=1, shuffle=False, num_workers=1)

--------- 4. inference for each image --------- for i_test, data_test in

enumerate(test_salobj_dataloader): print("inferencing:",img_name_list[i_test].split(os.sep)[-1]) inputs_test = data_test['image'] inputs_test = inputs_test.type(torch.FloatTensor) if torch.cuda.is_available(): inputs_test = Variable(inputs_test.cuda()) else: inputs_test = Variable(inputs_test) d1,d2,d3,d4,d5,d6,d7= net(inputs_test) — Reply to this email directly, view it on GitHub <#283 (comment) https://github.com/xuebinqin/U-2-Net/issues/283#issuecomment-1013669125>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 耗时700ms左右,cpu和gpu时间没有明显差别,我显卡是1070

— Reply to this email directly, view it on GitHub https://github.com/xuebinqin/U-2-Net/issues/283#issuecomment-1013670791, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORI4U6KSEOYX3QLCJALUWFPJFANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

-- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/

dbAIStudio commented 2 years ago

you may have to check if you are always running on CPU On Sat, Jan 15, 2022 at 4:05 PM dbAIStudio @.> wrote: try to just count the time of this line: d1,d2,d3,d4,d5,d6,d7= net(inputstest) … <#m-80561680867756588_> On Sat, Jan 15, 2022 at 3:54 PM dbAIStudio @.> wrote: 1.确保您输入的图像是320x320 2.确保您没有考虑图像加载和调整大小的时间 3.多次运行推理并获得平均值,通常像pytorch和tensorflow这样的深度学习框架需要初始化馈送第一张图像时的计算,因此第一张馈送图像的时间成本通常需要更多时间。4. 确保您的代码完全在 GPU 而不是 CPU 上运行。 … <#m-6488284796971335845> On Sat, Jan 15, 2022 at 3:21 PM dbAIStudio @.> wrote: I want to do a single image inference to get the result. When num_workers=1, it takes more than 5s on the gpu. I changed it to num_workers=0. The gpu takes more than 1s, and I tested the cpu gpu time. There seems to be no difference, when my torch 1.8, what is the reason for this? — Reply to this email directly, view it on GitHub <#283 <#283> <#283 <#283>>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORMAUI7XZCH7MT3KAWDUWFKDXANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ https://xuebinqin.github.io/ 我把初始化模型放到了前面,我想要单张图像进行推理,代码中 if torch.cuda.is_available(): 是进入的,确认时gpu版本的torch 我在下面这段代码中加的时间,dataloader 比较耗时并且d1,d2,d3,d4,d5,d6,d7= net(inputs_test)耗时700ms --------- 2. dataloader --------- #1 <#1>. dataloader test_salobj_dataset = SalObjDataset(img_name_list = img_name_list, lbl_name_list = [], transform=transforms.Compose([RescaleT(320), ToTensorLab(flag=0)]) ) test_salobj_dataloader = DataLoader(test_salobj_dataset, batch_size=1, shuffle=False, num_workers=1) # --------- 4. inference for each image --------- for i_test, data_test in enumerate(test_salobj_dataloader): print("inferencing:",img_name_list[i_test].split(os.sep)[-1]) inputs_test = data_test['image'] inputs_test = inputs_test.type(torch.FloatTensor) if torch.cuda.is_available(): inputs_test = Variable(inputs_test.cuda()) else: inputs_test = Variable(inputs_test) d1,d2,d3,d4,d5,d6,d7= net(inputs_test) — Reply to this email directly, view it on GitHub <#283 (comment) <#283 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA https://github.com/notifications/unsubscribe-auth/ADSGORPIONXHZ6U22RA3MY3UWFN77ANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.**> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/ 耗时700ms左右,cpu和gpu时间没有明显差别,我显卡是1070 — Reply to this email directly, view it on GitHub <#283 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSGORI4U6KSEOYX3QLCJALUWFPJFANCNFSM5MA4CPEA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.> -- Xuebin Qin PhD Department of Computing Science University of Alberta, Edmonton, AB, Canada Homepage: https://xuebinqin.github.io/

我一直都在cpu上运行,那一行不管gpu还是cpu都是700ms左右, 但if torch.cuda.is_available():都是True,我运行中报这个警告, d:\workspace\zs\python-3.8.5-embed-amd64\lib\site-packages\torch\nn\functional.py:3328: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.") d:\workspace\zs\python-3.8.5-embed-amd64\lib\site-packages\torch\nn\functional.py:3454: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. warnings.warn( d:\workspace\zs\python-3.8.5-embed-amd64\lib\site-packages\torch\nn\functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")