mikeage / stable-diffusion-aws

27 stars 5 forks source link

Help!! #2

Closed mynumu closed 8 months ago

mynumu commented 1 year ago

Hello. Thanks for creating this. Not an issue. After several hours with gpt4 helping me i have finally got the instance running but I cannot connect. Any thoughts!! All looks fine in AWS Console.

ssh: connect to host 44.204.191.12 port 22: Resource temporarily unavailable

Ive waited 20 minutes. Connecting via SSH via WSL2 on windows.

This is the public IP as per the instance.

My AWS CLI is basic level..thanks!

mikeage commented 1 year ago

Hmmm, strange. I can't say I've had that happen. Have you tried PuTTY as well?

mynumu commented 1 year ago

ooh hello! ive terminated them and will recreate - wow thats a quick reply. I will then try putty - chatgpt told me to use WSL...:)

mikeage commented 1 year ago

WSL may work as well, but it can't hurt to try something else if it doesn't work :-)

I use a Mac, so I can't really say what you need for windows, but the only thing you should need to do it create keys for AWS, export them, and then copy / paste into a bash window (like the WSL2 terminal) to create...

mynumu commented 1 year ago

Hi ok thanks. Seem to have run into some confusion.

When I run the script it auto duplicates the keypairs on AWS again with the same name (I created a keypair manually via AWS console first so I could get a ppk file)

Does your script need to create the keypairs for any reason or can I comment the line out

# aws ec2 import-key-pair --key-name sams-sd-aws --public-key-material fileb://${PUBLIC_KEY_PATH} --tag-specifications 'ResourceType=key-pair,Tags=[{Key=creator,Value=stable-diffusion-aws}]'

There is a keyname reference later down the script also - shall I just leave this line and change the keypair name to mine? --key-name stable-diffusion-aws \

Let me know if theres a better way of reaching you than github

Thanks a lot

mikeage commented 1 year ago

You can also run the cleanup script, although if you have multiple keys with the same name, I don't know what it will do :-) . My assumption was that you probably had a key locally, and would just need to upload it to AWS. But you can comment it out if you'd like; just make sure to either give it the same name or, alternatively, update the key name in the create-instance command.

mynumu commented 1 year ago

ok. didnt see a clean up script. Im connected via SSH (putty) and the instance is up and running but localhost not connecting. No obvious issues I can see in AWS console so after many hours I am now at a loss. No errors on WSL/Putty or in AWS Dashboard but I cant connect to that SSH tunnel...maybe its a windows thing?

How do you check the service is up and running correctly?

Im giving up now for the day - it all looked quick and easy lol. Thanks for the CLI practice. No doubt its me...so not an issue at all

Thanks

mikeage commented 1 year ago

There are a bunch of code blocks in the file; the last one is a cleanup.

Look at the file /var/log/cloud-init-output.log to see if the installation finished successfully.

Run systemctl status invokeai to see if it's running properly.

Feel free to post the contents of the first file and the output of the second command if you'd like me to take a look

mikeage commented 1 year ago

Also note that you can either run invokeai or sdwebgui (a1111) but not both at the same time. By default, invokeai is started. See https://github.com/mikeage/stable-diffusion-aws/blob/dca36b09a51b90625adff2556fb1370ac6f093f2/setup.sh#L152C1-L159C3

That part is poorly documented. I'll fix it.

Edit: It actually is documented, I just forgot ;-)

The are two options for frontends; the first is the GUI at https://github.com/AUTOMATIC1111/stable-diffusion-webui, and the second is https://github.com/invoke-ai/InvokeAI. By default, both are installed, but only Invoke-AI is started. There is insufficient RAM to run both at the same time, as model loading + image generation will take up slightly more than 16GB of RAM. There are environment variables at the beginning of setup.sh which can be used to set which are installed and/or started. Systemd services are installed for both, and they can be started or stopped at runtime freely. The names are sdwebgui.service and invokeai.service.

mynumu commented 1 year ago

Hi thanks for taking the time to reply. I will try a again later from scratch and report back. Looking through the scripts I can’t see why it didn’t work. The instance was running without issue. I had set invokeai to false.

I’m guessing the SSH tunnel was the issue.

I really want to get this working..as it’s using spot instances. Out of interest why did you choose Debian over Ubuntu or a pre set ML model?

thanks

mikeage commented 1 year ago

I started using Debian many years ago... my first installation was 1.2 in 1996. When Ubuntu came out in 2004, I switched, as it gave a better set of usable defaults and setup than Debian did, while still offering the same command line (well, ncurses) installer and keeping me far away from the RH ecosystem, which I never liked. Sometime around 2018 or so I started to get very frustrated with Ubuntu's direction, and I went back to Debian, which was lighter and simpler but now fully functional.

mynumu commented 1 year ago

Hello. I finally have this working! yay! For any other windows users

  1. Run the EC2 Create Instance Code via WSL
  2. Create an SSH Tunnel on Putty and then connect to the EC2 instance
  3. Check the stable diffusion directory is there - and if its not started up manually run webui.sh

If you get stuck theres a more gui type install based on this code over here https://github.com/blekmus/aws-stable-diffusion. I had to run this one first to try and work out why I had an issue

Thanks Mike - I'm going to ask a few questions in my next reply.

mynumu commented 1 year ago

Questions/Challenges

  1. How can I get the setup.sh script to run at launch time from the AWS console? I have now created a launch template from this and added the setup.sh into user data BUT when I ran this manually it didnt seem to start stable diffusion. I had SD set to true and set the SD webgui to start in the create instance script export PUBLIC_KEY_PATH="$HOME/.ssh/id_rsa.pub" export INSTALL_AUTOMATIC1111="true" export INSTALL_INVOKEAI="false" export GUI_TO_START="sdwebgui"

  2. Where do you put the alarm stop script - can you add this to the createinstance script or does it go in setup.sh

  3. Whats the best approach to adding new models and extensions. I see you added them in setup.sh can you do this via the webgui and add extensions via github url??

  4. With the stop instance and stop requests. Are you saying that you can just stop the instance to come back to it later or do I also need to cancel the stop request (but dont want to terminate??)

This spot instance can be stopped and started like a regular instance. When stopped, the only cost is $0.40/month for the EBS volume. When removing all traces of this, note that terminating the instance will cause the SpotInstanceRequest to launch a new instances, but conversely, canceling the SpotInstanceRequest will not automatically terminated the instances that it spawned. As such, the SpotInstanceRequest must be canceled first, and then the instance explicitly terminated.

Thanks

Thanks a lot for this - cant wait to play with my own SD..

mikeage commented 1 year ago
  1. The setup.sh is user-data, and only runs when the VM is provisioned. When you say "start Stable Diffusion, I assume you mean Automatic1111 (the "sdwebgui"). The other GUI, Invoke-AI, is also stable diffusion. If you want to take an existing server and switch which service it starts, you can use standard systemctl commands, like systemctl stop invokeai, systemctl disable invokeai, systemctl enable sdwebgui, and systemctl start sdwebgui.
  2. Run it from the command line
  3. For sdwebgui, I think you just manually download checkpoint files. For invokeai, they have a downloader frontend.
  4. Don't cancel the spot request. Just stop the instance. Then you won't pay per hour, but you will pay for the EBS volume ($0.08/month/gb).