Mac下jupyter notebook 出现“服务似乎挂掉,但会立刻重启”的解决方法

写在前面:很早之前使用mac跑神经网络的时候就出现过这种问题,当时以为是电脑的问题,后来一直用ubantu跑网络,最近又用mac跑很简单的网络,一跑就挂。就查了一下这个问题。

  • 问题描述

运行神经网络,即使是很简单的模型的时候也会出现这个问题。
控制台日志信息

从控制台可以看到日志信息如上图。

  • 问题原因

可以看到,这次的错误似乎和线程有关系,里面提到了
,百度一下。看来的确是和处理器的一些设计方案有关系。起初以为是内存不够了,看来好像并不是这样。

OpenMP是由OpenMP Architecture Review
Board牵头提出的,并已被广泛接受,用于共享内存并行系统的多处理器程序设计的一套指导性编译处理方案(Compiler Directive)
[1] 。OpenMP支持的编程语言包括C、C++和Fortran;而支持OpenMp的编译器包括Sun Compiler,GNU
Compiler和Intel
Compiler等。OpenMp提供了对并行算法的高层的抽象描述,程序员通过在源代码中加入专用的pragma来指明自己的意图,由此编译器可以自动将程序进行并行化,并在必要之处加入同步互斥以及通信。当选择忽略这些pragma,或者编译器不支持OpenMp时,程序又可退化为通常的程序(一般为串行),代码仍然可以正常运作,只是不能利用多线程来加速程序执行

  • 解决方法

  • 方法一

从日志信息中看到下面一句话

As an unsafe, unsupported ,undocumented work around you can set the environment KMP_DUPLICATE_LIB_OK=TRUE to all the program to continue execute, but that may cause crashed or silently produce incorrect results.

import os
os.environ['KMP_DUPLICATE_LIB_OK=TRUE']="True"

官网对environ的解释是这样的,和python环境有关系

A mapping object representing the string environment. For example, environ['HOME'] is the pathname of your home directory (on some platforms), and is equivalent to getenv("HOME") in C.

This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.

这个方法管用,但是官方不太推荐

  • 方法二
    先把numpy 、pandas、 scripy 卸掉,然后安装nomkl
    conda install nomkl
    再把这几个包装回来就好了

原因好像是这样

For macOS, nomkl is a good option, since the optimization MKL provides is in fact already provided by Apple’s Accelerate Framework, which uses OpenMP already. This is in fact the reason that the error (’…multiple copies of the OpenMP runtime…’) is triggered, it seems (as stated in this answer).

macOS的Apple’s Accelerate Framework 已经使用了OpenMP了,所以造成了两个OpenMP冲突,所以出现了 mu ltiple copies of the OpenMP runtime 的确有同学反映过在电脑里发现了两个这种文件

问题已解决

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值