Teach you step by step how to make alchemy in cloud environment (deploy Stable Diffusion WebUI)

A few days ago, I wrote an article titled " Teaching you step-by-step on how to install the Stable Diffusion Autumn Leaves Integration Package on your local computer." Some students reported that the hardware requirements were too high and the graphics card was too expensive. Today I will share another method of cloud server alchemy, so that everyone can get started quickly. This cloud service does not require special network settings and can be connected to public network disks. It can be opened and used at any time. There are 3090 graphics cards and 4090 graphics cards, but I often use it. The one is A5000 graphics card. This article is not an advertisement, it only shares how to use it, don’t skip it.

Without further ado, let’s get started.

Register; Login

Registration method one

Register directly with your mobile phone number, open this link: www.autodl.com/register , it’s very simple so I won’t go into details.

Registration method two

Why are there two ways? During the test, I found that the verification code could not be sent out. The official said that there was something wrong with the verification code channel in the past two days, and sometimes it could not be sent out. I don’t know the specific reason, so let’s make an alternative.

On its login page, click the "Login with WeChat" button, scan with WeChat, and on the page opened by WeChat, click "Follow the official account". After the follow is successful, the AutoDL web page will automatically jump to ask for binding a mobile phone number. , it feels a bit strange that I can receive this verification code.

Open server

After successful registration, you can log in. After successful login, you will enter a management interface.

I heard that registered users would receive 10 yuan as a gift before, but that should be gone now. Now they will give you a 30-day alchemy membership, with some discounts on the unit price. Under normal circumstances, this discount requires a purchase of 500 yuan.

You can't open a server without money, so we need to add some money first.

top up

Move the mouse to the account name in the upper right corner of the management interface, and click "Recharge" in the pop-up window.

On the "Recharge" page, select "Other amounts". I recharged 5 yuan here. You can try to see if a smaller amount can turn on the phone. Paying less each time can also avoid the problem of forgetting to turn off the phone and getting charged money.

Just choose the payment method according to your own situation. Everyone should be familiar with the specific payment process, so I won’t demonstrate it here.

Rent an instance

Click "Console" in the upper right corner of the management interface.

Then click "Container Instance" in the left menu, and click "Rent a New Instance" on the page that opens.

On the "Create Instance" page, follow the sequence in the figure below.

  • Billing method: Just select "Pay-as-you-go" at the beginning of the experience.
  • Select area: Everyone recommends Inner Mongolia Area A. It is said that the network is relatively stable, and I have been using this area.
  • GPU model: A5000 1.18 per hour, the measured performance is also OK.
  • Number of GPUs: Choose 1 first, and then adjust according to the actual situation when you are more familiar with it.
  • Select the host: After selecting the GPU model and quantity, the available hosts will be listed here. Just choose one first.

There are some settings below.

Data disk: The free capacity is 50G. If it is not enough, you need to spend money to expand it. Generally, 50G is enough.

Mirror: First select "Community Mirror", then enter "yinghuoai" in the input box, a mirror will automatically pop up, just select it. This image was specially modified by me and will be continuously optimized and upgraded in the future. If you have any questions, just give me feedback. Of course, you can also use other images, but the steps to start SD WebUI may be different later. It is recommended to follow my steps first and then go on.

Finally click "Create Now".

start up

Now that the server instance has been started, we need 2 more steps to start Stable Diffusion WebUI.

local startup

Click "JupyterLab" in the "Shortcut Tools" column, as shown in the figure below:

The above operation will open a new page in the browser, the JupyterLab page. JupyterLab is a web application that can manage files, take notes, and run programs. Its functions are similar to VSCode.

Refer to the picture below and perform the following 2 steps:

  • Double-click "Launcher.ipynb" in the file manager on the left side of the page;
  • Click the Start button in the red box in the tab that opens on the right side of the page.

It will be a bit slow to download some models when starting for the first time, about 2-3 minutes. If you start it later, these download steps will be skipped, reaching the level of seconds.

When you see "Running on local URL" and "Model loaded in" in the picture below, it means the startup is successful.

Among them, "http://127.0.0.1:6006" is the access address of SD WebUI, but this address can only be accessed locally, and this cloud server is essentially just a container instance, with no desktop environment and no browser to use. . Of course this problem can be solved, please continue reading below.

