This is a Dockerfile and Makefile for me to setup Python3.11 + Poetry + Pytorch environment on docker container.
- The host is Ubuntu.
- Has GPU.
- Install docker on the host. https://docs.docker.com/engine/install/
- Install nvidia-container-toolkit on the host. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
- Install nvidia gpu driver on the host. https://ubuntu.com/server/docs/nvidia-drivers-installation
- Create a directory for your project and copy-paste Dockerfile and Makefile
- Run:
make build. - Run:
make runto jump into the container. - Run:
poetry init -qin the container. - Run:
poetry add numpyor something else in the container to add some dependencies in the pyproject.toml. - Press Ctrl-d to get back to the host.
- Write some code.
- To rebuild container, run
make build. - Run:
make pson the host andpython main.pyor something in the container.