Can I train a Convolutional Neural Network optimized to AMD GPU

Can I train an optimized CNN on AMD GPU?

Hey John,

Most DL frameworks (including PyTorch and fastai) rely on CUDA, which only works with NVIDIA GPUs. There is some work in progress to improve the state of GPU acceleration for AMD, but currently it’s nowhere near as good as CUDA - so the bottom line is no, you cannot do so with fastai and I don’t think AMD GPUs will be competitive with NVIDIA for deep learning any time soon.

2 Likes

Q: Can I train an optimized CNN on AMD GPU?:
A: Yes, but not with fastai. (there is a pytorch compiled with ROC support somewhere)

1 Like

How ? Thanks

I would say the easiest way to do it is spin up a docker image with the software installed from AMD.
I got fast ai running on my desktop with an AMD RX 6900 XT running inside a docker container with rocm installed. I followed amd’s instructions here: AMD Documentation - Portal
I started the container with a --net host argument to pass the notebook server through to my host machine

docker run --net=host -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --device=/dev/kfd --device=/dev/dri --group-add video --ipc=host --shm-size 8G rocm/pytorch:latest

that got it up, once inside I cloned into fastbook and pip installed the requirements. I opened a python interpreter and imported torch and checked that cuda.is_available and it was so that was a success.
I ran into a weird issue with the python installed in the container and the fastai site package. When I ran any notebook, it said that there was a formatting issue with a progress.py function and after some googling, it looks like f strings weren’t supported with pytorch at sometime so I changed the f strings in /opt/conda/lib/python3.8/site-packages/fastai callback/progress.py and in core.py of fastai to be ‘{}’.format() and that seemed to work. I don’t know if that’s an issue other people have run into though. I just was up late tonight tinkering and thought I could get rocm pytorch running on my 6900xt. it’s not nearly as fast as the kaggle gpus but it was a fun project to try.

1 Like

That’s great!
I too was wondering if PS5 GPU could be leveraged for training models.