I am new to Python and Jupyter Notebook. I have Anaconda installed on my Windows 11 computer. I am running Jupyter Notebook in a virtual environent. The problem I'm encountering happens when I attempt to run the following...
import torch
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import torch.nn as nn
X = torch.linspace(1,50,50).reshape(-1,1)
torch.manual_seed(71)
e = torch.randint(-8,9,(50,1),dtype=torch.float)
y = 2*X + 1 + e
plt.scatter(X.numpy(),y.numpy())
The error I get is
"The kernel appears to have died. It will restart automatically."
I think I have narrowed the issue down to matplotlib, as it is the only new element I have imported, and only the cell referencing "plt.scatter" causes the kernel to die.
I have tried the following solutions
Run Anaconda Prompt as administrator
conda install --yes freetype=2.10.4
which results in
"# All requested packages already installed."
I also tried
conda update mkl
printing 'Hello World' works fine, as does using numpy and torch from what I can tell.
It's worth mentioning that when the kernel dies, my command window shows the following:
[I 16:30:08.979 NotebookApp] Kernel started: 503c71ae-ced0-4147-8f23-7cdad416d503, name: python3
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, 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/.
[I 16:30:23.983 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
WARNING:root:kernel 503c71ae-ced0-4147-8f23-7cdad416d503 restarted
Any help would be greatly appreciated.
Related
I have an extremely weird issue where if I run pytorch model training from Pycharm, it works fine but when I run the same code on the same environment from terminal, it freezes the screen. All windows become non-interactable. The freeze affects only me, not other users and for them >>top shows that the model is no longer training. The issue is consistent and reproducible across machines, users, and GPU slots.
All dependencies are installed to a conda environment dl_segm_auto. In pycharm I have it selected as the interpreter. Parameters are passed through Run->Edit configuration.
From terminal, I run
conda activate dl_segm_auto
python training.py [parameters]
After the first epoch the entire remote session freezes.
Suggestions greatly appreciated!
The issue was caused by the matplotlib's backend taking over the screen on Linux. Any of the following can solve the problem:
Installing PyQt5 (which changes the python's/environment's default backend)
Running from Pycharm (which uses a backend selector on startup).
Having matplotlib.use('Qt5Agg') (and potentially others) at the start of plotting functions or top-level script.
The kernel crashes when I run a simple code using pytorch (even though it's not used here).
import numpy as np
import matplotlib.pyplot as plt
import torch
x=np.arange(0,10,0.1)
plt.plot(x,np.sin(x))
plt.show()
When I run this code on Jupyter, it shows the kernel is dead. When I run it on Visual Code, it shows:
Canceled future for execute_request message before replies were done
The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click here for more info. View Jupyter log for further details.
How to resolve this issue. The torch package is supposed to be used later.
This problem has been solved by updating the numpy and matplotlib packages. These packages were installed just one year ago, though.
When I was using jupyter in vscode, I found that it could not remember remember I had import tensorflow in the last block. like:
block1: import tensorflow as tf (success)
block2: print(tf.__version) (false -->"name 'tf' is not defined")
This problem is only for tensorflow. Vscode works well with other modules.
I am using Apple M1 max
Restart Jupyter kernel will lose all variables. After I restart it then only run print(tf.__version__) i get the same error as yours:
After restarting, you should run the previous code cell again to make the following code run successfully.
I am using anaconda jupyter notebook on windows. I am using tensorflow 2.1.0, anaconda and keras are up-to-date, but when I try to import numpy it works but when I try to import keras it says kernel died. And it gives an error like:
Warning! HDF5 library version mismatched error
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.4, library is 1.10.5
SUMMARY OF THE HDF5 CONFIGURATION
could you help me int this case thanks.
When I try to run code using keras and numpy or keras and Matplotlib in one Jupyter notebook I always get the message: The kernel appears to have died. It will restart automatically.
When I run the code in two different notebooks it works perfectly fine. I have installed it using anaconda and I am using macOS. I would really appreciate an answer, everything else I've found and tried so far did not work. Thank you!