My kernel keeps crashing when importing pipeline

I am trying to import pipeline to use on a NLP project, when I run:
from transformers import pipeline

Kernal dies

3 Likes

I am having the same problem too. I have done all the solution that are on net but seems not to work

2 Likes

do you mean when create a new pipeline the app crashes?
i have run into this in electron too, then i use below code to detect the problem

const { spawn } = require('child_process');

// Change stdio configuration to capture stdout and stderr
const childProcess = spawn(process.execPath, [
  path.join('url-to-your-script.js')
], {
  stdio: ['inherit', 'pipe', 'pipe'],
});

// Add error handling
childProcess.on('error', (error) => {
  console.error(`Failed to start child process: ${error.message}`);
});
// Capture and log stderr
childProcess.stderr.on('data', (data) => {
  const error = data.toString().trim();
  console.error(`Child stderr: ${error}`);
  
  // You can also send errors to your renderer process
  // mainWindow.webContents.send('model-error', error);
});

// Handle unexpected exits
childProcess.on('close', (code, signal) => {
  if (code !== 0) {
    console.error(`Child process exited with code ${code} and signal ${signal}`);
  } else {
    console.log(`Child process completed successfully`);
  }
});

if exited with SIGTRAP, probably because an error during memory allocation. but i don’t know how to fix in electron app

1 Like

It seems to be quite rare, but it may occur relatively often in the Jupyter Notebook environment.
https://stackoverflow.com/questions/71024254/jupyter-kernel-dies-when-importing-pipeline-function-from-transformers-class-on