When reproducing some earlier documents, the network architecture was an earlier Pytorch model. The current higher version is not compatible, so you have to install a lower version of torch==0.4.0 to solve the problem.
Table of contents
1. Problem
问题:ImportError: cannot import name ‘_update_worker_pids’
A lower version of Pytorch is required when the following situations occur:
1.1 Problem analysis
This error may be due to a problem with the PyTorch version. _update_worker_pids etc. are internal functions of PyTorch and may not exist in some versions.
2. Solution
Note: Python version must be less than or equal to 3.6
2.1 Pytorch installation
Use the following command to install version 0.4.0 of Pytorch.
pip install torch==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
The installation in the corresponding virtual environment of the terminal is as follows:
2.2 torchvision installation
Corresponding to version 0.4.0 in the previous step, torchvision must be 0.2.0. If you don’t believe it, you can try other versions.
The command to install torchvision is as follows:
pip install torchvision==0.2.0 -i https://pypi.mirrors.ustc.edu.cn/simple/
The installation in the corresponding virtual environment of the terminal is as follows:
2.3 Test whether the installation is successful
The above installed look is as follows:
Test in the code. If there is no red line underlined or an error reported, it means the installation has been successful, as follows:
3. Summary
The above is the process of solving the problem: ImportError: cannot import name '_update_worker_pids’. I hope it can help you.
It’s not easy to summarize, thank you for your support, Sherer!