DeclanRussell / NvidiaAIDenoiser

A simple implementation of Nvidia's AI denoiser
MIT License
398 stars 52 forks source link

Do we have the linux GPU version of AIDenoiser #4

Open XBOOS opened 6 years ago

XBOOS commented 6 years ago

Hi sir, I wonder do we have the linux GPU version of AIDenoiser? I am using Linux most of the time,but now I only have the .dll files.

Best regards. Bing

DeclanRussell commented 6 years ago

Hey Bing, So this shouldn't be too hard to do and I'll try to find some time to look into it. The longest part on my end will be setting up a linux dev environment.

In the mean time however, if you already have such an environment setup on your linux machine, I would happily give some advice on how to get it to build yourself if thats something you would be interested in?

Cheers, Dec

XBOOS commented 6 years ago

Yes, I already have ubuntu installed on my laptop. Could you please give me some instuctions to build the AI denoiser on ubuntu? Appreciated for your kind help! My email addr is xubinghku@gmail.com if it's not convinent to put up on github.

DeclanRussell commented 6 years ago

Great, I'll likely ping you some time next week if thats ok? As I'm on holiday until Tuesday :)

atkpln commented 6 years ago

I am also working on a linux build here for CENTOS 7. I'll let you know how it goes. Great work on the denoiser, I have run it in windows and it does a fantastic job.

RicardasSim commented 6 years ago

Tested on Linux Ubuntu 16.04, but i have NVIDIA-OptiX-SDK-5.1.0-linux64 installed locally and CUDA under /usr/local/cuda

in main.cpp changed:

#include "OpenImageIO\imageio.h"
#include "OpenImageIO\imagebuf.h"

to

#include <OpenImageIO/imageio.h>
#include <OpenImageIO/imagebuf.h>

in contrib/optix created directory lib copied from Optix SDK lib64 liboptix.so, liboptix.so.51, liboptix.so.5.1.0 to that directory

this is edited SConstruct:

import os
PLATFORM = Platform()
DEBUG = ARGUMENTS.get("debug", 0)

CUDA_INCLUDE_PATH = "/usr/local/cuda/include"

ENV = Environment(CPPPATH = ['.', "./contrib/optix/include", "/usr/include", CUDA_INCLUDE_PATH
],
                  CCFLAGS="-std=c++11")

# Used for debbugging
if int(DEBUG):
    ENV.Append(CCFLAGS=' -ggdb3')

SOURCES = Glob("src/*.cpp")

LIBPATH = []
LIBPATH.append("./contrib/optix/lib")

LIBS = []
LIBS.append("optix")
LIBS.append("OpenImageIO")

LINKFLAGS = []
LINKFLAGS.append("-Wl,-rpath=.")

program = ENV.Program(target="bin/Denoiser", source=SOURCES,
                              LIBPATH=LIBPATH, LIBS=LIBS, LINKFLAGS=LINKFLAGS)

-Wl,-rpath=. needed to search local directory for libraries when running Denoiser

build, then copy libraries from sdk to bin directory, or Denoiser to SDK SDK-precompiled-samples and run

./Denoiser -i test.png -o test_output.png

Launching Nvidia AI Denoiser command line app v2.0 Created by Declan Russell (25/12/2017 ~ Merry Christmas!) Input image: test.png Loaded successfully Output image: test_output.png Denoising... Denoising complete Saving to: test_output.png Done!

Thanks Declan :)

DeclanRussell commented 6 years ago

@RicardasSim This is great, thanks for the contribution! :) @XBOOS Let me know if this works for your machine.

paperbenni commented 5 years ago

can someone just put a precompiled linux binary up somewhere? Would you be allowed to distribute that? (an aur would be great of course ;))

jasperges commented 5 years ago

@RicardasSim Thanks! I tested it under Fedora 29 and it also worked fine. Of course you also need to have OpenImageIO installed which can be done with dnf install OpenImageIO-devel for Fedora or apt install libopenimageio-dev for Ubuntu.

JSMOZART commented 5 years ago

@RicardasSim @jasperges Running this in Ubuntu 18.04.1 I keep getting the error "[OptiX]: std::exception" whenever I try to do the -i -o commands, did y'all run into this issue and if so how did you get over it?

jasperges commented 5 years ago

@JSMOZART I didn't have this problem. Did you compile it as RicardasSim showed? At the end of the week I can check on my work computer with proper GPU and Linux.

DeclanRussell commented 5 years ago

@JSMOZART Do you have the correct nvidia driver installed? It requires 390.xx or higher

RicardasSim commented 5 years ago

Ubuntu 18.04.1 LTS NVIDIA-OptiX-SDK-5.1.1-linux64 cuda-10.0

builded the same way, only replaced includes with new ones, from OptiX-SDK-5.1.1 copied /opt/NVIDIA-OptiX-SDK-5.1.1-linux64/include to contrib/optix/include and libraries liboptix.so liboptix.so.51 liboptix.so.5.1.1

