NVIDIA’s instant-ngp Readme explains how to run its code on standard Windows & Ubuntu machines pretty well. But running it on Google Colab isn’t as well documented. There have been attempts to document it by some helpful people but many of these articles have become outdated as the repository and its underlying dependencies have evolved.

It took me a lot of reading and trial-and-error to be able to figure this out. Here is how I did it.

Please note that all the following instructions were run on an A100 GPU enabled Google Colab. Additionally, you will notice that I add %cd <some path> at a lot of places, even when it is not needed. This is to avoid any reader confusion about where the commands need to be run.

Setup Colmap

Before we begin with building the instant-ngp code, we will need to manually setup an important dependency that is needed when running certain instant-ngp scripts(eg. scripts/colmap2nerf.py). This dependency is the colmap library. Now, there is a way to use apt-get to install this library easily, but doing it this way will lead to errors. This is because the GUI_ENABLED option is ON by default when we use install using apt-get. I tried to look for system flags that I can use to disable the graphical UI, but couldn’t find any. Instead, building it locally turned out to be the only option.

Please run the following code to set up colmap:

!sudo apt-get install \
    git \
    cmake \
    build-essential \
    libboost-program-options-dev \
    libboost-filesystem-dev \
    libboost-graph-dev \
    libboost-regex-dev \
    libboost-system-dev \
    libboost-test-dev \
    libeigen3-dev \
    libsuitesparse-dev \
    libfreeimage-dev \
    libgoogle-glog-dev \
    libgflags-dev \
    libglew-dev \
    qtbase5-dev \
    libqt5opengl5-dev \
    libcgal-dev \
    libcgal-qt5-dev
!sudo apt install libceres-dev
!sudo apt install libmetis-dev
!sudo apt install libflann-dev


!mkdir additional_libs
%cd /content/additional_libs


!git clone https://github.com/colmap/colmap
%cd /content/additional_libs/colmap
!git checkout main

In order to disable the graphical UI, we need to go to CMakeLists.txt and switch GUI_ENABLED to OFF. Once this is done, please run the following commands.

%cd /content/additional_libs/colmap

!mkdir /content/additional_libs/colmap/build
%cd /content/additional_libs/colmap/build

!cmake ..
!make
!sudo make install

%cd /content

Voila! colmap is ready. Please run this to verify:

!colmap -h

Instant-ngp

Now that the dependencies are ready, it’s time for the main event. Let’s begin setting up instant-ngp

%cd /content
!git clone --recursive https://github.com/nvlabs/instant-ngp

Please check the cuda version on the Google Colab environment to make sure your path is correct. Mine is cuda-12.2.

!export PATH="/usr/local/cuda-12.2/bin:$PATH"
!export LD_LIBRARY_PATH="/usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH"

Now that the flags are set, let’s begin building instant-ngp.

%cd /content/instant-ngp

!mkdir /content/instant-ngp/build

!cmake . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DNGP_BUILD_WITH_GUI=OFF
!cmake --build build --config RelWithDebInfo
!pip install -r requirements.txt

That’s it! NVIDIA’s instant-ngp is ready to use. I hope this article helps people save time, avoid the pain of going though tedious code and searching forums.

Please reach out to us at info@betacrew.io for help building cutting edge GenAI applications

Ronil Mehta

Write by

Building BetaCrew Labs | Always curious, always learning | Meta & Bloomberg Alumnus

Let's Do The Impossible Together

Ready to tackle your toughest challenges? Book an exploration call with us today and discover how we can solve your problems.

  • Fractional CTO

  • Product Lab

  • Software Implementation

  • Technology Consulting

  • Operational Excellence

  • Software Solutions

  • Modernizing Systems

Let's Do The Impossible Together

Ready to tackle your toughest challenges? Book an exploration call with us today and discover how we can solve your problems.

  • Fractional CTO

  • Product Lab

  • Software Implementation

  • Technology Consulting

  • Operational Excellence

  • Software Solutions

  • Modernizing Systems

Let's Do The Impossible Together

Ready to tackle your toughest challenges? Book an exploration call with us today and discover how we can solve your problems.

  • Fractional CTO

  • Product Lab

  • Software Implementation

  • Technology Consulting

  • Operational Excellence

  • Software Solutions

  • Modernizing Systems