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

1.查看显卡:

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

第二步:随后输入

python 复制代码
nvidia-smi

2.查看下载安装的包:

conda list

python 复制代码
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。

python 复制代码
dataset = torch.utils.data.DataLoader(trainset, batch_size=opt.batch_size,
                                        shuffle=True, num_workers=0, drop_last=True)
相关推荐
Loacnasfhia99 小时前
卷烟爆珠气泡缺陷检测与分类_YOLO11创新点改进_C3k2与MLCA模块融合结构研究_1
人工智能·目标跟踪·分类
雨大王5129 小时前
汽车制造数字化转型如何选择靠谱的产业链服务商?
人工智能
好物种草官9 小时前
广州儿童眼镜店深度测评:6家主流品牌横向对比与选择策略
大数据·人工智能·经验分享
qwy7152292581639 小时前
11-图像的缩放
人工智能·opencv·计算机视觉
工业相机定制与开发9 小时前
云钥科技AI智能相机为图文印刷行业提供全流程检测解决方案
人工智能·数码相机
XX風9 小时前
3.3 GMM (高斯混合模型)
人工智能·算法·机器学习
星爷AG I9 小时前
9-24 视觉叙事(AGI基础理论)
前端·人工智能
量子-Alex9 小时前
【大模型技术报告】ChatGLM大模型技术报告深度解读
人工智能
zy_destiny9 小时前
【工业场景】用YOLOv26实现8种道路隐患检测
人工智能·深度学习·算法·yolo·机器学习·计算机视觉·目标跟踪
(; ̄ェ ̄)。9 小时前
机器学习入门(二十)支持向量机SVM
人工智能·机器学习·支持向量机