FluxML / Metalhead.jl

Computer vision models for Flux
https://fluxml.ai/Metalhead.jl
Other
328 stars 65 forks source link

Saving large models with JLD2 fails #252

Closed oluwandabira closed 1 year ago

oluwandabira commented 1 year ago

Saving model with JDL2 fails if the model is large enough (at least I think that's what's happening)

using Flux
using Metalhead
using JLD2

model = ResNet(152)
model_state = Flux.state(model)
jldsave("model_state.jld2"; model_state)

The above will fails with:

InexactError(:trunc, UInt16, 66886)

Also fails for EfficientNet(:b8)

Pkg.status():

[587475ba] Flux v0.14.6
[033835bb] JLD2 v0.4.35
[dbeba491] Metalhead v0.8.3
darsnack commented 1 year ago

Can you post a full stack trace instead of the final error?

oluwandabira commented 1 year ago

https://gist.github.com/oluwandabira/aad1059b2410f1ad13d5232a6d1b071c

darsnack commented 1 year ago

I assume that ResNet(18) works? It's probably this issue. In which case that's a JLD2 issue, and there isn't much we can do here.

oluwandabira commented 1 year ago

All the other ResNets work. It does appear to be a JLD2 issue so I've opened an issue there.