Windows下 import torchvision :ImportError: DLL load failed: The specified module could not be found.

1、在 Windows 下安装 pytorch 后 ,再安装 torchvision,

import torchvision : DLL load failed: The specified module could not be found.

解决方案:

缺少了必要的一些动态链接库,或者没英伟达显卡而误装了GPU版本的

在cmd中输入:conda install -c peterjc123 vc vs2017_runtime

再倒入 torchvision 就没问题了

2、运行错误

#使用pytorch时出现的多进程错误,如下描述:
RuntimeError:
    An attempt has been made to start a new process before the
    current process has finished its bootstrapping phase.

   This probably means that you are not using fork to start your
   child processes and you have forgotten to use the proper idiom
   in the main module:

       if __name__ == '__main__':
           freeze_support()
           ...

   The "freeze_support()" line can be omitted if the program
   is not going to be frozen to produce an executable.

解决方案:

#解决方案如下:
import torch
def main()
    for i, data in enumerate(dataloader):
        # do something here
if __name__ == '__main__':
    main()

Reference:

Win10环境下安装Pytorch(两个错误解决方法汇总)

知乎-PyTorch 0.4.0 正式版 - Windows 说明

pytorch0.4.0官方文档

猜你喜欢

转载自blog.csdn.net/xrinosvip/article/details/81383399