grantwilk / d-noise

An AI denoising pipeline between Blender and NVIDIA's OptiX AI-Accelerated Denoiser.
http://remingtoncreative.com/software/blender/d-noise
GNU General Public License v3.0
303 stars 36 forks source link

Add support for linux #5

Closed paperbenni closed 4 years ago

paperbenni commented 5 years ago

Can you please add support for linux? As far as I understand the addon is basically just a wrapper for nvidia optix. There is an nvidia optix version for linux so it shouldn't be too hard to implement but it'd really help a lot of people since especially rendering is often done on linux servers. (and it'd be able to get on sheepit) I use arch on my main workstation and would really love to play around with DNOISE. Thanks in advance ;)

codecnotsupported commented 5 years ago

I builded a linux version of DeclanRussell Denoiser. https://my.mixtape.moe/kuuqrx.tar.xz It requires libopenimageio: So for Ubuntu/Debian: "sudo apt-get install libopenimageio1.7" The only catch is that you need to launch it with "LD_PRELOAD=./liboptix.so.51 ./denoiser"

For anyone interested in updating here are some hints: https://github.com/grantwilk/DNOISE/blob/master/urlutils.py#L28 https://github.com/grantwilk/DNOISE/blob/master/optix.py#L44

codecnotsupported commented 5 years ago

I builded a linux version of DeclanRussell Denoiser. https://my.mixtape.moe/kuuqrx.tar.xz It requires libopenimageio: So for Ubuntu/Debian: "sudo apt-get install libopenimageio1.7" The only catch is that you need to launch it with "LD_PRELOAD=./liboptix.so.51 ./denoiser"

For anyone interested in updating here are some hints: https://github.com/grantwilk/DNOISE/blob/master/urlutils.py#L28 https://github.com/grantwilk/DNOISE/blob/master/optix.py#L44

Alright by the magic of compilers the above build is broken. ( Please don't ask why, here be dragons 'n all )

So I fixed it. And actually checked if it worked. Builded it with cuda 10, and the latest Optix. https://mega.nz/#!cRVEAawK!Zy3AvOp044B2fZIdyilEgbsSOgtdqsosdUVlSnAEa74

paperbenni commented 5 years ago

@codecnotsupported thanks! Would you mind sharing a bash script, aur or docker container building this? Honestly, thank you so much, but I don't think that a lot people on GitHub would be comfortable running binaries from a mega. Plus, you wouldn't have to be the one having to constantly update this thing.

codecnotsupported commented 5 years ago

@codecnotsupported thanks! Would you mind sharing a bash script, aur or docker container building this? Honestly, thank you so much, but I don't think that a lot people on GitHub would be comfortable running binaries from a mega. Plus, you wouldn't have to be the one having to constantly update this thing.

Sure thing, it's not much of a bash script but this is what I did. Download & Install the OptixSDK https://developer.nvidia.com/designworks/optix/download Download & Install CUDA

Just grab https://github.com/DeclanRussell/NvidiaAIDenoiser Then go to 'src' and run. g++ main.cpp -lOpenImageIO -I[Pathto]/NVIDIA-OptiX-SDK-5.1.1-linux64/include/ -I[PathtoCUDA_headers]/ [Pathto]/NVIDIA-OptiX-SDK-5.1.1-linux64/lib64/* -o denoiser (Replace "[Pathto]" with the correct path to that directory.) The location of Cuda headers on my system is: "/usr/local/cuda-9.2/include", but yours might differ.

Then copy the following files from 'NVIDIA-OptiX-SDK-5.1.1-linux64/lib64' to the 'src' folder

libcudnn.so libcudnn.so.7 libcudnn.so.7.1.1 liboptix.so.51 liboptix_denoiser.so.5.1.1 liboptix_denoiser.so.51

Run as: LD_LIBRARY_PATH=./ ./denoiser

I should probably have posted this on his github project page, oh well ¯_(ツ)_/¯

jkroby commented 5 years ago

For compile with optix 6.5 i can't with 7 because i don't find lib64 directory...

install: libopenimageio

I have to use on my system: g++ main.cpp /usr/fast/jk/NVIDIA-OptiX-SDK-6.5.0-linux64/lib64/* -lOpenImageIO -I /usr/fast/jk/NVIDIA-OptiX-SDK-6.5.0-linux64//include/ -I/usr/local/cuda-10.1/ -I../contrib/optix/include/ -I../contrib/optix/include/optixu/ -I/usr/local/cuda-10.1/targets/x86_64-linux/include/ -I/usr/include/OpenImageIO -o denoiser

Gueriero commented 4 years ago

Can someone build a working version of the addon to run without dancing with a tambourine. Thanks.

codecnotsupported commented 4 years ago

Can someone build a working version of the addon to run without dancing with a tambourine. Thanks.

lol

I think the addon is kind of obsolete now that, Nvidia's Optix denoiser is implemented in Blender 2.81, as well as Intel's open image denoiser, which is available from the node editor.

https://evermotion.org/tutorials/show/11601/new-intel-open-image-denoiser-in-blender-2-81 https://docs.blender.org/manual/en/latest/render/layers/denoising.html

arnolde commented 2 years ago

@codecnotsupported Why do you say this is obsolete now? If I understand correctly, the integrated AI denoiser in Blender 2.81 only supports RTX cards, not GTX 600 and up, as the D-NOISE addon does. I have a Linux notebook (T440p) with a GTX 940M and would like to use the addon. Windows is not an option for me. Any comment greatly appreciated :-)

EDIT: I was mistaken, I only have a 730M and it only has compute capability of 3.0. So thats why Blender does not offer me optix support (requires 5.0). I do have the right driver (470+). Does your code run with compute 3.0? If you support GTX 600 and up, I suppose I might be lucky? Then I would just need a little help getting it running on my Ubuntu 20.04...

EDIT2: I've gotten so far by now:

~/Downloads/NvidiaAIDenoiser/src$ g++ main.cpp -lOpenImageIO -I../../NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64/include/ -I/usr/local/cuda-11.5/targets/x86_64-linux/include/ -I../contrib/OpenImageIO/include ../../NVIDIA-OptiX-SDK-7.4.0-linux64-x86_64/SDK/lib/* -o denoiser
In file included from ../contrib/OpenImageIO/include/OpenEXR/IexBaseExc.h:40,
                 from ../contrib/OpenImageIO/include/OpenEXR/ImathExc.h:47,
                 from ../contrib/OpenImageIO/include/OpenEXR/ImathVec.h:46,
                 from ../contrib/OpenImageIO/include/OpenImageIO/simd.h:56,
                 from ../contrib/OpenImageIO/include/OpenImageIO/fmath.h:65,
                 from ../contrib/OpenImageIO/include/OpenImageIO/hash.h:51,
                 from ../contrib/OpenImageIO/include/OpenImageIO/strutil.h:52,
                 from ../contrib/OpenImageIO/include/OpenImageIO/ustring.h:137,
                 from ../contrib/OpenImageIO/include/OpenImageIO/paramlist.h:46,
                 from ../contrib/OpenImageIO/include/OpenImageIO/imageio.h:61,
                 from main.cpp:6:
../contrib/OpenImageIO/include/OpenEXR/IexExport.h:42:35: error: ‘dllimport’ has not been declared
   42 |     #define IEX_EXPORT __declspec(dllimport)

I first had to edit main.cpp and change 2 includes with OpenImageIO to use a forward slash instead of backslash, and find those files and add the -I for their path. Also the lib64 path for Optix had changed to SDK/lib.

EDIT3: Now I found more info here: https://github.com/DeclanRussell/NvidiaAIDenoiser/issues/4

I also found that the Optix SDK 7.4 requires a higher driver than I have, so I downgraded to 7.3.0. Now I still have some problems, but a lot less ;-) (note I disabled 2 types of warnings here to see how far I get):

~/Downloads/NvidiaAIDenoiser/src$ g++ main.cpp -lOpenImageIO -I../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/include/ -I/usr/local/cuda/include/ ../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/* -o denoiser -Wno-write-strings -Wno-format-security -Wno-format-overflow
main.cpp: In function ‘int main(int, char**)’:
main.cpp:482:93: error: no matching function for call to ‘PrintInfo(const char*)’
  482 |                 PrintInfo((hdr) ? "HDR training data enabled" : "HDR training data disabled");
      |                                                                                             ^
main.cpp:65:6: note: candidate: ‘template<class ... Args> void PrintInfo(char*, Args ...)’
   65 | void PrintInfo(char *c, Args... args)
      |      ^~~~~~~~~
main.cpp:65:6: note:   template argument deduction/substitution failed:
main.cpp:482:33: note:   cannot convert ‘((hdr != 0) ? ((const char*)"HDR training data enabled") : ((const char*)"HDR training data disabled"))’ (type ‘const char*’) to type ‘char*’
  482 |                 PrintInfo((hdr) ? "HDR training data enabled" : "HDR training data disabled");
      |                           ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

EDIT4: Changing main.cpp line 482 to this got rid of the error: PrintInfo((hdr) ? (char*)"HDR training data enabled" : (char*)"HDR training data disabled");

But now:

~/Downloads/NvidiaAIDenoiser/src$ g++ main.cpp -lOpenImageIO -I../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/include/ -I/usr/local/cuda/include/ ../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/* -o denoiser -Wno-write-strings -Wno-format-security -Wno-format-overflow
/usr/bin/ld: ../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/CMake kann nicht gefunden werden: file format not recognized
../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/CMakeLists.txt: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status

Those files are there, however:

ea@thinkpad:~/Downloads/NvidiaAIDenoiser/src$ ll ../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/
drwxr-xr-x  3 ea ea  4096 Apr  6  2021 CMake/
-rw-r--r--  1 ea ea 16822 Apr  6  2021 CMakeLists.txt
DeclanRussell commented 2 years ago

@arnolde In https://github.com/DeclanRussell/NvidiaAIDenoiser/commit/4e6f8667fa9867dfb7ef36b870ff66b2c18d3b44 I have pushed a commit that should fix those warnings.

As far as your compilation error. I don't think you need this line ../../NVIDIA-OptiX-SDK-7.3.0-linux64-x86_64/SDK/* in your compiler flags.