In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces you how to run and debug torch distributed training in pycharm, the content is very detailed, interested friends can refer to it, I hope it can help you.
Now a lot of deep learning research open source code will use the pytorch framework, one of the reasons is that in torch, as long as you define a module, you can easily use torch.distributed to apply it to single-machine multi-GPU or multi-machine multi-GPU scene, accelerate the convergence speed of the model.
But in all the github projects readme only shows how to use distributed methods in command-line mode. This is less useful for researchers who need to debug in Pycharm or other IDEs. environment PyTorch 1.1.0 PyCharm 2020.1 Analyze Readme parameter settings First, we need to see how the Readme file of the project uses distributed training, in case we set parameters in Pycharm later.
python -m torch.distributed.launch --nproc_per_node=4 tools/train.py --cfg xxx.yaml
python -m torch.distributed.launch --nproc_per_node=4 indicates that the torch.distributed.launch file is called for distributed training; --nproc_per_node=4 indicates that the number of nodes created is 4, which is usually consistent with the number of GPUs used for training. tools/train.py--cfg xxx.yaml is the real training file, followed by--cfg xxx.yaml is the name and value of the execution parameters that need to be given when train.py is used. soft link distributed file By analyzing the commands that call distribution, we first need to find the torch.distributed.launc h file and soft link it to our Pycharm project directory. Why use soft links instead of direct copy? Because soft linking does not change the path of the file, the launch.py file can import the packages it needs without making any changes. In Ubuntu, create soft links by
ln -s /yourpython/lib/python3.6/site-packages/torch/distributed/ /yourprogram/
The above command does not link directly to launch.py but its parent directory distributed, because it is easier to know that launch.py is a soft link and not confused with other files in the project. Set Pycharm operating parameters
Open Pycharm and click Run->Edit Configurations to enter the parameter configuration interface:
Just configure Script path to launch.py path;Parameters to launch.py run parameters, refer to the method called on the command line, set as follows.
--nproc_per_node=4tools/train.py--cfg xxx.yaml You can run distributed training in Pycharm by following these steps. However, if you are debugging the model, it is best to modify the trian.py file. Debugging through single GPU mode does not mean that distributed mode cannot be debugged, just because in single GPU mode, it is better to control the data flow and reduce debugging time. About how to run and debug torch distributed training in pycharm to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.