-
-
Save anjilinux/28cae31b6164bbb9856dee067b2256e5 to your computer and use it in GitHub Desktop.
Revisions
-
hidetatz revised this gist
Nov 11, 2023 . 1 changed file with 8 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,10 +13,11 @@ This is a Dockerfile and Makefile for me to setup Python3.11 + Poetry + Pytorch 2. Install nvidia-container-toolkit on the host. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html 3. Install nvidia gpu driver on the host. https://ubuntu.com/server/docs/nvidia-drivers-installation 4. Create a directory for your project and copy-paste Dockerfile and Makefile 5. Run: `make build`. 6. Run: `make run` to jump into the container. 7. Run: `poetry init -q` in the container. 8. Run: `poetry add numpy` or something else in the container to add some dependencies in the pyproject.toml. 9. Press Ctrl-d to get back to the host. 10. Write some code. 11. To rebuild container, run `make build`. 12. Run: `make ps` on the host and `python main.py` or something in the container. -
hidetatz created this gist
Nov 11, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04 ENV NVIDIA_VISIBLE_DEVICES=all ENV NVIDIA_DRIVER_CAPABILITIES=all ENV DEBIAN_FRONTEND=noninteractive # configure locale ENV LANG en_US.UTF-8 ENV LANGUAGE en_US:en ENV LC_ALL en_US.UTF-8 ENV TZ=Asia/Tokyo RUN apt-get update && apt-get install -y --no-install-recommends locales tzdata && \ sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen # configure user and group RUN apt-get update && apt-get install --no-install-recommends -y sudo && \ groupadd -g 1000 gwhale && \ useradd -m -s /bin/bash -u 1000 -g 1000 -G sudo whale && \ echo whale:password | chpasswd && \ echo "whale ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers USER whale # install basic stuff RUN sudo apt update && sudo apt install --no-install-recommends -y \ build-essential curl git less make nano openssh-client ssh software-properties-common vim wget \ libopencv-dev libcurl4-openssl-dev libssl-dev ffmpeg WORKDIR /home/whale/tmp # install python and poetry RUN sudo apt install --no-install-recommends -y \ build-essential libbz2-dev libdb-dev \ libreadline-dev libffi-dev libgdbm-dev liblzma-dev \ libncursesw5-dev libsqlite3-dev libssl-dev \ zlib1g-dev uuid-dev tk-dev RUN wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tar.xz && \ tar xJf Python-3.11.6.tar.xz && \ cd Python-3.11.6 && \ ./configure && make && sudo make install RUN curl -sSL https://install.python-poetry.org | python3 - ENV PATH="/home/whale/.local/bin:${PATH}" WORKDIR /home/whale/work COPY pyproject.toml . RUN poetry install This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ # build docker container .PHONY: build build: docker build -t dev . .PHONY: run run: docker run -it --gpus all -e SHELL="/bin/bash" -v ./:/home/whale/work dev -- bash # poetry shell .PHONY: ps ps: docker run -it --gpus all -e SHELL="/bin/bash" -v ./:/home/whale/work dev -- bash -c "poetry shell" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ ## What's this? This is a Dockerfile and Makefile for me to setup Python3.11 + Poetry + Pytorch environment on docker container. ## Prerequisites 1. The host is Ubuntu. 2. Has GPU. ## Usage 1. Install docker on the host. https://docs.docker.com/engine/install/ 2. Install nvidia-container-toolkit on the host. https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html 3. Install nvidia gpu driver on the host. https://ubuntu.com/server/docs/nvidia-drivers-installation 4. Create a directory for your project and copy-paste Dockerfile and Makefile 5. Run: `make build` 6. Run: `make run` to jump into the container 7. Run: `poetry init -q` in the container 8. Run: `poetry add numpy` or something else in the container 9. Press Ctrl-d to get back to the host 10. Write some code 11. Run: `make ps` on the host and `python main.py` or something in the host