Skip to content

Compilation

Xiang Feng edited this page Mar 17, 2024 · 2 revisions

Dependencies

  • C++ compiler. MSVC 19.31.31105 and gcc 9.4.0 was tested.
  • CMake. Version 3.16 was tested.
  • NVIDIA driver. Should be released on or after December 15th, 2020, for the implementations of the new official versions of the Vulkan ray tracing extensions. RTX 3060 Ti with Driver Version 512.15 was tested. Whether this project supports non NVIDIA graphics cards has not been determined.
  • Vulkan SDK. Version 1.3.204.1 was tested.
  • OptiX 7. Version 7.4.0 was tested.

Compile

$ git clone git@github.com:f1shel/Asuna.git --recursive
$ mkdir Asuna/build
$ cd Asuna/build
$ cmake ..
$ make # or build in IDE on windows

The binary file is placed in the Asuna/bin_x64 folder.

Render on Headless Server with Docker

One can compile Asuna in the docker, and the docker can be deployed on a headless server. The Dockerfile is placed in Asuna/docker and you can build image with following command:

$ cd Asuna/docker
$ docker build --pull --tag "asuna:latest" --file Dockerfile .

Note that nvidia-container-toolkit is required for accessing GPU in the docker. To start image you can type:

docker run -it \
    --runtime=nvidia \
    --gpus all \
    -e NVIDIA_DRIVER_CAPABILITIES=all \
    -v /usr/share/nvidia:/usr/share/nvidia \
    asuna:latest /bin/bash

Note that CUDA(11.6 and 11.8 tested) and OptiX(7.4 and 7.5 tested) is needed and you should download them manually. You can check with nvcc --version to see if CUDA is configured properly. After OptiX is installed, please set the OPTIX7_LOCATION environment variable which is requied by CMake.

export PATH=/usr/local/cuda-11.6/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64:$LD_LIBRARY_PATH
export OPTIX7_LOCATION=/root/NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64/

Note that option -v /usr/share/nvidia:/usr/share/nvidia is mandatory for properly using OptiX Denoiser in the docker (see the issue here).

Since Asuna depends on GLFW, You also need a X server to run it on a headless machine. Install xvfb, launch it(you propobably need a tmux or screen to keep it running in the background) and create a virtual framebuffer:

apt install xvfb
export DISPLAY=:99
Xvfb $DISPLAY -screen 0 1024x768x16

Now just run the compiled executable binary.

I test headless rendering on a 8xRTX4090 Ubuntu server. I would like to discuss a bug here: the program will recoganize 16 GPUs (more than actual number) and fail to initailize CUDA defaultly. After some debugging I find that only part of them is valid. You may specify the valid GPU by CUDA_VISIBLE_DEVICES or --gpu_id xxx. And the tricky thing here is the gpu id could be arbitrary value. For example, I have 8 GPUs on the server, 16 GPUs recoganized by the program, but only id 3 and 11 is valid.

Usage

$ ./asuna.exe --scene scenes/cornell_box/scene.json [--offline] [--out cbox]

Architecture

  • Initializing: window, surface, context, device, allocator

  • Parsing scene: interpret scene file and generate meta data

  • Allocating scene resources: convert meta data to gpu resources

  • Building pipeline

  • Binding pipeline and resources

  • Rendering

class AsunaTracer : public AppBaseVk {
    class Context; ----------------|
    class Scene;   ----------|     |
    class Pipeline;   <------|-----|
    void run();
};

Clone this wiki locally