How to use CUDA to train your ResNet model

I’m trying to train a large dataset using ResNet34 running 10 epochs and it takes forever. I want to use the GPU for this so I decided to give CUDA a shot. I’ve never used CUDA before so this is also a learning experience for me.

After googling, I saw that people use the @vectorize annotation from the numba package for this so I’ve done the same.

@vectorize(["float32(float32, float32)"], target='cuda')
learn = cnn_learner(data, models.resnet34, metrics=error_rate)

However, I’m getting the following syntax error. I only started getting this error after adding the @vectorize annotation.

learn = cnn_learner(data, models.resnet34, metrics=error_rate)
SyntaxError: invalid syntax

cnn_learner and models.resnet34 are from the library. Here is the entirety of what I’m importing.

from fastai import *
from import *
import os, shutil
from pathlib import Path
from numba import vectorize