Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Google collab I get IOPub data rate exceeded

IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable --NotebookApp.iopub_data_rate_limit.

Current values:

NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec)
NotebookApp.rate_limit_window=3.0 (secs)
like image 698
Raja Avatar asked Jun 04 '18 22:06

Raja


People also ask

What happens when the iopub data rate is exceeded?

IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--NotebookApp.iopub_data_rate_limit`. Current values: NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec) NotebookApp.rate_limit_window=3.0 (secs)

What is iopub error in Colab?

IoPub Error is occurring in Colab because you are trying to display the output on the console itself (Eg. print () statements) which is very large. The IoPub Error maybe related in print function.

Why can't I display a large output in Google Colab?

Given the error, you seem to be hitting a Google Colab-specific limit on the output size. Try printing len (model.wv.vocab) first to get a sense of how large of an output you're trying to display. It may not be practical to show in a notebook cell!

How do I change the data rate limit for the notebook app?

To change this limit, set the config variable `--NotebookApp.iopub_data_rate_limit`. Current values: NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec) NotebookApp.rate_limit_window=3.0 (secs)


2 Answers

An IOPub error usually occurs when you try to print a large amount of data to the console. Check your print statements - if you're trying to print a file that exceeds 10MB, its likely that this caused the error. Try to read smaller portions of the file/data.

I faced this issue while reading a file from Google Drive to Colab. I used this link https://colab.research.google.com/notebook#fileId=/v2/external/notebooks/io.ipynb and the problem was in this block of code

# Download the file we just uploaded.
#
# Replace the assignment below with your file ID
# to download a different file.
#
# A file ID looks like: 1uBtlaggVyWshwcyP6kEI-y_W3P8D26sz
file_id = 'target_file_id'

import io
from googleapiclient.http import MediaIoBaseDownload

request = drive_service.files().get_media(fileId=file_id)
downloaded = io.BytesIO()
downloader = MediaIoBaseDownload(downloaded, request)
done = False
while done is False:
  # _ is a placeholder for a progress object that we ignore.
  # (Our file is small, so we skip reporting progress.)
  _, done = downloader.next_chunk()

downloaded.seek(0)

#Remove this print statement
#print('Downloaded file contents are: {}'.format(downloaded.read()))

I had to remove the last print statement since it exceeded the 10MB limit in the notebook - print('Downloaded file contents are: {}'.format(downloaded.read()))
Your file will still be downloaded and you can read it in smaller chunks or read a portion of the file.

like image 115
Srishti Avatar answered Nov 11 '22 16:11

Srishti


The above answer is correct, I just commented the print statement and the error went away. just keeping it here so someone might find it useful. Suppose u are reading a csv file from google drive just import pandas and add pd.read_csv(downloaded) it will work just fine.

file_id = 'FILEID'

import io
from googleapiclient.http import MediaIoBaseDownload

request = drive_service.files().get_media(fileId=file_id)
downloaded = io.BytesIO()
downloader = MediaIoBaseDownload(downloaded, request)
done = False
while done is False:
  # _ is a placeholder for a progress object that we ignore.
  # (Our file is small, so we skip reporting progress.)
  _, done = downloader.next_chunk()

downloaded.seek(0)
pd.read_csv(downloaded);
like image 26
Abhishek Tripathi Avatar answered Nov 11 '22 14:11

Abhishek Tripathi