forked from ashawkey/stable-dreamfusion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ashawkey#22 from Supercabb/docker-image
Docker image
- Loading branch information
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04 | ||
|
||
# Remove any third-party apt sources to avoid issues with expiring keys. | ||
RUN rm -f /etc/apt/sources.list.d/*.list | ||
|
||
RUN apt-get update | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/MADRID apt-get install -y tzdata | ||
|
||
# Install some basic utilities | ||
RUN apt-get install -y \ | ||
curl \ | ||
ca-certificates \ | ||
sudo \ | ||
git \ | ||
bzip2 \ | ||
libx11-6 \ | ||
python3 \ | ||
python3-pip \ | ||
libglfw3-dev \ | ||
libgles2-mesa-dev \ | ||
libglib2.0-0 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# Create a working directory | ||
RUN mkdir /app | ||
WORKDIR /app | ||
|
||
RUN cd /app | ||
RUN git clone https://github.com/ashawkey/stable-dreamfusion.git | ||
|
||
|
||
RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 | ||
|
||
WORKDIR /app/stable-dreamfusion | ||
|
||
RUN pip3 install -r requirements.txt | ||
RUN pip3 install git+https://github.com/NVlabs/nvdiffrast/ | ||
|
||
# Needs nvidia runtime, if you have "No CUDA runtime is found" error: https://stackoverflow.com/questions/59691207/docker-build-with-nvidia-runtime, first answer | ||
RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch | ||
|
||
RUN pip3 install git+https://github.com/openai/CLIP.git | ||
RUN bash scripts/install_ext.sh | ||
|
||
|
||
|
||
|
||
|
||
# Set the default command to python3 | ||
#CMD ["python3"] | ||
|
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
### Docker installation | ||
|
||
## Build image | ||
To build the docker image on your own machine, which may take 15-30 mins: | ||
``` | ||
docker build -t stable-dreamfusion:latest . | ||
``` | ||
|
||
If you have the error **No CUDA runtime is found** when building the wheels for tiny-cuda-nn you need to setup the nvidia-runtime for docker. | ||
``` | ||
sudo apt-get install nvidia-container-runtime | ||
``` | ||
Then edit `/etc/docker/daemon.json` and add the default-runtime: | ||
``` | ||
{ | ||
"runtimes": { | ||
"nvidia": { | ||
"path": "nvidia-container-runtime", | ||
"runtimeArgs": [] | ||
} | ||
}, | ||
"default-runtime": "nvidia" | ||
} | ||
``` | ||
And restart docker: | ||
``` | ||
sudo systemctl restart docker | ||
``` | ||
Now you can build tiny-cuda-nn inside docker. | ||
|
||
## Download image | ||
To download the image (~6GB) instead: | ||
``` | ||
docker pull supercabb/stable-dreamfusion:3080_0.0.1 | ||
docker tag supercabb/stable-dreamfusion:3080_0.0.1 stable-dreamfusion | ||
``` | ||
|
||
## Use image | ||
|
||
You can launch an interactive shell inside the container: | ||
|
||
``` | ||
docker run --gpus all -it --rm -v $(cd ~ && pwd):/mnt stable-dreamfusion /bin/bash | ||
``` | ||
From this shell, all the code in the repo should work. | ||
|
||
To run any single command `<command...>` inside the docker container: | ||
``` | ||
docker run --gpus all -it --rm -v $(cd ~ && pwd):/mnt stable-dreamfusion /bin/bash -c "<command...>" | ||
``` | ||
To train: | ||
``` | ||
export TOKEN="#HUGGING FACE ACCESS TOKEN#" | ||
docker run --gpus all -it --rm -v $(cd ~ && pwd):/mnt stable-dreamfusion /bin/bash -c "echo ${TOKEN} > TOKEN \ | ||
&& python3 main.py --text \"a hamburger\" --workspace trial -O" | ||
``` | ||
Run test without gui: | ||
``` | ||
export PATH_TO_WORKSPACE="#PATH_TO_WORKSPACE#" | ||
docker run --gpus all -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $(cd ~ && pwd):/mnt \ | ||
-v $(cd ${PATH_TO_WORKSPACE} && pwd):/app/stable-dreamfusion/trial stable-dreamfusion /bin/bash -c "python3 \ | ||
main.py --workspace trial -O --test" | ||
``` | ||
Run test with gui: | ||
``` | ||
export PATH_TO_WORKSPACE="#PATH_TO_WORKSPACE#" | ||
xhost + | ||
docker run --gpus all -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:ro -v $(cd ~ && pwd):/mnt \ | ||
-v $(cd ${PATH_TO_WORKSPACE} && pwd):/app/stable-dreamfusion/trial stable-dreamfusion /bin/bash -c "python3 \ | ||
main.py --workspace trial -O --test --gui" | ||
xhost - | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|