GitHub issue #3618: TIMIT Dataset not working with GPU
State: closed | Created: 2022-01-24T03:26:03Z

## Describe the bug
I am working trying to use the TIMIT dataset in order to fine-tune Wav2Vec2 model and I am unable to load the "audio" column from the dataset when working with a GPU. 

I am working on Amazon Sagemaker Studio, on the Python 3 (PyTorch 1.8 Python 3.6 GPU Optimized) environment, with a single ml.g4dn.xlarge instance (corresponds to a Tesla T4 GPU). 

I don't know if the issue is GPU related or Python environment related because everything works when I work off of the CPU Optimized environment with a non-GPU instance. My code also works on Google Colab with a GPU instance. 

This issue is blocking because I cannot get the 'audio' column in any way due to this error, which means that I can't pass it to any functions. I later use the dataset.map function and that is where I originally noticed this error. 

## Steps to reproduce the bug
```python
from datasets import load_dataset

timit_train = load_dataset('timit_asr', split='train')
print(timit_train['audio'])
```

## Expected results
Expected to see inside the 'audio' column, which contains an 'array' nested field with the array data I actually need.

## Actual results

Traceback
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-ceeac555e921> in <module>
----> 1 timit_train['audio']

/opt/conda/lib/python3.6/site-packages/datasets/arrow_dataset.py in __getitem__(self, key)
   1917         """Can be used to index columns (by string names) or rows (by integer index or iterable of indices or bools)."""
   1918         return self._getitem(
-> 1919             key,
   1920         )
   1921 

/opt/conda/lib/python3.6/site-packages/datasets/arrow_dataset.py in _getitem(self, key, decoded, **kwargs)
   1902         pa_subtable = query_table(self._data, key, indices=self._indices if self._indices is not None else None)
   1903         formatted_output = format_table(
-> 1904             pa_subtable, key, formatter=formatter, format_columns=format_columns, output_all_columns=output_all_columns
   1905         )
   1906         return formatted_output

/opt/conda/lib/python3.6/site-packages/datasets/formatting/formatting.py in format_table(table, key, formatter, format_columns, output_all_columns)
    529     python_formatter = PythonFormatter(features=None)
    530     if format_columns is None:
--> 531         return formatter(pa_table, query_type=query_type)
    532     elif query_type == "column":
    533         if key in format_columns:

/opt/conda/lib/python3.6/site-packages/datasets/formatting/formatting.py in __call__(self, pa_table, query_type)
    280             return self.format_row(pa_table)
    281         elif query_type == "column":
--> 282             return self.format_column(pa_table)
    283         elif query_type == "batch":
    284             return self.format_batch(pa_table)

/opt/conda/lib/python3.6/site-packages/datasets/formatting/formatting.py in format_column(self, pa_table)
    315         column = self.python_arrow_extractor().extract_column(pa_table)
    316         if self.decoded:
--> 317             column = self.python_features_decoder.decode_column(column, pa_table.column_names[0])
    318         return column
    319 

/opt/conda/lib/python3.6/site-packages/datasets/formatting/formatting.py in decode_column(self, column, column_name)
    221 
    222     def decode_column(self, column: list, column_name: str) -> list:
--> 223         return self.features.decode_column(column, column_name) if self.features else column
    224 
    225     def decode_batch(self, batch: dict) -> dict:

/opt/conda/lib/python3.6/site-packages/datasets/features/features.py in decode_column(self, column, column_name)
   1337         return (
   1338             [self[column_name].decode_example(value) if value is not None else None for value in column]
-> 1339             if self._column_requires_decoding[column_name]
   1340             else column
   1341         )

/opt/conda/lib/python3.6/site-packages/datasets/features/features.py in <listcomp>(.0)
   1336         """
   1337         return (
-> 1338             [self[column_name].decode_example(value) if value is not None else None for value in column]
   1339             if self._column_requires_decoding[column_name]
   1340             else column

/opt/conda/lib/python3.6/site-packages/datasets/features/audio.py in decode_example(self, value)
     85             dict
     86         """
---> 87         path, file = (value["path"], BytesIO(value["bytes"])) if value["bytes"] is not None else (value["path"], None)
     88         if path is None and file is None:
     89             raise ValueError(f"An audio sample should have one of 'path' or 'bytes' but both are None in {value}.")

TypeError: string indices must be integers
```

## Environment info
<!-- You can run the command `datasets-cli env` and copy-and-paste its output below. -->
- `datasets` version: 1.18.0
- Platform: Linux-4.14.256-197.484.amzn2.x86_64-x86_64-with-debian-buster-sid
- Python version: 3.6.13
- PyArrow version: 6.0.1