Map to external network

Return to the container instance list, find the instance you just started, and click "Custom Service" in "Shortcut Tools", as shown in the figure below:

If you use a custom service for the first time, it will pop up an identity authentication prompt. Because AutoDL will map the local access address of SD WebUI to the external network, you may have heard about website registration. The external network address provided by AutoDL here uses the subdomain name of the domain name that AutoDL itself has registered. Therefore, AutoDL has to bear certain risks. It must be able to find people when something goes wrong, so identity authentication is required.

Just follow the prompts. Here I use personal authentication to demonstrate.

Enter your name and ID number. Note that an ID card can only be authenticated once on AutoDL. Multiple accounts must be authenticated with different ID numbers.

As long as the name and ID number match, the above authentication will be passed.

We click "Customize Service" again, and a warning will pop up, which means don't mess around. If you mess around, you will be punished. We are all good people, check the box to agree to the service agreement, and click "Access".

Then AutoDL will open a new tab in the browser, wait a moment, and the long-awaited SD WebUI page will be displayed.

Publish the picture

In order to facilitate everyone's painting, this mirror comes with two large models, one two-dimensional and one real vision.

Here we take the two-dimensional model as an example to demonstrate how to generate pictures.

1. Select the large model. Here is the default two-dimensional model AnythingV5.

2. For prompt words, let’s start with a simple one: a girl.

3. Reverse prompt words: EasyNegative, this is the code name of an embedded model, which combines some common reverse prompt words.

4. Click Generate.

5. Wait a moment and the image will be generated. You can click to enlarge and right-click to save.

More parameters and settings will be introduced in other articles later, please pay attention to the public account: Yinghuo AI (yinghuo6ai).

There are also some cloud server usage issues that need attention, please continue reading below.

Shut down/on

The server instance billing method introduced in this article is pay-as-you-go, billed once per hour. If you are not using it temporarily, remember to "turn off" it.

It is recommended to use "Mini Program Management Instance". When you can't remember clearly, just open the WeChat mini program and take a look to avoid wasting resources.

You may encounter the problem that the GPU cannot be allocated when you turn it off and on again. Because servers are shared, others may continue to use the computing resources of this server when you turn it off, and there may not be enough graphics cards when you turn it on again.

What to do at this time? Don't panic, there is a solution.

In the "More" section of the shutdown instance, click "Clone Instance".

In the pop-up prompt, there are two key pieces of information: 1. The data disk will not be automatically copied and needs to be processed manually. 2. There are three cloning opportunities per day.

The process after clicking "OK" is similar to creating a new server, except that there is no need to select a container image.

Then you can see the cloning progress in the container instance list:

After the new instance is started, if we still need data from the data disk, we need to click "Cross-instance copy data" in "More" of the original instance:

In the pop-up window, select "Target Instance", which is the new cloned instance; fill in "Source Instance Data Path": *, which represents all the files in the data disk.

Wait for the data copy to complete:

After the data is copied, you can use the new instance to continue working.

The method of starting SD WebUI has been introduced in the above steps and will not be repeated here.

storage

File management

JupyterLab comes with a file manager.

  • Click the folder icon in the upper right corner to open/close the file manager
  • The root directory of this file manager actually corresponds to the /root directory of the Linux system.
  • Double-clicking the file will open it in the editor on the right.

Operations on folders and files can be triggered by the right mouse button. You can see that there are many operations here, including new, copy, and delete, which is quite convenient.

For the interaction between the server and local files, we can achieve it through the upload and download of this file manager.

Public network disk

The AutoDL system disk is 30G and the data disk is 50G. If it exceeds the limit, you need to pay for data space. Although we have moved various models to the data disk, large models often weigh 2-5G, so the free data disk cannot hold several models, and we also have various plug-ins and generated files.

Consider the usage scenario. For models, we will not use all models at the same time, so we can put them in other places first, load them in when they are used, and move the ones that are not used very much to other places. This other place can be the user's local computer, but it will also take up a lot of space, so it is often a variety of network disks, such as Baidu Cloud Disk and Alibaba Cloud Disk. The "public network disk" supported by AutoDL does this.

Network disk authorization

In the instance list, find the instance for which data needs to be downloaded and click "AutoPanel":

Click "Public Network Disk" on the AutoPanel page. You need to set a password here.

After setting the password, you can authorize the network disk. Alibaba Cloud Disk does not have a speed limit, so it is recommended to use it first. Students who do not have Alibaba Cloud Disk need to register an account first, then install its APP on their mobile phones and scan the QR code for authorization.

After the authorization is passed, the current server can operate the cloud disk. However, after such authorization, only the current server can access the network disk, and other servers must be re-authorized if they want to access the network disk.

AutoDL provides a method to save authorization information to a separate location, and newly opened instances automatically load the authorization information.

The operation method is to click "Export Authorization" on the authorized server.

In the pop-up window, click "Copy Authorization Information".

Then open the AutoDL console, go to "Account" -> "Settings" -> "Public Network Disk", paste the authorization information copied previously, and finally click the "OK" button. In this way, the newly created instance will be automatically authorized, and you only need to enter an independent password when accessing the network disk.

download file

On the authorized public network disk, find the file you want to download locally and click the "Download" button.

Confirm the location of the downloaded file. You cannot modify it here. Just know it. Click "OK" to start downloading.

After the download is completed, enter JupyterLab, enter the "autodl-tmp" folder, and you can see the file we downloaded.

If you need to move the file to another directory, right-click on the target file and click "Cut" in the pop-up menu.

Then go to the target path through the file manager, click "Paste" in the blank space, wait a moment, and the file will be moved.

upload files

In the "Public Network Disk" page of "AutoPanel", click "Upload", and an "Upload File" page will pop up. You can switch the path at the top of the page, and a list of files under the path will be displayed at the bottom of the page. Find the file you want to upload. file, click "Upload" next to the file.

Both single files and folders can be uploaded, but if there are more than 100 files in a folder, they need to be compressed before uploading. Multiple upload tasks can be initiated continuously and they will be queued for execution.

File storage

Because this part of the content requires the user to manually open it and then do some technical processing, the operation threshold is relatively high. If you don’t understand it, it doesn’t matter, and it will not affect normal use.

AutoDL itself provides a function called "File Storage", which can be shared among multiple server instances. It is similar to a public network disk, but we can access it directly in the server, so it is more convenient than a public network disk. Some.

After clicking "Initialize File Storage", we can see the interface below. You can upload and download files. It is a pity that this free space is only 20G. If it exceeds 20G, the excess space will be billed. Currently, it costs 1 cent per G per day.

After turning on file storage, we can see this folder in the server's file system, and what is mounted is the "file storage" created above. If the server is created after the "File Storage" is initialized, the server instance needs to be shut down and then restarted before it can be mounted successfully.

The essence of "file storage" is a kind of network storage. Its advantage is that it is stored in three copies and data is not easily lost. However, compared with the local "system disk" and "data disk" of the server, the access speed will be slower.

If you do not have high requirements on disk performance, you can change part of the SD WebUI path to this, such as the output path for generating images, some small models, etc.

How to change the image output path :

(1) Start a terminal that can execute commands.

Click the plus sign in JupyterLab to open a new Launcher.

Click "Terminal" on the Launcher page.

(2) Execute the command to change the path in the terminal.

  • First create a directory in "File Storage" to save the images generated by SD;
  • Then delete the file output directory of SD WebUI;
  • Finally, create a soft link from the SD WebUI output directory to the newly created directory in "File Storage".

In this way, when SD WebUI saves a file, it will automatically be saved in "File Storage".

mkdir /root/autodl-fs/webui_outputs
rm -Rf /root/stable-diffusion-webui/outputs
ln -s /root/autodl-fs/webui_outputs /root/stable-diffusion-webui/outputs

How to change the model save path :

This is simple, just modify the startup command. If you are using the yinghuoai image, directly modify the following file:

There are several --xxx-dir parameters in this command, which are the paths of various models. Just replace them as needed.

After making the changes, don't forget to restart in JupyterLab, just click the button with the two arrows.


OK, the above is the main content of this article. If you have any questions, please give me feedback.

I will often share some cutting-edge knowledge and application examples of AI. Please follow the public account: Yinghuo Walking AI (yinghuo6ai) to avoid mistakes in exciting content.

Guess you like

Origin blog.csdn.net/bossma/article/details/132022385