最近开始学习Pytorch,记录一下自己踩过的坑。
系统环境
笔记本 | 实验室服务器 | |
---|---|---|
OS | Windows 10 | Ubuntu 18.04.1 |
python | 3.7.6 | 3.8.6 |
pytorch | 1.6.0 | 1.6.0 |
cuda | 10.2 | 11.1 |
今后的实验基本都在服务器环境下进行了(2020.11.14)
1.多线程数据加载
trainloader = torch.utils.data.DataLoader(trainset, batch_size=4,
shuffle=True, num_workers=2)
如果在使用上述这类代码时发生如下错误,那么你可能需要调整一下自己代码的顺序了。
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