question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum number of server active requests exceeded. Error while uploading data using EC2.

See original GitHub issue

🐛🐛 Bug Report

Not able to upload data using EC2.

⚗️ Current Behavior

Check screenshot below.

Input Code

import json
import time
import numpy as np
from PIL import Image
from tqdm import tqdm

import hub
from hub import Dataset, schema
from hub.schema import Tensor


mpii_schema = {
    "image": schema.Image(
        shape = (None, None, 3),
         max_shape = (10000, 10000, 3),
          dtype = 'uint8'),
    "isValidation": Tensor(max_shape = (100,), dtype = 'float64'),
    "img_paths": Tensor(max_shape = (100,), dtype = 'float64'), 
    "img_width":Tensor(max_shape = (100,), dtype = 'float64'),
    "img_height": Tensor(max_shape = (100,), dtype = 'float64'),
    "objpos": Tensor(max_shape = (100,), dtype = 'float64'),
    "joint_self": Tensor(
        shape = (None, None),
         max_shape = (100, 100),
          dtype = 'float64'),
    "scale_provided": Tensor(max_shape = (100,), dtype = 'float64'),
    "annolist_index": Tensor(max_shape = (100,), dtype = 'float64'),
    "people_index": Tensor(max_shape = (100,), dtype = 'float64'),
    "numOtherPeople": Tensor(max_shape = (100,), dtype = 'float64'),
}


def get_anno(jsonfile):

    with open(jsonfile) as f:
        instances = json.load(f)    

    annotations = []
    for i in range(len(instances)):
        annotations.append(instances[i])
    return annotations, len(annotations)


def upload_data(tag, schema, anno_shape, img_path, annotations):

    ds = Dataset(tag,
                 mode = 'w+',
                 schema = schema,
                 shape = (anno_shape,),
                 storage_cache = None)

    for i in tqdm(range(anno_shape)):

        ds["image", i] = np.array(Image.open(img_path + annotations[i]['img_paths']))
        ds["isValidation", i] = annotations[i]['isValidation']
        ds["img_paths", i] = annotations[i]['img_paths']
        ds['img_width', i] = annotations[i]['img_width']
        ds["img_height", i] = annotations[i]['img_height']
        ds["objpos", i] = np.array(annotations[i]['objpos'])
        ds["joint_self", i] = np.array(annotations[i]['joint_self'])
        ds["scale_provided", i] = annotations[i]['scale_provided']
        ds["annolist_index", i] = annotations[i]['annolist_index']
        ds["people_index", i] = annotations[i]['people_index']
        ds["numOtherPeople", i] = annotations[i]['numOtherPeople']

        if i % 1000 == 0:
            print(i,"instances uploaded.")
    ds.commit()


if __name__ == "__main__":

    tag = input("Enter tag(username/dataset_name):")
    jsonfile = input("Enter json file path:")
    img_path = input("Enter path to images:")

    annotations, anno_shape = get_anno(jsonfile)
    t1 = time.time()
    upload_data(tag, mpii_schema, anno_shape, img_path, annotations)
    print("Time taken to upload:", (time.time() - t1), "sec")

Expected behavior/code Last checked uploaded till 11k instances. The same code working fine on colab stored all 25k instances(59 GB data) locally.

⚙️ Environment

  • Python version(s):
    • good: [e.g. 3.8]
    • better: [3.8.6 - Clang 12.0.0 (clang-1200.0.32.27)]
  • OS: [e.g. Ubuntu 18.04, OSX 10.13.4, Windows 10]
  • IDE: [Vim, VS-Code, Pycharme]
  • Packages: [ Tensorflow==2.1.2 - latest]

🧰 Possible Solution (optional)

🖼 Additional context/Screenshots (optional)

Add any other context about the problem here. If applicable, add screenshots to help explain. Screenshot (229)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mynameisvinncommented, Dec 11, 2020

I’ve had this issue before with boto. It might be boto’s limitation - I’ll see if there is a known workaround.

0reactions
edogrigqv2commented, Dec 18, 2020

Finally reproduced the error. In forums some point on wasabi not being stable.

Traceback (most recent call last):
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 530, in info
    Key=key, **version_id_kw(version_id), **self.req_kw)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 200, in _call_s3
    return method(**additional_kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (404) when calling the HeadObject operation: Not Found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 394, in _lsdir
    for i in it:
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/paginate.py", line 255, in __iter__
    response = self._make_request(current_kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/paginate.py", line 332, in _make_request
    return self._method(**current_kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (TemporarilyUnavailable) when calling the ListObjectsV2 operation (reached max retries: 4): Maximum number of server active requests exceeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "bugs/mpii_boto_error.py", line 79, in <module>
    doit()
  File "bugs/mpii_boto_error.py", line 70, in doit
    upload_data(tag, mpii_schema, anno_shape, img_path, annotations)
  File "bugs/mpii_boto_error.py", line 46, in upload_data
    ds["image", i] = np.array(Image.open(img_path + annotations[i]["img_paths"]))
  File "/home/eduard/dev/Hub/hub/api/dataset.py", line 354, in __setitem__
    self._tensors[subpath][slice_list] = assign_value
  File "/home/eduard/dev/Hub/hub/store/dynamic_tensor.py", line 220, in __setitem__
    self._storage_tensor[slice_] = value
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1121, in __setitem__
    self.set_basic_selection(selection, value, fields=fields)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1216, in set_basic_selection
    return self._set_basic_selection_nd(selection, value, fields=fields)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1507, in _set_basic_selection_nd
    self._set_selection(indexer, value, fields=fields)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1556, in _set_selection
    self._chunk_setitem(chunk_coords, chunk_selection, chunk_value, fields=fields)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1704, in _chunk_setitem
    fields=fields)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/zarr/core.py", line 1734, in _chunk_setitem_nosync
    cdata = self.chunk_store[ckey]
  File "/home/eduard/dev/Hub/hub/store/metastore.py", line 30, in __getitem__
    return self._fs_map[k]
  File "/home/eduard/dev/Hub/hub/store/lru_cache.py", line 87, in __getitem__
    result = self._actual_storage[key]
  File "/home/eduard/dev/Hub/hub/store/store.py", line 138, in __getitem__
    return self._map[slice_]
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/mapping.py", line 132, in __getitem__
    result = self.fs.cat(k)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/spec.py", line 684, in cat
    return self.cat_file(paths[0])
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/spec.py", line 626, in cat_file
    return self.open(path, "rb").read()
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/spec.py", line 903, in open
    **kwargs
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 378, in _open
    autocommit=autocommit, requester_pays=requester_pays)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 1097, in __init__
    cache_type=cache_type)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/spec.py", line 1224, in __init__
    self.details = fs.info(path)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 546, in info
    return super(S3FileSystem, self).info(path)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/fsspec/spec.py", line 577, in info
    out = self.ls(self._parent(path), detail=True, **kwargs)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 619, in ls
    files = self._ls(path, refresh=refresh)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 487, in _ls
    return self._lsdir(path, refresh)
  File "/home/eduard/dev/Hub/venv/lib/python3.6/site-packages/s3fs/core.py", line 409, in _lsdir
    raise translate_boto_error(e)
OSError: [Errno 5] An error occurred (TemporarilyUnavailable) when calling the ListObjectsV2 operation (reached max retries: 4): Maximum number of server active requests exceeded
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error codes for the Amazon EC2 API - AWS Documentation
These errors are usually caused by an AWS server-side issue. ... The maximum number of concurrent CreateImage requests for the instance has been...
Read more >
Account and limit settings - GitLab Docs
On the left sidebar, select Settings > General, then expand Account and limit. Increase or decrease by changing the value in Maximum export...
Read more >
S3 Error: The difference between the request time and the ...
The time on your local box is out of sync with the current time. Sync up your system clock and the problem will...
Read more >
What is the maximum number of instances that I can have ...
Answer. By default, when you create an EC2 account with Amazon, your account is limited to a maximum of 20 instances per EC2...
Read more >
Configuration properties | Bitbucket Data Center and Server 8.6
Maximum number of audit event rows stored in DB, events exceeding the ... If an error occurs while retrieving the SSO configuration from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found