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.

Column of arrays (2D+) are using unreasonably high memory

See original GitHub issue

Describe the bug

When trying to store Array2D, Array3D, etc as column values in a dataset, accessing that column (or creating depending on how you create it, see code below) will cause more than 10 fold of memory usage.

Steps to reproduce the bug

from datasets import Dataset, Features, Array2D, Array3D
import numpy as np

column_name = "a"
array_shape = (64, 64, 3)

data = np.random.random((10000,) + array_shape)
dataset = Dataset.from_dict({column_name: data}, features=Features({column_name: Array3D(shape=array_shape, dtype="float64")}))

the code above will use about 10Gb of RAM while constructing the dataset object.

The code below will use roughly the same amount of memory (and time) when trying to actually access the data itself of that column.

from datasets import Dataset
import numpy as np

column_name = "a"
array_shape = (64, 64, 3)

data = np.random.random((10000,) + array_shape)
dataset = Dataset.from_dict({column_name: data})
dataset[column_name]

Expected results

Some memory overhead, but not like as it is now and certainly not an overhead of such runtime that is currently happening.

Actual results

Enormous memory- and runtime overhead.

Environment info

  • datasets version: 2.3.2
  • Platform: macOS-12.5.1-arm64-arm-64bit
  • Python version: 3.8.13
  • PyArrow version: 9.0.0
  • Pandas version: 1.4.4

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
vigsterkrcommented, Sep 10, 2022

note i have tried the same code with datasets version 2.4.0, the outcome is the very same as described above.

0reactions
Slater-Victoroffcommented, Sep 22, 2022

That’s… unfortunate. I didn’t realize that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

2D array using dynamic memory allocation error - c++
Your problem is here: for(i=0;i<a;i++){ // iterate through rows (b) not columns (a) ptr[i] = new int[i]; // you should allocate memory with...
Read more >
Resolve "Out of Memory" Errors - MATLAB & Simulink
When your code operates on large amounts of data or does not use memory efficiently, MATLAB ® might produce an error in response...
Read more >
Two-Dimensional Arrays
Two-dimensional (2D) arrays are indexed by two subscripts, one for the row and one for the column. Each element in the 2D array...
Read more >
EP1265248A2 - Addressing a cross-point diode memory array ...
Because of the price it is generally unreasonable to use Flash memory storage ... The memory array comprises a regular matrix of column...
Read more >
NEC Corp. v. Hyundai Electronics Industries Co., 30 F. Supp. 2d 546 ...
The cells are connected to the circuitry outside the memory array through a ... memory cell can be accessed by presenting the DRAM...
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