PyTorch出现:RuntimeError: An attempt has been made to start a new process...报错 PyTorch出现:RuntimeError: An attempt has been made to start a new process...报错

1.查看显卡:

第一步:同时按下键盘的win+r键,输入cmd

第二步:随后输入

nvidia-smi

2.查看下载安装的包:

conda list

conda list

3.问题报错

PyTorch出现:RuntimeError: An attempt has been made to start a new process...报错

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.

出错原因:网上查找结果,原因是多进程的原因

解决方法:

1. 代码在运行 epoch 之前,加上    if __name__=='__main__'

2, 不使用多线程,即去掉 num_workers 参数,或设置 num_workers=0。

dataset = torch.utils.data.DataLoader(trainset, batch_size=opt.batch_size,
                                        shuffle=True, num_workers=0, drop_last=True)

相关推荐

  1. torchdata pytorch2.3

    2024-03-27 07:16:02       30 阅读
  2. PyTorch使用tensorboard的SummaryWriter

    2024-03-27 07:16:02       33 阅读
  3. pytorch GPU cuda 使用 整理

    2024-03-27 07:16:02       29 阅读
  4. 解决子组件没有渲染完出现

    2024-03-27 07:16:02       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-27 07:16:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-27 07:16:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-27 07:16:02       87 阅读
  4. Python语言-面向对象

    2024-03-27 07:16:02       96 阅读

热门阅读

  1. 05、Lua 变量

    2024-03-27 07:16:02       37 阅读
  2. leetcode - 843. Guess the Word

    2024-03-27 07:16:02       36 阅读
  3. 【Django】枚举类型数据

    2024-03-27 07:16:02       37 阅读
  4. 微服务设计原则——低风险

    2024-03-27 07:16:02       36 阅读
  5. 滴滴出行高级Node.js开发工程师笔试题2024

    2024-03-27 07:16:02       42 阅读
  6. 【Mysql】更新脚本SQL——新增删除修改字段

    2024-03-27 07:16:02       38 阅读
  7. day29【LeetCode力扣】15.三数之和

    2024-03-27 07:16:02       39 阅读
  8. js对比日期大小

    2024-03-27 07:16:02       42 阅读
  9. 搭建服务器 - 笔记

    2024-03-27 07:16:02       33 阅读
  10. Spark SQL DataFrame

    2024-03-27 07:16:02       44 阅读
  11. 类模板分文件编写

    2024-03-27 07:16:02       41 阅读
  12. 3.23Code

    2024-03-27 07:16:02       32 阅读