报错
pytorch报错RuntimeError:
DataLoader worker (pid(s) ... exited unexpectedly
解决
因为torch.utils.data.DataLoader中设置了num_works=4,也就是多线程读取。
根据其他方法,我设置num_works=1
或者num_works=0
都不行。
最后重装了pytorch,就可以了。
pip install torch==1.5.1+cu101 torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
原因分析
过程中显示下面内容,所以,可能是因为有些包用pip install
的时候没装上吧。
The following packages will be downloaded:
package | build
---------------------------|-----------------
certifi-2020.6.20 | py36_0 160 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-base-1.18.5 | py36hde5b4d6_0 5.1 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random-1.1.1 | py36h0573a6f_0 382 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft-1.1.0 | py36h23d657b_0 159 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-1.18.5 | py36ha1c710e_0 4 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
------------------------------------------------------------
Total: 5.8 MB
The following NEW packages will be INSTALLED:
blas: 1.0-mkl https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cudatoolkit: 10.1.243-h6bb024c_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
intel-openmp: 2020.1-217 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgfortran-ng: 7.3.0-hdf63c60_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl: 2020.1-217 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-service: 2.3.0-py36he904b0f_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_fft: 1.1.0-py36h23d657b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl_random: 1.1.1-py36h0573a6f_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ninja: 1.9.0-py36hfd86e86_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy: 1.18.5-py36ha1c710e_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-base: 1.18.5-py36hde5b4d6_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pytorch: 1.4.0-py3.6_cuda10.1.243_cudnn7.6.3_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
six: 1.15.0-py_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
```