Unable to use predict_array on image due to CUDA not enabled

Hi everyone,
I have trained cats vs dogs model on fastai GPU instance on aws and then when i tried to use the model on my machine (mac OS) to predict an image class predict_array doesn’t seem to work due to this error Torch not compiled with CUDA enabled

 img = cv2.imread('dog.jpg')
 _, img_encoded = cv2.imencode('.jpg', img)
 nparr = np.fromstring(img_encoded.tostring(), np.uint8)
 flags = cv2.IMREAD_UNCHANGED+cv2.IMREAD_ANYDEPTH+cv2.IMREAD_ANYCOLOR
 image = cv2.cvtColor(cv2.imdecode(nparr, flags).astype(np.float32) / 255, cv2.COLOR_BGR2RGB)
 image = val_tfms(image)
 preds = learn.predict_array(image[None])

Does anyone know how to solve this in able to run prediction on cpu ?

Sounds like you may not have the latest fastai from git.

I installed it via pip ! should i upgrade the library with pip ?

The fastai version installed via pip will trail that available via Github. So I’d recommend (and Jeremy did somewhere else) to install and pull directly from Github.

It worked with cpu environment installation thanks :wink: