How does a novice Xiaobai rent a GPU cloud server to run deep learning

I just learned deep learning recently, and my computer’s cpu version of pytorch can run LexNet at most, and AlexNet can’t run directly, but I have to write homework and do experiments. In desperation, I discovered on the Internet that I can also rent a server. The server I rented was RMB 0.78 per hour. It was like discovering a new continent and saving a lot of money.

Because I am a novice, I am not very fluent in terms of technical terms, so I directly uploaded the picture. If you are also a novice, reading posts full of technical terms on the Internet is probably as painful as I started. Without further ado, let's serve the dishes directly.

1. Find a server that can be rented

There are many server platforms on the Internet

The example here refers to the GPU you rented. After clicking, you can select your GPU. There is nothing else to say. One thing to pay attention to is the place where the image is mirrored.

 

If you are installing for the first time, then you should choose "basic image", because there is a high probability that your teacher will let you learn basic networks such as CNN, LeNet, and AlexNet first. 

And if you want to use some github projects such as YOLO-v5, select "Algorithm Mirroring" to have a ready-to-use algorithm environment immediately.

And if you have used a gpu before, but the gpu you used before was turned off and then turned on and found to be gone (it was rented to someone else), then you have to choose "my image". Because some data used by the code after you rent the server, for example, the model you saved is not in your local, but in the image of the gpu, you need to save the image of the gpu you used before.

Make sure your gpu is powered off before saving the image.

 Then name your image, whatever you want, as long as you can remember it.

Then you can use your original image when renting a new gpu.

Finally, click Create Now, and the server has been rented by you. This platform will give you 10 yuan first, which is enough for you to work on it for a day and understand the rental process.

2.pycharm Professional Edition

Because renting a gpu is equivalent to remotely sending your code to a distant place~~, and letting others run it for you, so you have to have a professional version of pycharm, and only the professional version can be remote.

You can go to the official website of pycharm to find out how much the professional version costs->->, so my suggestion is the omnipotent treasure (shh).

3.pycharm establishes a remote SSH connection

Let me talk about it here. I don’t know why the online tutorials say to establish the SFTP protocol first, and then establish the SSH connection, but I can directly establish the SSH connection, so I wrote my method. If you have doubts, you can search the Internet.

First come to the AutoDL platform to find your instance, which is the gpu you rented, and find the login command and password of the gpu

for example,

The login command is: ssh -p 26966 [email protected]

The password is: zHr0lkQW+M

Then you need to use these to connect your pycharm with the rented gpu

Go to File -> Settings in the upper left corner, click to File -> Settings in the upper left corner, and click to enter

Find Python Interpreter in the Project on the left column, enter and click Add Interpreter on the right

Select SSH

1/4 Use the previous login command to fill in these three, and just split that command.

2/4 Fill in the login password

3/4 If there is no mistake in the previous, this step will be as shown in the figure. Otherwise, it is a line of red letters

Choose the system interpreter here, do not choose the virtual environment according to the picture

4/4 Choose the basic interpreter. If you have configured the pytorch virtual environment before, you should know what the interpreter means.

After the creation is successful, a new interpreter starting with Remote Python will appear in your Python Interpret, just select it.

 Finally select SSH configuration, tools->Deployment->configuration

Select the SSH configuration you just created, be sure to select the √ symbol above, otherwise it cannot be changed

Then you can start using pycharm.

4. Use pycharm

4.1. Terminal

The first task is to get your code running. The process of running code with a rented gpu is that pycharm will upload your code to the server, and then use the linux command to run the uploaded code

First upload the code

 Right click on your code to find Deployment->Upload your code to the server

 Then click File Transform on the far right at the bottom to find the path of your recently uploaded py file, which is 2 on the picture

Copy this path and go to Terminal

At this time, you cannot run the code in the local Terminal, but run it in your server. From the small triangle, select the python interpreter you created before, that is, the interpreter that starts with Remote Python, as mentioned earlier.

Then you write your command into Terminal in the form of python+space+path in the window you just opened. This is actually a linux command. After pressing Enter, the py file will start running.

4.2. How to install the library

 Just pip install the library name directly in the terminal

 The above are some of the problems I encountered when renting the GPU. Welcome to comment and exchange~

Guess you like

Origin blog.csdn.net/h_u_m_a_n/article/details/127771716