Skip to content

ResNet model takes forever to load in Metalhead 0.8 compared to 0.7. #247

@christiangnrd

Description

@christiangnrd

I've been looking to change over some code from using Metalhead 0.7 to 0.8 and I've noticed that loading the pretrained ResNet in 0.8 takes an abnormally long time to load.

The pretrained weights are loaded for each test. Without pretrained weights there is still a 3x slowdown, but it is MUCH worse when loading the weights.

Metalhead 0.7.4:

julia> using Metalhead

julia> @time model = ResNet(152, pretrain=false).layers[1];
  1.234614 seconds (1.47 M allocations: 556.321 MiB, 4.13% gc time)
julia> using Metalhead

julia> @time model = ResNet(152, pretrain=true).layers[1];
  4.520097 seconds (6.87 M allocations: 1.314 GiB, 2.11% gc time)

Metalhead 0.8.1:

julia> using Metalhead

julia> @time model = ResNet(152, pretrain=false).layers[1];
  4.833957 seconds (5.21 M allocations: 801.770 MiB, 1.94% gc time)
julia> using Metalhead

julia> @time model = ResNet(152, pretrain=true).layers[1];
161.141156 seconds (16.60 M allocations: 1.897 GiB, 0.14% gc time)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions