Giter VIP home page Giter VIP logo

Comments (16)

myagues avatar myagues commented on May 13, 2024 1

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 :)

from instant-ngp.

myagues avatar myagues commented on May 13, 2024 1

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.

Step 1: testing X11 forwarding between client and remote

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.

Step 2: X11 forwarding from container to client

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

from instant-ngp.

pwais avatar pwais commented on May 13, 2024

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

from instant-ngp.

greeneggsandyaml avatar greeneggsandyaml commented on May 13, 2024

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?

from instant-ngp.

pwais avatar pwais commented on May 13, 2024

@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

from instant-ngp.

greeneggsandyaml avatar greeneggsandyaml commented on May 13, 2024

Thanks for the quick reply. I will try that and see if it works.

from instant-ngp.

myagues avatar myagues commented on May 13, 2024

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.

from instant-ngp.

pwais avatar pwais commented on May 13, 2024

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.

from instant-ngp.

greeneggsandyaml avatar greeneggsandyaml commented on May 13, 2024

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.

from instant-ngp.

himat avatar himat commented on May 13, 2024

I got this error with the original dockerfile

/bin/sh: 1: cd: can't cd to /opt/instant-ngp

from instant-ngp.

pwais avatar pwais commented on May 13, 2024

@himat derp i edited it to clone the repo. the directory doesn't exist if you don't have anything cloned

from instant-ngp.

himat avatar himat commented on May 13, 2024

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.

from instant-ngp.

Gigabyte0x1337 avatar Gigabyte0x1337 commented on May 13, 2024

Thanks, I also got it working on windows.

Step 1

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

Step 2

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"]

Step 3

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....

Step 4

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.

Step 5

Run a command for example
./build/testbed --scene data/nerf/fox

from instant-ngp.

cduguet avatar cduguet commented on May 13, 2024

is the development container not for this purpose? in .devcontainer/Dockerfile ?
(It doesn't seem to have cloned the repo inside the container though)

from instant-ngp.

pwais avatar pwais commented on May 13, 2024

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.

from instant-ngp.

Tom94 avatar Tom94 commented on May 13, 2024

Closing since a .devcontainer/Dockerfile is now included

from instant-ngp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.