We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b95e335 commit fcdb200Copy full SHA for fcdb200
timm/models/_builder.py
@@ -413,7 +413,8 @@ def build_model_with_cfg(
413
feature_cfg['feature_cls'] = kwargs.pop('feature_cls')
414
415
# Instantiate the model
416
- with torch.device("meta") if pretrained else nullcontext():
+ meta_device = torch.device("meta")
417
+ with meta_device if hasattr(meta_device, "__enter__") and pretrained else nullcontext():
418
if model_cfg is None:
419
model = model_cls(**kwargs)
420
else:
0 commit comments