学习paddle中试着跑教程中的代码,发现核崩溃了,该如何解决

```python
#网络结构部分之后的代码,保持不变
def train(model):
    model.train()
    #调用加载数据的函数,获得MNIST训练数据集
    train_loader = load_data('train')
    # 使用SGD优化器,learning_rate设置为0.01
    opt = paddle.optimizer.SGD(learning_rate=0.01, parameters=model.parameters())
    # 训练5轮
    EPOCH_NUM = 10
    # MNIST图像高和宽
    IMG_ROWS, IMG_COLS = 28, 28

    for epoch_id in range(EPOCH_NUM):
        for batch_id, data in enumerate(train_loader()):
            #准备数据
            images, labels = data
            images = paddle.to_tensor(images)
            labels = paddle.to_tensor(labels)
            
            #前向计算的过程
            predicts = model(images)
            
            #计算损失,取一个批次样本损失的平均值
            loss = F.square_error_cost(predicts, labels)
            avg_loss = paddle.mean(loss)

            #每训练200批次的数据,打印下当前Loss的情况
            if batch_id % 200 == 0:
                print("epoch: {}, batch: {}, loss is: {}".format(epoch_id, batch_id, avg_loss.numpy()))
            
            #后向传播,更新参数的过程
            avg_loss.backward()
            # 最小化loss,更新参数
            opt.step()
            # 清除梯度
            opt.clear_grad()

    #保存模型参数
    paddle.save(model.state_dict(), 'mnist.pdparams')

model = MNIST()
train(model)


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.


报错:
info 22:20:7.826: Got new session 4f3b9038-3ae1-48ba-8a53-322b3c4d2551
info 22:20:7.826: Started new restart session
info 22:20:7.827: Executing silently Code (idle) = import sys\nprint(sys.executable)
info 22:20:7.829: Widget Message: Received IPyWidgetMessages.IPyWidgets_onRestartKernel
info 22:20:7.829: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 22:20:7.829: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 22:20:7.944: Executing silently Code (completed) = import sys\nprint(sys.executable) with 1 output(s)
info 22:20:7.945: UpdateWorkingDirectoryAndPath in Kernel
info 22:20:7.945: Executing silently Code (idle) = import os\nimport sys\n%cd "c:\Users\island\Desktop\Minist"\nif os.getcwd() not in sys.path:\nsys.pa
info 22:20:7.959: Executing silently Code (completed) = import os\nimport sys\n%cd "c:\Users\island\Desktop\Minist"\nif os.getcwd() not in sys.path:\nsys.pa with 1 output(s)
info 22:20:7.960: Waiting for idle on (kernel): 4f3b9038-3ae1-48ba-8a53-322b3c4d2551 -> idle
info 22:20:7.960: Finished waiting for idle on (kernel): 4f3b9038-3ae1-48ba-8a53-322b3c4d2551 -> idle
info 22:20:8.8: Cell 0 executed with state Success
info 22:20:9.94: Cell 1 executed with state Success
info 22:20:9.190: Cell 2 executed with state Success
warn 22:20:9.217: StdErr from Kernel Process W0829 22:20:09.216308  3600 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 11.6, Runtime API Version: 11.6

warn 22:20:9.220: StdErr from Kernel Process W0829 22:20:09.219309  3600 gpu_resources.cc:91] device: 0, cuDNN Version: 8.4.

error 22:20:19.733: Disposing session as kernel process died ExitCode: 3221226505, Reason: c:\Users\island\miniconda3\lib\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
c:\Users\island\miniconda3\lib\site-packages\traitlets\traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '299f680a-8eb5-4783-811b-e46bf7e01555' instead of 'b"299f680a-8eb5-4783-811b-e46bf7e01555"'.
  warn(
W0829 22:20:09.216308  3600 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 8.6, Driver API Version: 11.6, Runtime API Version: 11.6
W0829 22:20:09.219309  3600 gpu_resources.cc:91] device: 0, cuDNN Version: 8.4.

info 22:20:19.733: kill daemon
error 22:20:19.734: Raw kernel process exited code: 3221226505
error 22:20:19.735: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
    at t.KernelShellFutureHandler.dispose (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:32353)
    at c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:51405
    at Map.forEach ()
    at y._clearKernelState (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:51390)
    at y.dispose (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:44872)
    at c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:2320921
    at t.swallowExceptions (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:7:118974)
    at dispose (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:2320899)
    at t.RawSession.dispose (c:\Users\island\.vscode\extensions\ms-toolsai.jupyter-2022.7.1102252217\out\extension.node.js:2:2325836)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)]
warn 22:20:19.736: Cell completed with errors {
  message: 'Canceled future for execute_request message before replies were done'
}
info 22:20:19.737: Cancel all remaining cells true || Error || undefined
info 22:20:19.737: Cancel pending cells
info 22:20:19.737: Cell 3 executed with state Error
info 22:20:19.737: Cell 4 executed with state Idle


```

这应该是你电脑环境的问题,先重启一下,看能否解决问题。实在不行重装paddle,或者到aistudio平台上测试你的代码