UPDATE 2024: I've updated this post to be based on the nvcr.io/nvidia/pytorch image, which I always use these days because of its great NVIDIA + NCCL + Infiniband support. I also simplified the file and modified it to use gom for GPU monitoring.
This post is mainly meant for coworkers, but it might be useful for others as well. I'll be sharing the Dockerfile that I use to set up my machine learning environment. It's based on NVIDIA's pytorch image, but I've added a few things (upgraded Pip packages, GitHub CLI, Starship prompt, GPU monitoring, etc.) that I find useful.
Setup
Copy and paste the below Dockerfile to a new directory. Feel free to add or remove anything you want — I'll likely update this post as I make changes to my setup.
Building the Image
After you've created the files, you can build the image with:
Running the Image
You can run the image with:
If you liked this article, don't forget to share it and follow me at @nebrelbug on X!