fix(model): resolve NFS flock error when loading pretrained timm weights#7
Open
fix(model): resolve NFS flock error when loading pretrained timm weights#7
Conversation
Use timm's cache_dir parameter to store pretrained weights locally in anomaly_match/pretrained_cache/, avoiding fcntl.flock failures on NFS filesystems. Bundle the default tf_efficientnet_lite0.in1k weights so the model loads without network access. Also skip redundant pretrained weight download for eval_model in FixMatch, since its weights are immediately overwritten by copying from train_model.
Add lfs: true to actions/checkout in CI so bundled pretrained weights are fetched. Replace **kwargs with explicit pretrained parameter in build_test_cnn to satisfy vulture dead code detection.
…s unavailable If the repo is cloned without git-lfs, the bundled pretrained cache contains LFS pointer files instead of actual weights. This adds a try/except fallback that downloads from HuggingFace in that case, with a warning suggesting git-lfs for offline use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cache_dirfor pretrained weight downloads: Pass timm's nativecache_dirparameter pointing toanomaly_match/pretrained_cache/, so HuggingFace Hub downloads and file locks happen on a local filesystem instead of NFS (which doesn't supportfcntl.flock).tf_efficientnet_lite0.in1kpretrained weights (~18 MB) with the repo, eliminating the need for network access when using the default model.pretrained=False.Fixes
OSError: [Errno 37] No locks availablewhen running on NFS filesystems.Context
Release 1.3.0 switched from
efficientnet_lite_pytorchtotimm, which useshuggingface_hubfor pretrained weight downloads.huggingface_hubusesfcntl.flock()for cache file locking, which fails on NFS filesystems that don't support POSIX file locks.Test plan
pretrained_cache/without network access