Pycharm Professional Edition connects to remote GPU server + xshell7 and xrtp7 download

This blog will take everyone to use pycharm to connect to the remote server, and use the GPU on the server to run the code. There are many lightning points in it, and everyone stepped on them one by one, so this is also an article on lightning protection. The article attaches the download link of pycharm professional version, the download and usage instructions of xshell7 and xrtp7, I hope it can help you.
insert image description here

1. Pycharm connects to remote server

First of all, we must make sure that our Pycharm is a professional version. We usually use the community version of Pycharm. The community version of Pycharm does not have the function of remote connection, so we need to use the professional version of Pycharm. Here is an installation tutorial for the professional version of Pycharm, just follow this tutorial to install it: Pycharm Professional Edition Installation .
Open the interface and click configuration under deployment under the toolbox. insert image description here
Click the plus sign to add server information, select SFTP, click ... on the right to add information:
insert image description here
enter IP, port number (default is 22), user name (note case), and password in sequence.
insert image description here
Click OK to return to the previous interface, you can click Test_connection to try to connect, successful connect means you can connect to the server normally.
insert image description here

The key step is here! --- Configuration file mapping information. Click mappings, the local path is the path of the local folder, using a \ slash, and the deployment path is the path corresponding to the remote server. The key point! The last folder name of the server must be the same as the local folder name, here I The local is lzy, and the server should also create a folder with the same name as lzy , otherwise when the file is run later, an error that the file cannot be found will be reported!
insert image description here
Then create a virtual environment, select ssh to create, select the server connection we created before:
insert image description here
select the virtual environment of conda in the remote server, and then fill in the mapping relationship of the previous files on it.
insert image description here
Click finish, click the gear on the right and then showall, find the environment of the remote server, and click edit on the right.
insert image description here
Change to SSH connection, modify the SSH configuration and interpreter path, and modify it to your own. Then click OK.
insert image description here
Libraries in virtual environments on remote servers can be seen. I have pre-installed Pytorch and torchvision and torchaudio, and it is the GPU version.
insert image description here
Turn on automatic file upload, or manually upload files. When uploading, click on the entire folder and upload.
insert image description here
Write a script to test whether the Gpu on the server is successfully connected:


#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project :628test 
@File    :test.py
@IDE     :PyCharm 
@Author  :咋
@Date    :2023/6/28 23:24 
"""
import torch
print(torch.cuda.is_available())
print(torch.__version__)
cuda_version = torch.version.cuda
print("CUDA 版本:", cuda_version)
device = torch.cuda.get_device_name()
print("名称:", device)

insert image description here
output:

True
1.10.2+cu111
CUDA 版本: 11.1
名称: NVIDIA GeForce RTX 3090

Now the code is running on the remote server, using the GPU on the server. So far, Pycharm is connected to the remote server. Let’s start using the graphics card on the server happily! Let me recommend two very useful tools, xshell and xftp.

Two, xshell7 and xrtp7 are used together

xshell is used to connect to remote servers, and xrtp is used to transfer files. After xshell is connected, it is equivalent to the command window of linux, and various linux commands can be used to control the actions of the remote server. xrtp is to transfer files to and from the remote server after xshell is connected. It has a visual interface, which is very convenient. xshell and xrtp free version download address: xshell and xrtp free version download address .
insert image description here
insert image description here
Fill in the ip and port number, user name and password, and you can connect directly, and you can connect directly without entering the password next time. The main network problem, if there is a proxy, turn off the proxy to ensure that the current network is suitable for connecting to the current server.

3. Summary

I used to think that it was very troublesome to configure the remote server and the local Pycharm connection. With the completion of this blog, I feel that it is not very troublesome. The thinking is very clear, and I have explained all the pitfalls I stepped on before. If you encounter other problems, please feel free to comment below!

Guess you like

Origin blog.csdn.net/weixin_63866037/article/details/131711411