Automate 1111 image generators and how to deploying it on AWS EC2 instance and it configuration for production.
Have you ever wonder where these beautiful AI images come from. That’s what I was thinking when my elder brother Hassan Revel comes to me, one of the best Cloud Engineer (Just Kidding) and said hey can we deploy automate1111 on AWS EC2 cause I really need it. That when I introduced to automate1111 and things make sense to me where those AI anime girls images comes from.
Anyways about deploying Automate to EC2, it’s really simple and straight forward. We need to open some port and make adjust in automate config files. Pretty simple isn't?
Note:
I am not going to step up automate on instance for you. Gonna have to do it by yourself, Just install and configure it as you do it on your computer. Don’t judge me on this I know I am lazy person.
1: Instance type g4dn.xlarge
I believe this instance is great for anyone kind of AI and Machine learning work. My elder brother use this all the time and he has a great experience using it and nice things to say about it, "What is wong with this instance. This is bold sh*t." said by Hassan Revel . Anyways Please use this instance for this project because it's super fast and very reliable. You can get up 60% on it if you request spot Instance.
2: Instance Configuration
Please completing installing your automate on it as you do in your device. Now we gonna need to do some adjust on system and projects file. I have look into the docs of automate1111 and I believe they did a great job setting it up for productions.
Automate configuration:
Now run the automate as you normally do by typing
If thing are things correctly then you are good to follow my lead.
See if the automate is running run on host and port 0.0.0.0:7862
Instance configuration
Now we need to tell ubuntu that it keep the automate running on closing ssh or on server restart
Description=Automatic1111
After=network.target
[Service]
Type=simple
ExecStart=/home/ubuntu/stable-diffusion-webui/webui.sh
Restart=always
User=ubuntu
[Install]
WantedBy=multi-user.target
Now it's time to see if your efforts are worth the trouble or not!
If the automate is in running state after configuring the files. Then we successed if not then I am afraid you gonna have to follow things again. Getting error at this stage is normal. I made this blogs after solving a lones of error, so it's normal if you get stuck in error it helps us to keep learning.
3: AWS configuration
For automate the AWSconfiguration kinda go different. Now you might say this is just like web page all I have to do is open port on 80 and 443 and It would work. At least that is what I though to myself but no. Follow through the below step and It would work like a charm. Trust me!
Security Group setting:
领英推荐
Now at this moment things are working great but if one if those rocket must be pointer guys then follow the below configuration to connect it to Route 53 for https or domain name.
Load balance configuration:
Trust me! this part may seem complicate but if you’re developer then this nothing for you or if not then just follow along. Good Luck!
Here people might try to have TCP or change the port. Trust me you don’t have to change anything for it to work, just configure it normally.
Now please don’t thing about create a Network load balance just create a Application Load balance. Don’t judge me on this I know it’s possible with NLB but ALB also get the job done and it's cost efficient and more reliable in this regard.
This will redirect http traffic to https
Woow it worked:
Summary:
This is all there is to deploying the automate1111 to AWS. Now we could have made things much more secure and fast but that would require a lot of unnecessary steps. I made this blogs just to get the project on running site. Feel free to contact me if you wanna attach nginx or apache to it, I hope we would work together to improve your work.