在docker中运行的pytorch运行多线程训练,报如下错误:
unexpected bus error encountered in worker. This might be caused by insufficient shared memory(shm)
解决方法,启动docker时,增加--ipc=host参数
如果是在k8s上运行的,则需要在yaml的spec中加入hostIPC: true类似如下效果:
apiVersion: v1
kind: pod
metadata:
name: pod-with-host-pid-and-ipc-yaohong
spec:
hostPID: true //你希望这个pod使用宿主节点的PID命名空间
hostIPC: true //你希望pod使用宿主节点的IPC命名空间
containers:
- name: main
image: alpine
command: ["/bin/sleep", "99999"]
参考:https://kubernetes.io/zh/docs/concepts/policy/pod-security-policy/#host-namespaces