Pycharm connects to remote SSH

1. Configure the remote interpreter

Please use the professional version of Pycharm, the community office does not include this feature!

In pycharm, click Tools - "Deployment -" Configuration, create a new SFTP connection, click Configure SSH, enter the server IP, account and password, and click Test Connection to verify the account password. After creating SSH, there is no need to fill in the SFTP content and go to the next step:

Click File -》setting -》project -》python interpreter -》add interpreter -》On SSH. Please enter the IP, account and password when configuring the server for the first time:

In the third step, please wait patiently for the detection connection to end. Generally, conda is used to configure a python environment on the remote end:

conda create --name your_project python=3.6

Use an existing environment and select the corresponding interpreter in the Interpreter. There are two items in Sync folders. Select the local folder on the left (no need to modify), and select the remote server on the right to correspond to the project location.

After completing this step, you can see the remote interpreter configuration:

Notice! We can find that an SFTP is automatically created, click mapping:

You can find that the local path and remote path have been configured. This is because the project path is configured when setting up the interpreter. When using other projects and need to use the existing python environment, please configure the project path here:

Two useful tips

 Tools - "Start SSH Session" Select the corresponding SFTP connection and open the command line in pycharm. Tools - "Deployment -" Browse Remote Host can open the server file list on the right:

 Code modification and execution

After modifying the code, please right-click -> Deployment -> update to SFTP, synchronize the code of the remote server and click Run.

2. slurm script and submission

Submit and view commands

sbatch test.slurm  # 提交任务
# Submitted batch job 2161  # 该任务已经提交2161号作业

squeue  # 查看当前任务
# JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
# 2161       gpu ffhq_ngp gonggeng  R       0:09      1 gpu05

script template

#!/bin/bash
#SBATCH --job-name=job_name ##作业名称      《需要修改》
#SBATCH --partition=gpu ##作业申请的分区名称
#SBATCH --nodes=1 ##作业申请的节点数
#SBATCH --ntasks-per-node=8 ##作业申请的每个节点使用的核心数
#SBATCH --gres=gpu:1 ##作业申请的每个节点GPU卡数量
#SBATCH --error=%j.err  # 报错日志
#SBATCH --output=%j.out  # 执行日志

# ======================下方需要改成自己的代码==============================
# 激活conda环境
# source activate test_env  该方法激活会报错,下方已改成绝对路径
source conda_path/anaconda3/bin/activate test_env
python main.py --config ./configs/test.yaml

Guess you like

Origin blog.csdn.net/RRRUAAA/article/details/131456195