MAC OS 運行tensorflow, keras 遇到error 解決方法
直接給結論:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
os.environ['KMP_DUPLICATE_LIB_OK']='True'
===================================================================
就在昨晚睡前發生的事,練習深度學習時,跑出下面兩行...乾你ㄇ 的 那麼長...
OMP: Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/
立馬餵狗
OMP:錯誤#15:初始化libiomp5.dylib,但發現libiomp5.dylib已經初始化。
OMP:提示這意味著已將OpenMP運行時的多個副本鏈接到該程序中。 這很危險,因為它會降低性能或導致錯誤的結果。 最好的辦法是確保只有一個OpenMP運行時鏈接到進程中,例如 通過避免任何庫中的OpenMP運行時的靜態鏈接。 作為不安全,不受支持,未記錄的變通方法,您可以設置環境變量KMP_DUPLICATE_LIB_OK = TRUE以允許程序繼續執行,但這可能導致崩潰或無聲地產生不正確的結果。 有關詳細信息,請訪問http://www.intel.com/software/products/support/
看到關鍵字,再去搜尋一下,果然...10秒鐘可以解決的事情
但事情並非發展的如此順利......
看到解答:
路人甲的回答 :
I tried:
import os
os.environ['KMP_DUPLICATE_LIB_OK']='True'
os.environ['KMP_DUPLICATE_LIB_OK']='True'
It can do the job for me. But it is kind of ugly.
我心想:
這會污染我的程式啊......
於是參照了另外路人乙的回答:
For people googling this error, the best solution that I found is listed here.
The site lists two method. I prefer method 1, which is to go into your anaconda3/lib directory and remove the old libiomp5.dylib file. Nice and simple.
好像很棒!!輕鬆簡單,我移除了libiomp.dylib 文件,還手賤的把垃圾桶清空...
回不去了...整個程式崩潰,只好重灌,浪費了我15分鐘...Orz
只好繼續用路人A的方法,看之後有沒有提出更好的解答了。
沒有留言:
張貼留言