Skip to content

Fix Dockerfile, make it more convenient and efficient#603

Open
bitplane wants to merge 2 commits into
neonbjb:mainfrom
bitplane:fix-dockerfile
Open

Fix Dockerfile, make it more convenient and efficient#603
bitplane wants to merge 2 commits into
neonbjb:mainfrom
bitplane:fix-dockerfile

Conversation

@bitplane

Copy link
Copy Markdown
  • Fix env variable bugs that stopped it from building
  • Put the data in docker_data, which is excluded via .gitignore and .dockerignore
  • Add a script to build and run docker
  • Update README.md so it doesn't tell people to mount from /root; make it work from here.
  • Rearrange the steps so we don't need to wait for a full conda or apt update every time there's a source code change
  • Clean up conda after installing, to help keep image sizes down (saves 2gb)
  • Split out the requirements.txt and do pip install -r before adding the code, so we only download from pypi when there's a change to the python deps.
  • Don't use a cache dir for pip, so no junk is created that needs to be cleaned up
  • add the conda activate and cd app part in root's .bashrc so it's ready to go when you log in
  • Exclude *.pyc files and build dirs from the Docker build context, in case the user has been running things outside docker

Rather than relying on things outside the project dir, have a
data dir with all the caches, model files etc, and exclude them from
git and the docker context with the .ignore files.

Also move the install step to last and put it in its own step, so it
doesn't have to rebuild all the slow conda stuff every time there's
a change to a file in the project.
@JonasGruenwald

JonasGruenwald commented Nov 12, 2023

Copy link
Copy Markdown

Thanks for fixing the Dockerfile! Was looking for this because of the env variable issues.
With the current Dockerfile from your PR, I'm getting an interactive Proceed ([y]/n)? prompt at this step:

RUN conda create --name tortoise python=3.9 numba inflect \
    && conda activate tortoise \
    && conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia \
    && conda install transformers=4.29.2 \
    && conda clean --all \
    && echo "conda activate tortoise; cd /app" >> "${HOME}/.bashrc"

Because the commands are all stringed together in a single shell list, I can't really tell which command is going interactive, but it's not create (I checked), so it must be one of the installs or clean.
Anyways I suggest adding -y to those commands to avoid this issue, it worked for me:

RUN conda create -y --name tortoise python=3.9 numba inflect \
    && conda activate tortoise \
    && conda install -y pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia \
    && conda install -y transformers=4.29.2 \
    && conda clean -y --all \
    && echo "conda activate tortoise; cd /app" >> "${HOME}/.bashrc"

@JonasGruenwald

JonasGruenwald commented Nov 12, 2023

Copy link
Copy Markdown

Also, I had to install the NVIDIA container toolkit to be able tor run the image with the --gpus flag, maybe this could be added to the Readme

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html

@manmay-nakhashi

Copy link
Copy Markdown
Collaborator

@bitplane is this working properly ?
can somelese confirms this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants