Closed Gigabyte0x1337 closed 2 years ago
This worked for me on an ubuntu host with CUDA 11.4 but YMMV. It does not yet run the GUI tho, if anybody wants to add that please contribute! (i think you can volume mount the x socket but the image might need some other libs too). You can also skip the colmap stuff if you don't want colmap.
(edit remove nproc from build command not needed)
# If you don't build this image, you can start from the base image and just run the commands manually:
# $ docker run --runtime=nvidia --name=my-instant-ngp -it -d --net=host -v`pwd`:/opt/instant-ngp:z -w /opt/instant-ngp -v/:/outer_root pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel sleep infinity
# then $ docker exec -it my-instant-ngp bash
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel
ENV PYTHONDONTWRITEBYTECODE 1
## General, instant-ngp doesn't use everything
RUN \
apt-get update && \
apt-get install -y python3 python3-pip unzip && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libopencv-dev && \
apt-get install -y \
wget unzip git vim less sudo curl unzip
## CMake >=3.19 required for instant-ngp. There's no package for base image so compile from source
RUN \
apt-get update && apt-get install -y libssl-dev && \
mkdir -p /opt/cmake && \
cd /opt/cmake && \
wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz && \
tar xvfz cmake-3.22.1.tar.gz && \
cd cmake-3.22.1 && \
./bootstrap && make -j && sudo make install && \
cmake --version
## COLMAP
RUN \
apt-get install -y \
libatlas-base-dev libsuitesparse-dev build-essential libeigen3-dev libgflags-dev libgoogle-glog-dev
RUN \
cd /opt && \
(git clone https://github.com/ceres-solver/ceres-solver || true) && \
cd ceres-solver && \
git checkout 2.0.0 && \
mkdir -p build && cd build && \
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF && \
make -j && \
make install
RUN \
apt-get install -y \
git \
cmake \
build-essential \
libboost-all-dev \
libeigen3-dev \
libsuitesparse-dev \
libfreeimage-dev \
libgoogle-glog-dev \
libgflags-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-qt5-dev \
libcgal-dev
RUN \
cd /opt && \
(git clone https://github.com/colmap/colmap || true) && \
cd colmap && \
git checkout 3.6 && \
mkdir -p build && cd build && \
cmake .. && \
make -j && \
make install && \
colmap -h
## instant-ngp
RUN apt-get install -y build-essential git \
python3-dev python3-pip libopenexr-dev \
libglfw3-dev libglew-dev libomp-dev \
libxinerama-dev libxcursor-dev libxi-dev
RUN apt-get install -y ffmpeg
RUN pip3 install imageio-ffmpeg imageio
# For whatever reason, the instant-ngp build can't find cuda w/out this stuff despite the canonical paths looking OK
ENV PATH /usr/local/cuda-11.3/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH
# Note!!! change this if you don't have 30x series GPU
ENV TCNN_CUDA_ARCHITECTURES 86
RUN \
cd /opt && \
git clone --recursive https://github.com/NVlabs/instant-ngp && \
cd instant-ngp && \
pip3 install -r requirements.txt && \
cmake . -B build && \
cmake --build build --config RelWithDebInfo -j --target all && \
python3 scripts/run.py --help
Hello, I am having difficulty with the Dockerfile. Specifically, I get:
make: *** No rule to make target '255'. Stop.
after the build (i.e. the cmake --build build --config RelWithDebInfo -j --target all
nproc`) is complete:
...
[ 92%] Built target ngp
[ 96%] Building CUDA object CMakeFiles/testbed.dir/src/main.cu.o
[ 96%] Building CUDA object CMakeFiles/pyngp.dir/src/python_api.cu.o
[ 98%] Linking CXX executable testbed
[ 98%] Built target testbed
[100%] Linking CXX shared library pyngp.cpython-37m-x86_64-linux-gnu.so
[100%] Built target pyngp
make: *** No rule to make target '255'. Stop.
My Dockerfile is almost exactly the same as the one above:
# If you don't build this image, you can start from the base image and just run the commands manually:
# $ docker run --runtime=nvidia --name=my-instant-ngp -it -d --net=host -v`pwd`:/opt/instant-ngp:z -w /opt/instant-ngp -v/:/outer_root pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel sleep infinity
# then $ docker exec -it my-instant-ngp bash
FROM pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel
ENV PYTHONDONTWRITEBYTECODE 1
## General, instant-ngp doesn't use everything
RUN \
apt-get update && \
apt-get install -y python3 python3-pip unzip && \
DEBIAN_FRONTEND=noninteractive apt-get install -y libopencv-dev && \
apt-get install -y \
wget unzip git vim less sudo curl unzip
## CMake >=3.19 required for instant-ngp. There's no package for base image so compile from source
RUN \
apt-get update && apt-get install -y libssl-dev && \
mkdir -p /opt/cmake && \
cd /opt/cmake && \
wget https://github.com/Kitware/CMake/releases/download/v3.22.1/cmake-3.22.1.tar.gz && \
tar xvfz cmake-3.22.1.tar.gz && \
cd cmake-3.22.1 && \
./bootstrap && make -j && sudo make install && \
cmake --version
## COLMAP
RUN \
apt-get install -y \
libatlas-base-dev libsuitesparse-dev build-essential libeigen3-dev libgflags-dev libgoogle-glog-dev
RUN \
cd /opt && \
(git clone https://github.com/ceres-solver/ceres-solver || true) && \
cd ceres-solver && \
git checkout 2.0.0 && \
mkdir -p build && cd build && \
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF && \
make -j && \
make install
RUN \
apt-get install -y \
git \
cmake \
build-essential \
libboost-all-dev \
libeigen3-dev \
libsuitesparse-dev \
libfreeimage-dev \
libgoogle-glog-dev \
libgflags-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-qt5-dev \
libcgal-dev
RUN \
cd /opt && \
(git clone https://github.com/colmap/colmap || true) && \
cd colmap && \
git checkout 3.6 && \
mkdir -p build && cd build && \
cmake .. && \
make -j && \
make install && \
colmap -h
## instant-ngp
RUN apt-get install -y build-essential git \
python3-dev python3-pip libopenexr-dev \
libglfw3-dev libglew-dev libomp-dev \
libxinerama-dev libxcursor-dev libxi-dev
RUN apt-get install -y ffmpeg
RUN pip3 install imageio-ffmpeg imageio
# For whatever reason, the instant-ngp build can't find cuda w/out this stuff despite the canonical paths looking OK
ENV PATH /usr/local/cuda-11.3/bin:$PATH
ENV LD_LIBRARY_PATH /usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH
# Note!!! change this if you don't have 30x series GPU
ENV TCNN_CUDA_ARCHITECTURES 75
# 86
RUN \
cd ~ && \
git clone https://github.com/NVlabs/instant-ngp --recursive && \
cd instant-ngp && \
pip3 install -r requirements.txt && \
export CC=gcc && \
cmake . -B build && \
cmake --build build --config RelWithDebInfo -j --target all `nproc` && \
python3 scripts/run.py --help
Do you have any advice?
@greeneggsandyaml ahh yes I do get make: *** No rule to make target '255'. Stop.
as well. but it still works. did you try it? once you get Built target pyngp
then the python stuff should work.
maybe the build command is bad, try cmake --build build --config RelWithDebInfo -j --target all
(no nproc) i'll edit the suggestion
Thanks for the quick reply. I will try that and see if it works.
I think it's a typo on that last cmake command:
cmake --build build --config RelWithDebInfo -j --target all `nproc` && \
should be:
cmake --build build --config RelWithDebInfo --target all -j `nproc` && \
This shorter Dockerfile has been working for me, but is just a basic functioning image. Take into account that this uses nvidia/cuda:11.5.1-devel-ubuntu20.04
, so no cuDNN libraries.
FROM nvidia/cuda:11.5.1-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install build-essential git python3-dev python3-pip \
libopenexr-dev libxi-dev libglfw3-dev libglew-dev libomp-dev \
libxinerama-dev libxcursor-dev && \
# Clean up
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" \
PIP_NO_CACHE_DIR="1"
RUN pip3 install --upgrade cmake
RUN git clone --recursive https://github.com/nvlabs/instant-ngp
WORKDIR instant-ngp
# choose your GPU architecture
ENV TCNN_CUDA_ARCHITECTURES=XX
RUN pip3 install -r requirements.txt && \
# add -DNGP_BUILD_WITH_GUI=OFF if you want to disable the GUI
cmake . -B build && \
cmake --build build --config RelWithDebInfo -j `nproc`
CMD ["/usr/bin/bash"]
Note that if you save the Dockerfile in a non-empty directory you should add a .dockerignore file (just add an *
), to avoid sending the context to the daemon.
oh interesting @myagues what cmake do you get with pip3 install --upgrade cmake
? i guess that's ubuntu 20 tho so you'll get a newer one.. yeah my base image is ubuntu 18.
It's the one on the PyPI repo, currently 3.22.1, but I guess you can choose which one you want as with any pip package installation. I was surprised this worked :)
Update: the previous (long) Dockerfile worked for me with your fix. It's so nice to actually be able to use this.
Also that looks like a nice short Dockerfile (though I haven't tested it yet), very concise.
I got this error with the original dockerfile
/bin/sh: 1: cd: can't cd to /opt/instant-ngp
@himat derp i edited it to clone the repo. the directory doesn't exist if you don't have anything cloned
Thanks, it now built.
But getting an X11 issue now if you have any ideas on the best way to set up X11 in this docker container I'm running on a remote machine over ssh.
root@01d7fea8c5e9:/opt/instant-ngp# ./build/testbed --scene data/nerf/fox
17:06:39 INFO Loading NeRF dataset from
17:06:39 INFO data/nerf/fox/transforms.json
17:06:39 SUCCESS Loaded 50 images of size 1080x1920 after 0s
17:06:39 INFO cam_aabb=[min=[0.5,-1.53747e+36,0.5], max=[0.5,-1.53747e+36,0.5]]
17:06:39 INFO Loading network config from: configs/nerf/base.json
17:06:39 INFO GridEncoding: Nmin=16 b=1.51572 F=2 T=2^19 L=16
17:06:39 INFO Density model: 3--[HashGrid]-->32--[FullyFusedMLP(neurons=64,layers=3)]-->1
17:06:39 INFO Color model: 3--[SphericalHarmonics]-->16+16--[FullyFusedMLP(neurons=64,layers=4)]-->3
17:06:39 INFO total_encoding_params=13074912 total_network_params=10240
Glfw Error 65544: X11: Failed to open display localhost:10.0
17:06:39 ERROR Uncaught exception: GLFW could not be initialized.
I found a way to forward the GUI from inside the container, although I did not have a very good performance (3 FPS with albert on a GTX1070Ti), hopefully more powerful GPUs can still get good performance.
The image I used is the short one I posted, but should work for the other docker image, as no additional packages are needed.
Follow the setup recommended in the ArchWiki, for both the client and the remote server. If you do not have permission to edit /etc/ssh/sshd_config
you will have to contact your system administrator, in case X11Forwarding
is disabled.
Make sure your X11 forwarding connection is working with xclock
or xeyes
, as the wiki suggests.
Once we know that our ssh
connection works with X11 forwarding, we need to setup our container. We will follow the steps described in SO. Consider the image is called local/instant-ngp
:
$ docker run --gpus all -it --net=host local/instant-ngp &
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a24deeab6843 local/instant-ngp "/usr/bin/bash" 6 minutes ago Up 6 minutes elated_lederberg
$ docker exec -i elated_lederberg bash -c 'cat > ~/.Xauthority' < ~/.Xauthority
$ docker exec -it --env="DISPLAY" elated_lederberg bash
Now, in the docker prompt:
# echo $DISPLAY
localhost:10.0
If environment variable DISPLAY
is empty inside the container, something has gone wrong in the previous steps, look for some typo or remove the container (docker stop elated_lederberg && docker rm elated_lederberg
) and repeat all the process.
# ./build/testbed --scene=data/image/albert.exr
Thanks, I also got it working on windows.
Install XLaunch see https://dev.to/darksmile92/run-gui-app-in-linux-docker-container-on-windows-host-4kde Don't forget to turn off the Native OPENGL option WITHOUT THIS IT WONT WORK
Create a file named Dockerfile Paste the image config below and change TCNN_CUDA_ARCHITECTURES to your gpu architecture. You can find it here https://developer.nvidia.com/cuda-gpus
FROM nvidia/cuda:11.5.1-devel-ubuntu20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get -y install build-essential git python3-dev python3-pip \
libopenexr-dev libxi-dev libglfw3-dev libglew-dev libomp-dev \
mesa-utils libgl1-mesa-glx \
libxinerama-dev libxcursor-dev && \
apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" \
PIP_NO_CACHE_DIR="1"
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,display
RUN pip3 install --upgrade cmake
RUN git clone --recursive https://github.com/nvlabs/instant-ngp
WORKDIR instant-ngp
ENV TCNN_CUDA_ARCHITECTURES=75
RUN pip3 install -r requirements.txt && \
# add -DNGP_BUILD_WITH_GUI=OFF if you want to disable the GUI
cmake . -B build && \
cmake --build build --config RelWithDebInfo -j `nproc`
CMD ["/usr/bin/bash"]
Run the command below in the folder where the Dockerfile is located.
docker build .
Keep the image hash from the build result last line
sha:XX....
Find your ip using ipconfig and run the command below with your ip and your image hash
docker run --gpus all -it -e DISPLAY=192.168.178.33:0.0 --net=host sha256:XXYOURIMAGEHASH
If you have more than one gpu you can change the 'all' part to 0 or 1 or 0,1 depending on which gpu you want to run it on.
Run a command for example
./build/testbed --scene data/nerf/fox
is the development container not for this purpose? in .devcontainer/Dockerfile
?
(It doesn't seem to have cloned the repo inside the container though)
is the development container not for this purpose? in
.devcontainer/Dockerfile
? (It doesn't seem to have cloned the repo inside the container though)
right the devcontainer appears to disable the gpu right now (NGP_BUILD_WITH_GUI=off
). but that Dockerfile should work with the x11 instructions in this issue.
Closing since a .devcontainer/Dockerfile
is now included
I can't get it to build properly, it would be nice to have a docker image and or dev container to run it. Saves everyone a lot of time trying to build the project.