避坑实操:5070TI+Stable Diffusion sm_120 报错修复
·
检查CUDA与显卡驱动版本兼容性
NVIDIA GeForce 5070TI需搭配CUDA 12.x及更高版本驱动。运行以下命令验证驱动和CUDA版本:
nvidia-smi # 查看驱动版本(需≥525.60.11)
nvcc --version # 查看CUDA Toolkit版本(需≥12.0)
若版本不匹配,需升级驱动或降级CUDA Toolkit至兼容版本。
修改Stable Diffusion启动参数
在启动命令中显式指定--precision full --no-half,避免半精度浮点运算导致的sm_120兼容性问题:
python launch.py --precision full --no-half --skip-torch-cuda-test
调整Torch与CUDA环境
5070TI的Ampere架构需PyTorch 2.0+和CUDA 11.8/12.x组合。创建虚拟环境并安装指定版本:
conda create -n sd_env python=3.10
conda activate sd_env
pip install torch==2.0.1+cu118 torchvision==0.15.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
修改源码绕过架构检查
定位Stable Diffusion的launch.py文件,找到check_cuda相关代码段,注释或修改以下行:
# 原始代码可能包含类似检查
# assert torch.cuda.get_device_capability(0) >= (7, 0), "Unsupported GPU"
替换为:
torch.backends.cudnn.benchmark = True # 启用加速
强制使用XFORMERS优化
在配置文件中添加enable_xformers=True,或启动时追加参数:
python launch.py --xformers
若提示xformers不兼容,需从源码编译:
pip install -v -U git+https://github.com/facebookresearch/xformers.git@main#egg=xformers
验证修复结果
运行测试脚本确认GPU可用性:
import torch
print(torch.cuda.is_available()) # 应输出True
print(torch.rand(10,10).cuda()) # 应无报错
若仍报错,尝试禁用硬件加速解码:
export CUDA_VISIBLE_DEVICES=0
export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128
附:常见错误码对应措施
CUDA error 700: 升级驱动至最新Game Ready版本sm_120 not supported: 使用--no-half-vae参数跳过VAE模型半精度DLL load failed: 重装Microsoft Visual C++ 2015-2022 Redistributable
更多推荐


所有评论(0)