Swin Transformer进行语义分割,Ubuntu系统,解决RuntimeError: one of the variables needed for gradient computation

1、问题描述

        最近在用Swin Transformer做语义分割的任务,基本的配置环境参考的是GitHub的基础安装步骤,主要的是环境的配置问题,mmcv的配置要求,不允许高于1.4.0,所以,在train.py文件进行训练运行的时候,报错:RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [2, 512, 32, 32]], which is output 0 of ReluBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

2、解决方案与配置单

        1、python=3.8
        2、conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c         pytorch -c conda-forge
        3、pip install mmcv-full==1.4.0 -f         https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html

3、总结

        就是环境问题,这是我浪费了一天的时间,总结出来的配置单,大家有问题也可以私信我

安装Swin-Transformer-Semantic-Segmentation需要按照以下步骤进行操作。首先,确保您的系统配置符合要求,即使用Ubuntu 18.04操作系统。然后,您需要安装MMCV,它需要Python 3.6或更高版本。请注意,在Windows环境下安装时,不要使用pip直接安装,而是需要使用源码安装。此外,编译MMCV时,请使用PowerShell而不是CMD。对于CUDA和PyTorch的版本要求,建议使用CUDA 10.2和PyTorch 1.8,这样可以确保配置成功。其他版本可能会遇到各种问题。最后,您还需要安装Visual Studio 2019 Community版本,并将其路径添加到系统环境变量中。具体路径为"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC*14.29.30037*\bin\Hostx86\x64"。请注意,根据您的实际安装路径,上述路径可能会有所不同。完成这些步骤后,您就可以开始使用Swin-Transformer-Semantic-Segmentation训练自己的数据了。\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* *2* *3* [使用Swin-Transformer-Semantic-Segmentation训练自己的数据(语义分割,自己做数据)](https://blog.csdn.net/weixin_38353277/article/details/123117391)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值