简体   繁体   中英

Importing PyTorch before using pandas.DataFrame.plot() causes Jupyter kernel to crash

I'm running windows 10 with the following library versions:

matplotlib  3.3.3
torch       1.7.0
pandas      1.1.4

When I load from CSV a dataframe and plot its data BEFORE import torch , I get no issues. However, if I put all of my import statements at the top of the notebook, as is tradition, I instead get a crashed kernel with the following pop up message:

The kernel for anom_detect_nn.ipynb appears to have died. It will restart automatically.

When I look at my shell, I see two error messages:

OMP: Error #15: Initializing libiomp5md.dll, but found libiomp5md.dll 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, eg 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/ .

It seems like other users on SO have experienced this before, but all of the solutions apply to MacOS users. I've tried them anyway:

  1. conda install nomkl
  2. pip uninstall everything , pip install everything
  3. I did not use the dangerous workaround KMP_DUPLICATE_LIB_OK=TRUE

Thanks to the above steps entire set-up is now a tangled mess where I can't pip install anything successfully, and modules that are successfully installed can no longer be imported without Module not found errors.

This is a real pain, and I'm at my wits end. I'm currently uninstalling everything Python on my system and starting over. Not a happy camper. Any solutions that are for Windows and not Mac, should this problem persist when I start over?

Same issue. This worked for me:

  • put plt before import torch
  • use imshow immediately
  • import torch
  • use imshow (and it doesn't crash)

I don't know why, but it works...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM