DALI icon indicating copy to clipboard operation
DALI copied to clipboard

numpy reader error

Open ksm9413 opened this issue 3 years ago • 1 comments

The following error occurred while loading data to gpu using numpy reader.

Below is the source code and the printed error message.

from nvidia.dali import pipeline_def, fn data_dir = os.path.join(data_dir_2d, 'SER00001') @pipeline_def(batch_size=batch_size, num_threads=1, device_id=0) def pipe_gds(): data = fn.readers.numpy(device='gpu', file_root=data_dir, file_filter='*.npy') return data p = pipe_gds()
p.build() pipe_out = p.run()
data_gds = pipe_out[0].as_cpu().as_array() # as_cpu() to c|opy the data back to CPU memory print(data_gds.shape)

RuntimeError: [/opt/dali/dali/python/backend_impl.cc:752] Assert on "tl.IsDenseTensor()" failed: Tensors in the list must have the same shape

ksm9413 avatar Mar 02 '22 05:03 ksm9413

Hi @ksm9413,

Please check the as_array function documentation. To call it, all tensors in the batch need to have the same shape, otherwise the bach cannot be represented as a single array. Please resize/pad/crop the tensors in the batch or make sure that the input data is uniform in shape.

JanuszL avatar Mar 02 '22 06:03 JanuszL