RuntimeError: CUDA error: misaligned address CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1
最近在运行stable diffusion的时候,出现了这个问题。查看stable diffusion的issue发现没人遇到和我一样的问题,记录一下解决过程:
首先按照提示,进行debug:在程序的运行开始之前加上环境变量
import os
os.environ['CUDA_LAUNCH_BLOCKING']='1'
可以很快的发现有一个usewarning
UserWarning:
NVIDIA GeForce RTX 3090 with CUDA capability sm_86 is not compatible with the current PyTorch installation.
The current PyTorch install supports CUDA capabilities sm_37 sm_50 sm_60 sm_70.
If you want to use the NVIDIA GeForce RTX 3090 GPU with PyTorch, please check the instructions at https://pytorch.org/get-started/locally/
warnings.warn(incompatible_device_warn.format(device_name, capability, " ".join(arch_list), device_name))
这一段的提示是我的显卡是3090的,算力与我安装的pytorch版本不对应。我查看了一下我的pytorch版本:
import torch
print(torch.__version__)
###
'1.12.1+cu102'
可以看到我的pytorch版本是1.12.1的版本,版本太低了,因此需要升级pytorch的版本。升级pytorch的版本很多,可以直接从官网上下载最新的版本。