Stable Diffusion (Diffusers) / DiffusersでcontrolnetをCPUだけで動かす

GPU固定でプログラムをされているとCPUでは動きません

/usr/local/lib/python3.10/dist-packages/torch/cuda/init.py in _lazy_init()
245 if 'CUDA_MODULE_LOADING’ not in os.environ:
246 os.environ['CUDA_MODULE_LOADING’] = 'LAZY’
–> 247 torch._C._cuda_init()
RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver

pipeline_controlnet.py

/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/controlnet/pipeline_controlnet.py

次のコードに命令を追加して書き換えます


        device = torch.device(f"cuda:{gpu_id}")
        device = "cuda" if torch.cuda.is_available() else "cpu"

stable-diffusion

Posted by eightban