提示:PyCharm远程连接服务器,调试torch.distributed.launch分布式程序,无需.sh,命令行操作
一、引入软链接
在项目的上一级目录输入。前面的是解释器所对应的distributed的目录,后者是项目名。
ln -s /home/username/miniconda3/envs/virtualenv_name/lib/python3.6/site-packages/torch/distributed/ yourproject
然后服务器中的项目会有这样应该文件夹。
接下来就在pycharm中download这个文件夹到本地。
二、在pycharm中进行修改设置
1、创建应该新的configuration
2、引入本地文件夹中的lanch.py文件
因为上一步意见进行了软连接了
3、写入参数
原参数如下
python -m torch.distributed.launch --nproc_per_node=2 --master_port 12345 main.py --dataset prcc --cfg configs/res50_cels_cal.yaml --gpu 0,1 #
在configuration中新的参数如下,涉及到地址,一定要使用linux在的绝对地址!!!!(这个踩坑很久)
4、然后就可以debug了
总结
希望可以帮到大家,100%可以用的!