timothybrooks / instruct-pix2pix

Other
6.1k stars 527 forks source link

Force program to run on CPU (AMD x86_64) #107

Closed TheSystemGuy1337 closed 3 months ago

TheSystemGuy1337 commented 1 year ago

Here we go again. I have a system where I only have AMD Radeon Graphics, which has non existent compute support. Unfortunately this program ABSOLUTELY REQUIRES an Nvidia GPU or it will error out. I tried looking in the configs to see if I could force fallback CPU mode, but I couldn't find anything. I also tried editing edit_cli.py and replaced all references to CUDA with CPU. but that didn't do anything. Hugging Face is slow as all hell, Replicate is paid, and Imaginairy also requires an CUDA compliant GPU. So I am screwed. Is there any way to force CPU fallback mode? Other programs that use PyTorch do fall back on the CPU just fine, and I don't mind it taking 45 years to do one image.

umutyazgan commented 10 months ago

Hi, I was able to get this running on a device with AMD 7900 XTX. I don't know which AMD GPU you have available but maybe this will help you as well. I've mostly followed instructions here, with a few modifications: https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/9591 These instructions are for Stable Diffusion, but you can use the same environment for instruct-pix2pix as well.

I don't exactly remember what I have done differently, but I think I've used ROCm version 5.6 instead of 5.5_rc4. You may need to test around a bit and see what works best for you. Also, you will need to make sure that these environment variables set during this process persists:

export HIP_VISIBLE_DEVICES=0
export PYTORCH_ROCM_ARCH="gfx1100"
export CMAKE_PREFIX_PATH=/SD/stable-diffusion-webui/venv/

Or you may need to set them again each time the container is restarted.

Afterwards, you will need to install the dependencies of instruct-pix2pix. Unfortunately, we can't just use the provided conda environment for this. You can try to write a requirements.txt file from the dependencies listed in environment.txt and install it using pip. Or you can try to install packages manually one by one. In either case, I would recommend upgrading pip to the latest version beforehand, as it does a better job of handling dependency cycles/conflicts. Here is the list of packages (pip list) in my environment, as a reference:

https://gist.github.com/umutyazgan/d397a12fa21ee1a0b88d5f508b436517 Keep in mind that this is the full list of packages installed in this environment. You probably won't need to install all of this by hand, most are dependencies of other dependencies. But it can be useful as a reference on which versions of the packages are needed.

TheSystemGuy1337 commented 10 months ago

I don’t know either. All I know is it’s a generic Radeon iGPU

TheSystemGuy1337 commented 3 months ago

This issue is dead. It's time that humanity moved on.