问题描述
OSError: (External) Cuda error(3), initialization error.
[Advise: The API call failed because the CUDA driver and runtime could not be initialized. ] (at /paddle/paddle/fluid/platform/gpu_info.cc:200)
- 说明: 使用的是paddlepaddle训练的模型, 准备使用多进程进行数据的处理, 但是在初始化的时候报上面的错误.
解决方案:
- 在是github上找了好久的, 下面这个是可以解决问题的方案
1. 将原来的使用的 from multiprocessing import Pool 修改为 from torch.multiprocessing import Pool
2. 另外还需要添加 import torch
- 这个时候就可以启动程序了, 如果在启动程序的过程中出现
RuntimeError: context has already been set # 这个报错问题
- 上面问题的解决方案:
在 if __name__ == '__main__':
代码中添加:
torch.multiprocessing.set_start_method('spawn')
- 完成上面的代码添加, 问题得到解决, 程序顺利运行
祝大家运行顺利!!! ~~~💪🏻