I think you should switch from macOS to any linux of your choice if you want to use pytorch in a docker, because docker on a mac runs in a kind of virtual machine with no direct access to the gpus. You can install pytorch normaly, but on a mac the nvidia driver is not well supported. It is much easier to use pytorch on a linux system.