Why is Google Colab running equally slow when using a GPU and CPU with FastAI?

Viewed 145

I am using Google Colab with FastAI for a tabular data classification problem. I have preprocessed my data into a csv with 13 columns and 66,000 rows (including independent and dependent variables). The csv is approximately 250mB in size. I read that importing the csv from google drive is very slow and this is indeed the case. So instead, I placed the csv in a zip folder within google drive and unzip it directly into Colabs memory (I saw this as a recommendation on various other posts):

!unzip "/content/gdrive/MyDrive/Colab Notebooks/data/data.zip" -d "/content"

I then load the unzipped data as follows:

path = '/content/data/technical_candles.csv'  # google colab
all_data_df = pd.read_csv(path)

The csv now loads into memory very quickly.

Now on to building my model. First I define the data split:

splits = EndSplitter(valid_pct=0.2, valid_last=True)(range_of(data_df))

Secondly, I define some of the variables and processing techniques:

category_names = ['X', 'Y', 'Z']
continuous_names = list(set(data_df.columns[3:]) - set(category_names))
data_procs = [Categorify, FillMissing, Normalize]

Then defining the dataloader and learner:

to = TabularPandas(data_df, procs=data_procs,
               cat_names = category_names,
               cont_names = continuous_names,
               y_names='decision',
               splits=splits,
               y_block = CategoryBlock)

dls = to.dataloaders(bs=64)

learn = tabular_learner(dls, metrics=accuracy)

Finally, using the fit_one_cycle from FastAI:

learn.fit_one_cycle(10)

Each epoch takes approximately 9-12 seconds to run with the CPU and exactly 11 seconds with the GPU. I can confirm that the GPU runtime is selected and confirmed by running:

torch.cuda.is_available()

This returns true when I use a runtime type with a GPU and False when I use the CPU as expected.

Any idea why the training time for the GPU and CPU is similar? I'd like to eventually run hundreds of epochs so I was hoping the GPU would provide better performance. Any help would be appreciated.

0 Answers
Related