also you can change include and lib path in SConstruct to proper OptiX-SDK-5.1.1 directories

but then .....

Input image: test.png Loaded successfully Output image: test_o.png

first solution was to set LD_LIBRARY_PATH variable

open console, run command: (it must be run once, each time you open a new console ) export LD_LIBRARY_PATH=/opt/NVIDIA-OptiX-SDK-5.1.1-linux64/lib64:$LD_LIBRARY_PATH then ./Denoiser -i test.png -o test_o.png

Created by Declan Russell (25/12/2017 ~ Merry Christmas!) Input image: test.png Loaded successfully Output image: test_o.png Denoising... Denoising complete Saving to: test_o.png Done!

also works if to copy libraries from /opt/NVIDIA-OptiX-SDK-5.1.1-linux64/lib64 or make symlinks:

liboptix_denoiser.so liboptix_denoiser.so.51 liboptix_denoiser.so.5.1.1 liboptix.so liboptix.so.51 liboptix.so.5.1.1 ...

to /usr/local/lib wthout setting LD_LIBRARY_PATH

run ldconfig

maybe there is a better solution, for example to set LD_LIBRARY_PATH to OptixSDK globally, in /etc/ld.so.conf.d, but I can't do that, because I have other versions of libraries with the same names, for example newer cudnn, so can't test it

RicardasSim commented 5 years ago

simple script to run

in the same directory as Denoiser

create script (change path to OptixSDK libs if needed)

cat > denoiser.sh << "EOF"

!/bin/bash

export LD_LIBRARY_PATH=/opt/NVIDIA-OptiX-SDK-5.1.1-linux64/lib64:$LD_LIBRARY_PATH

./Denoiser "$@"

EOF

make it executable

chmod +x denoiser.sh

./denoiser.sh -i test.png -o test_o.png

Launching Nvidia AI Denoiser command line app v2.0 Created by Declan Russell (25/12/2017 ~ Merry Christmas!) Input image: test.png Loaded successfully Output image: test_o.png Denoising... Denoising complete Saving to: test_o.png Done!

RicardasSim commented 5 years ago

from Optix SDK Version 6.0.0 Release Notes System Requirements All NVIDIA GPUs of Compute Capability 5.0 (Maxwell) or higher are supported. Linux: driver version 418.30 or later is required.

cuda toolkit 10.1.105 released with nvidia drivers 418.39

now the denoiser also works on ubuntu with optix sdk 6.0.0

stevefoy commented 5 years ago

Thanks all, i just did a quick build and test, updated the plugin a little, amazing results:

My system/ tested Optix sdk 6.0.0 NVIDIA-SMI 418.39 Driver Version: 418.39 CUDA Version: 10.1 Distributor ID: Ubuntu Description: Ubuntu 16.04.5 LTS Release: 16.04 Codename: xenial

Branch here if it helps anyone: https://github.com/stevefoy/NvidiaAIDenoiser

arnolde commented 2 years ago

I'm currently trying to get it working on Ubuntu 20.04. Here my ordeal so far is documented: https://github.com/grantwilk/d-noise/issues/5

@stevefoy @RicardasSim @jasperges Do you know how to get past the cmake part? I'm completely new to it and the Cmakelists.txt is huge :-(

artnose commented 2 years ago

Man I wish I could get this compiled.
I can't get the SDK or this with all the dependencies.
What's the compile command for this?

For the SDK, gives me there errors

ccmake ../SDK

CMake Warning at lib/ImageSource/CMakeLists.txt:53 (message): OpenEXR not found (see OpenEXR_ROOT). Will use procedural texture in optixDemandTexture.

Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR) Using X11 for window creation CMake Error at support/GLFW/CMakeLists.txt:223 (message): The RandR library and headers were not found

Configuring incomplete, errors occurred! See also "/root/nv/SDK/CMakeFiles/CMakeOutput.log". See also "/root/nv/SDK/CMakeFiles/CMakeError.log".

Is there a binary of the SDK libs? I'm on Centos8

pigLoveRabbit520 commented 1 month ago

hello @DeclanRussell I have written a CMakeLists file and I successfully built the project on Ubuntu 22. my fork

GeForce RTX 3060 OS: Ubuntu 22.04 CUDA: 12.4 Driver Version: 550.100 NVIDIA-OptiX: 8.0.0

I also fix the bug

CU_CHECK(cudaMalloc(((void*)(l.input.data)), sizeof(float) * 4 * b_width * b_height));

to

CU_CHECK(cudaMalloc(((void**)&(l.input.data)), sizeof(float) * 4 * b_width * b_height));
DeclanRussell commented 1 month ago

Thanks for the efforts in the CMakeFile @pigLoveRabbit520. Thats greatly appreciated. I've never gotten around to getting things working on linux as I don't have a linux machine to hand. I would advise people to check out the optixDenoiser sample in the OptiX SDK. This is a command line tool similar to this, but has a bit more support from Nvidia and should build on linux.