eGPUs under Linux: an advanced guide
Ubuntu 16.04 LTS for me came installed with a recent Linux kernel (I think it was 4.15). If you don't have the latest kernel you just update it.
@peter_gelderbloem CUDA will most likely not work in a VM like VirtualBox. CUDA requires direct access to the GPU. I did see that a passthrough might be possible with VirtualBox, but (esp on Mac OS) this will probably be a pain to set up and probably not worth it.
However, if you want to try, you can try to emulate the passthrough work done on LXD containers linked below:
Mac OS is Unix based, so the NVidia drivers could be similar on both Mac OS and Linux, but this is a very tenuous assumption. This would only likely work between a host and virtual operating system both on Linux.
I did see direct PCI-E passthrough also being an option, but you would need to figure out how to do that in Mac OS if that is even possible.