jpujol commited on
Commit
465fbc2
1 Parent(s): d718cf7

- Add docker image.

Browse files

Signed-off-by: jpujol <jpujol@picvisa.com>

Files changed (2) hide show
  1. docker/Dockerfile +53 -0
  2. docker/README.md +75 -0
docker/Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.6.2-cudnn8-devel-ubuntu20.04
2
+
3
+ # Remove any third-party apt sources to avoid issues with expiring keys.
4
+ RUN rm -f /etc/apt/sources.list.d/*.list
5
+
6
+ RUN apt-get update
7
+
8
+ RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/MADRID apt-get install -y tzdata
9
+
10
+ # Install some basic utilities
11
+ RUN apt-get install -y \
12
+ curl \
13
+ ca-certificates \
14
+ sudo \
15
+ git \
16
+ bzip2 \
17
+ libx11-6 \
18
+ python3 \
19
+ python3-pip \
20
+ libglfw3-dev \
21
+ libgles2-mesa-dev \
22
+ libglib2.0-0 \
23
+ && rm -rf /var/lib/apt/lists/*
24
+
25
+
26
+ # Create a working directory
27
+ RUN mkdir /app
28
+ WORKDIR /app
29
+
30
+ RUN cd /app
31
+ RUN git clone https://github.com/ashawkey/stable-dreamfusion.git
32
+
33
+
34
+ RUN pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
35
+
36
+ WORKDIR /app/stable-dreamfusion
37
+
38
+ RUN pip3 install -r requirements.txt
39
+ RUN pip3 install git+https://github.com/NVlabs/nvdiffrast/
40
+
41
+ # Needs nvidia runtime, if you have "No CUDA runtime is found" error: https://stackoverflow.com/questions/59691207/docker-build-with-nvidia-runtime, first answer
42
+ RUN pip3 install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
43
+
44
+ RUN pip3 install git+https://github.com/openai/CLIP.git
45
+ RUN bash scripts/install_ext.sh
46
+
47
+
48
+
49
+
50
+
51
+ # Set the default command to python3
52
+ #CMD ["python3"]
53
+
docker/README.md ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Docker installation
2
+
3
+ ## Build image
4
+ To build the docker image on your own machine, which may take 15-30 mins:
5
+ ```
6
+ docker build -t stable-dreamfusion:latest .
7
+ ```
8
+
9
+ 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.
10
+ ```
11
+ sudo apt-get install nvidia-container-runtime
12
+ ```
13
+ Then edit ` and add the default-runtime:
14
+ ```
15
+ {
16
+ "runtimes": {
17
+ "nvidia": {
18
+ "path": "nvidia-container-runtime",
19
+ "runtimeArgs": []
20
+ }
21
+ },
22
+ "default-runtime": "nvidia"
23
+ }
24
+ ```
25
+ And restart docker:
26
+ ```
27
+ sudo systemctl restart docker
28
+ ```
29
+ Now you can build tiny-cuda-nn inside docker.
30
+
31
+ ## Download image
32
+ To download the image (~6GB) instead:
33
+ ```
34
+ docker pull supercabb/stable-dreamfusion:3080_0.0.1
35
+ docker tag supercabb/stable-dreamfusion:3080_0.0.1 stable-dreamfusion
36
+ ```
37
+
38
+ ## Use image
39
+
40
+ You can launch an interactive shell inside the container:
41
+
42
+ ```
43
+ docker run --gpus all -it --rm -v $(cd ~ && pwd):/mnt stable-dreamfusion /bin/bash
44
+ ```
45
+ From this shell, all the code in the repo should work.
46
+
47
+ To run any single command `<command...>` inside the docker container:
48
+ ```
49
+ docker run --gpus all -it --rm -v $(cd ~ && pwd):/mnt stable-dreamfusion /bin/bash -c "<command...>"
50
+ ```
51
+ To train:
52
+ ```
53
+ export TOKEN="#HUGGING FACE ACCESS TOKEN#"
54
+ 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"
55
+
56
+ ```
57
+ Run test without gui:
58
+ ```
59
+ export PATH_TO_WORKSPACE="#PATH_TO_WORKSPACE#"
60
+ 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"
61
+ ```
62
+ Run test with gui:
63
+ ```
64
+ export PATH_TO_WORKSPACE="#PATH_TO_WORKSPACE#"
65
+ xhost +
66
+ 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"
67
+ xhost -
68
+ ```
69
+
70
+
71
+
72
+
73
+
74
+
75
+