复现论文-报错记录dream-ood

复现论文Dream the Impossible: Outlier Imagination with Diffusion Models
过程中出现的问题记录
服务器:NIVIDA2080ti
github:

1.pytorch使用出现"RuntimeError: An attempt has been made to start a new process before the..."(应该用cpu才会出现)

具体报错:

RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase. This probably means that you are not using fork to start your child processes and you have forgotten to use the proper idiom in the main module: if __name__ == '__main__': freeze_support() ... The "freeze_support()" line can be omitted if the program is not going to be frozen to produce an executable.

我之后用的服务器就又都修改回来了。


2.Pytorch 如何修改Torch Hub模型下载路径

Torch Hub模型下载的默认路径是~/.cache/torch/hub/checkpoints/。

从github上下载国内下不下来,会报错:RuntimeError: unexpected EOF, expected 183852 more bytes. The file might be corrupted.

解答:

首先将模型自己下载到本地

然后设置环境变量

通过设置TORCH_HOME环境变量来指定新的模型下载路径。在终端中运行以下命令来设置环境变量:

export TORCH_HOME=/path/to/new/download/directory

请将/path/to/new/download/directory替换为您想要存储Torch Hub模型的新路径。

本人修改到:export TORCH_HOME=/opt/data/private


3.huggingface镜像下载

有很多模型要从huggingface上下载,但国内无法访问。也是下载到本地,然后传到相应位置

官网: HF-Mirror   网站域名 hf-mirror.com,用于镜像 huggingface.co 域名 

HF-Mirror搜索,并在模型主页的Files and Version中下载文件


4.安装xformers指定版本

pip3 install xformers==0.0.13 

原作者说的版本为0.0.13

但是在之后的运行过程中发现还是会报错。

后来原作者也说了,要根据自己的cuda和pytorch版本安装相应的xformers版本。

网上都可以查到对应信息。

本人:NVIDIA-SMI 515.76       Driver Version: 515.76       CUDA Version: 11.7


5.Can't load tokenizer for 'openai/clip-vit-large-patch14'.

If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.

解答:clip-vit-large-patch14 国内已经不能访问了
需要手动创建openai 目录并把 下载后解压的资源拖入到openai/clip-vit-large-patch14目录下面

下载地址:

openai/clip-vit-large-patch14 at main


6、CUDA out of memory

要么增加显卡,要么修改参数

原作者生成10K张,

我的解决方法:

1、减小batch_size:这里面减小了n_smple。

2、检查是否显存不足

watch -n 0.5 nvidia-smi

查看显存占用

指定使用的GPU

os.environ['CUDA_VISIBLE_DEVICES'] = "0, 1, 3"
device = torch.device("cuda:0" if torch.cuda.is_available() and not args.no_cuda else "cpu")  # cuda 指定使用GPU设备
model = torch.nn.DataParallel(model, device_ids=[0, 1, 3])  # 指定多GPU并行处理时使用的设备编号

这个方法会发生报错:AttributeError: 'DataParallel' object has no attribute 'XXXX' 

解决方法:将self.model都变成self.model.module

 或者

在python前面添加指定的GPU编号


CUDA_VISIBLE_DEVICES=1 python script1.py

7.import cv2 报错libSM.so.6: cannot open shared object file: No such file or directory

执行完以下三句就可以正常import cv2啦

apt-get install libsm6
apt-get install libxrender1
apt-get install libxext-dev

如果出现: 

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libsm6

先执行:在root下不用sudo

apt-get update

 然后再执行上面三个命令。


8、ModuleNotFoundError: No module named 'faiss'

conda install -c pytorch faiss-gpu

9、Need to compile C++ extensions to get sparse attention suport. Please run python setup.py build develop

要根据自己的pytorch版本安装xformers.

facebookresearch/xformers at v0.0.17

 找tag,tag下面写了对应关系。

一定要找对应版本的。

注: 不知道这个有没有影响

我没换xformers版本之前,还更改了代码中的attention.py文件。

 https://github.com/deeplearning-wisc/dream-ood/blob/main/ldm/modules/attention.py)

文件变为: 

 stablediffusion/ldm/modules/attention.py at main · Stability-AI/stablediffusion · GitHub

其中要把源文件中的class LinearAttention(nn.Module)加到更换后的文件中就可以了


10、module ‘torch‘ has no attribute ‘_six‘

torch 2.0版本以后中没有 ‘_six.py’ 文件,所以运行模型报错

解答:

将version.py中的代码修改如下

if isinstance(root, torch._six.string_classes):

修改为:

if isinstance(root, str):


11、测试数据集下载梯子

测试数据集在dropbox,需要梯子

我用的翻墙:

SSRDOG 导航站


13、-bash: screen: command not found

命令:apt-get install screen

用screen防止中途断网之类的问题。深刻教训😭😭😭😭😭😭


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值