RuntimeError: CLAMP: [enforce fail at inline_container.cc:208] . file not found: archive/constants.p

需要加载CLIP预训练模型 RN50.pt
但是一直报错,可能是我环境中用的torch和torchvision与RN50.py用的版本不一样
在github上找到CLIP用的版本:


```python
conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0
于是卸载当前环境的torch和torchvision

```python
pip uninstall torch
pip uninstall torchvision

安装和CLIP模型相同的版本:

pip install torch==1.7.1+cu110 torchvision==0.8.2+cu110 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html

然后发现还是不行,于是在网上搜索一番,发现本项目中初始化CLIP模型的时候用的是torch.jit.load():

def init_weights(self, pretrained=None):
        if isinstance(pretrained, str):
            checkpoint = torch.jit.load(pretrained, map_location='cpu').float().state_dict()

改为:

checkpoint = torch.load(pretrained, map_location='cpu').float().state_dict()

ok,解决了,虽然继续报新的bug…

AttributeError: CLAMP: ‘collections.OrderedDict’ object has no attribute ‘float’
改成:

checkpoint = torch.load(pretrained, map_location='cpu')

终于跑起来了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值