Skip to content

Instantly share code, notes, and snippets.

@jedypod
Last active November 4, 2019 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedypod/8344e55357cc0563391047923851dedf to your computer and use it in GitHub Desktop.
Save jedypod/8344e55357cc0563391047923851dedf to your computer and use it in GitHub Desktop.

Compile GafferCycles with OIDN

Trying to compile the [https://github.com/boberfly/GafferCycles/tree/oidn](oidn branch of gafferCycles) to get OpenImageDenoise working in Gaffer.

# Compile with vfx reference platform docker
docker run -it --mount type=bind,source=/pod/sw/compile/gaffercycles,target=/root --mount type=bind,source=/opt,target=/root/opt --entrypoint /bin/bash gaffercycles-1

# Set up env
export GAFFER_ROOT=~/opt/gaffer/gaffer
# export GAFFERCYCLES=~/opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.54.2.0
export GAFFERCYCLES=/root/gafferCycles-oidn-0.10.2-gaffer-0.54.2.0
export LD_LIBRARY_PATH=$GAFFER_ROOT/lib
export PATH=$GAFFER_ROOT/bin:$PATH
export PYTHONHOME=~/opt/gaffer/gaffer
export GITHUB_RELEASE_TOKEN=10.2

git clone --recurse-submodules https://github.com/boberfly/GafferCycles.git

cd GafferCycles

# modify dependencies/build/build.py to bypass ssl checking so gflags compiles
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
urllib.urlretrieve( download, archivePath, context=ctx)

scl enable devtoolset-6 bash

Compile Dependencies

cd GafferCycles/dependencies
python ./build/build.py --project Gflags --buildDir $GAFFERCYCLES --forceCCompiler gcc --forceCxxCompiler g++
python ./build/build.py --project Glog --buildDir $GAFFERCYCLES --forceCCompiler gcc --forceCxxCompiler g++
python ./build/build.py --project Embree --buildDir $GAFFERCYCLES --forceCCompiler gcc --forceCxxCompiler g++
python ./build/build.py --project OpenSubdiv --buildDir $GAFFERCYCLES --forceCCompiler gcc --forceCxxCompiler g++

python ./build/build.py --project OpenImageDenoise --gafferRoot $GAFFER_ROOT --buildDir $GAFFERCYCLES --forceCCompiler gcc --forceCxxCompiler g++

Compile GafferCycles

cd ../build
export OPTIX_ROOT=/optix
cmake -DCMAKE_CXX_COMPILER=g++ -DGAFFER_ROOT=$GAFFER_ROOT -DCMAKE_INSTALL_PREFIX=$GAFFERCYCLES -DWITH_CYCLES_EMBREE=ON -DWITH_CYCLES_OPENSUBDIV=ON -DWITH_CYCLES_LOGGING=ON -DWITH_CYCLES_DEVICE_OPTIX=ON -DOPTIX_ROOT_DIR=$OPTIX_ROOT ..
make -j4

# error: can't find OpenImageDenoise/oidn.hpp
cp -R $GAFFERCYCLES/include/OpenImageDenoise ../include/

make -j4

Test

export GAFFERCYCLES=/opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0
export GAFFER_EXTENSION_PATHS=${GAFFERCYCLES}:$GAFFER_EXTENSION_PATHS
export LD_LIBRARY_PATH=${GAFFERCYCLES}/lib:${GAFFERCYCLES}/lib64
export GAFFER_ROOT=/opt/gaffer/gaffer

exec ${GAFFER_ROOT}/bin/gaffer

Error

ERROR : startup/gui/menus.py : Error loading OIDN module - "/opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0/lib/libGafferOIDN.so: undefined symbol: oidnReleaseDevice".
 Traceback (most recent call last):
  File "/opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0/startup/gui/menus.py", line 85, in <module>
    import GafferOIDN
  File "/opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0/python/GafferOIDN/__init__.py", line 37, in <module>
    from _GafferOIDN import *
ImportError: /opt/gaffer/extensions/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0/lib/libGafferOIDN.so: undefined symbol: oidnReleaseDevice

Compile as Debug instead of Release

Compile with vfx reference platform docker

docker run -it --mount type=bind,source=/pod/sw/compile/gaffercycles,target=/root --mount type=bind,source=/opt,target=/root/opt --entrypoint /bin/bash gaffercycles-1

Set up env

export GAFFER_ROOT=/opt/gaffer/gaffer export GAFFERCYCLES=/gafferCycles-oidn-0.10.2-gaffer-0.55.0.0 export LD_LIBRARY_PATH=$GAFFER_ROOT/lib export PATH=$GAFFER_ROOT/bin:$PATH export PYTHONHOME=/opt/gaffer/gaffer export GITHUB_RELEASE_TOKEN=10.2 export OPTIX_ROOT=/opt/optix/NVIDIA-OptiX-SDK-7.0.0-linux64

cd ~/GafferCycles/dependencies python ./build/build.py --project Gflags --buildDir $GAFFERCYCLES --buildType debug --forceCCompiler gcc --forceCxxCompiler g++ python ./build/build.py --project Glog --buildDir $GAFFERCYCLES --buildType debug --forceCCompiler gcc --forceCxxCompiler g++ python ./build/build.py --project Embree --buildDir $GAFFERCYCLES --buildType debug --forceCCompiler gcc --forceCxxCompiler g++

python ./build/build.py --project OpenSubdiv --buildDir $GAFFERCYCLES --buildType debug --forceCCompiler gcc --forceCxxCompiler g++

Had to add this to the Dockerfile to compile OpenSubdiv

RUN yum install -y compat-glew glew-devel glew libGLEW tbb tbb-devel

python ./build/build.py --project OpenImageDenoise --gafferRoot $GAFFER_ROOT --buildDir $GAFFERCYCLES --buildType debug --forceCCompiler gcc --forceCxxCompiler g++

cd ../build cmake -DCMAKE_CXX_COMPILER=g++ -DGAFFER_ROOT=$GAFFER_ROOT -DCMAKE_INSTALL_PREFIX=$GAFFERCYCLES -DWITH_CYCLES_EMBREE=ON -DCMAKE_BUILD_TYPE=Debug -DWITH_CYCLES_OPENSUBDIV=ON -DWITH_CYCLES_LOGGING=ON -DWITH_CYCLES_DEVICE_OPTIX=ON -DOPTIX_ROOT_DIR=$OPTIX_ROOT .. make -j4

error: can't find OpenImageDenoise/oidn.hpp

cp -R $GAFFERCYCLES/include/OpenImageDenoise ../include/

make -j4

make install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment