Column of arrays (2D+) are using unreasonably high memory
See original GitHub issueDescribe 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:
- Created a year ago
- Reactions:1
- Comments:10 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
note i have tried the same code with
datasets
version 2.4.0, the outcome is the very same as described above.That’s… unfortunate. I didn’t realize that.