简体   繁体   English

Jupyter notebook 死内核

[英]Jupyter notebook dead kernal

I was doing a project in Colab.我在 Colab 做一个项目。 But when I copy the same code in my jupyter notebook in my MacBook, I get a dead kernal message when I run the following imports.但是,当我在 MacBook 的 jupyter notebook 中复制相同的代码时,运行以下导入时会收到一条死内核消息。

import os
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.font_manager import FontProperties
import scipy
import cv2
%matplotlib inline

np.random.seed(2)

from sklearn.metrics import confusion_matrix
import itertools

from keras.utils.np_utils import to_categorical
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D, BatchNormalization
from tensorflow.keras.optimizers import RMSprop
from keras.preprocessing.image import ImageDataGenerator
from keras.callbacks import ReduceLROnPlateau, ModelCheckpoint
from keras.models import model_from_json

import warnings

warnings.filterwarnings('ignore')

Any Ideas on how to fix this?有想法该怎么解决这个吗?

It seems conda has not installed properly in your system.您的系统中似乎没有正确安装conda Try again by uninstalling the anaconda and install it back from scratch.卸载 anaconda 再试一次,然后从头开始重新安装。

Please check thislink to install Anaconda.请检查此链接以安装 Anaconda。

After installing Anaconda in your system, Create virtual environment to install Tensorflow in it as below:在您的系统中安装 Anaconda 后,创建虚拟环境以在其中安装 Tensorflow,如下所示:

To install the current release of CPU-only TensorFlow,要安装仅 CPU TensorFlow 的当前版本,

conda create -n tf tensorflow
conda activate tf

Or, to install the current release of GPU TensorFlow或者,安装当前版本的 GPU TensorFlow

conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu

You can also create virtual environment in Anaconda Environment section.您还可以在 Anaconda 环境部分创建虚拟环境。 Open the Jupyter notebook by selecting the same virtual environment.通过选择相同的虚拟环境打开 Jupyter Notebook。

run below code:运行以下代码:

conda install pip
pip install tensorflow

After doing all these setups, your code may run fine as I have already executed above code in Jupyter and its not showing any error.完成所有这些设置后,您的代码可能会运行良好,因为我已经在 Jupyter 中执行了上面的代码并且它没有显示任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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