Open coderamen666 opened 1 year ago
You can build without GPU/CUDA support.
https://github.com/dreamworksanimation/openmoonray/discussions/34
We have not attempted to compile on Mac OS, regardless of hardware. I imagine, being Unix-based, it may be easier to get it to work than under Windows. I have not looked into the M1 specifications and worry about the memory model. We run on x86-64, which has a strong memory model; there may be cases in our code where we use the wrong memory fence, but it has never been caught. That said, that will be a runtime bug and should not be a barrier (Ha! Thread barrier. Get it?) to the first step of compilation.
Compiling on Mac OS will simply be a matter of someone attempting it and working through the issues. I imagine that a Raspberry Pi is more difficult.
So, I gave this a try. because I'm both a macOS and Raspberry Pi user. I wanted to first compile it on docker on my M1 machine, since that felt like the the safest/easiest route before embarking in a architecture change challenge.
My current diff is pretty small, basically:
-FROM nvidia/cuda:11.4.0-base-centos7
+FROM centos:7
and
RUN yum install -y mesa-libGL
-RUN yum install -y cuda-toolkit-11-4
I can export a git patch but there's nothing fancy going on.
From there, I basically followed what the docs suggest, with the other relevant contribution being the --platform linux/amd64
to get a non arm64 image, as a starter (since that's the safest but less performant way). More info here: https://www.docker.com/blog/multi-arch-images.
These were my steps:
$ cd ./building
$ docker build --platform linux/amd64 -t openmoonray_base . --file Dockerfile
$ docker run --platform linux/amd64 -v ~/dev/personal/moonray/openmoonray/building:/building --network=host --rm -it openmoonray_base
$ cd /build
$ cmake ../building
$ cmake --build . -- -j $(nproc)
These^ steps went all fine, and the 3rd party dependencies were built correctly.
NOTE: I removed the building:shared
fraction because it was failing on macOS and I wanted to move forward:
Error: is mounted on /host_mnt but it is not a shared mount macOS
Some relevant posts:
I made sure that the path where I had moonray was added in the Resources / File sharing preferences of the Docker Desktop App so that it could be bind mounted into docker containers. Another error that I encountered was that the build process was getting killed because it was running out of memory, so I had to bump the allocated Docker memory from 8GB to 32GB and things went fine!
After that, I saved the new image as specified in the docs:
$ docker commit 77791acddb26 openmoonray_build
Finally, I tried to compile the actual moonray binaries:
$ docker run --platform linux/amd64 -v ~/dev/personal/moonray/openmoonray:/openmoonray -v /tmp:/tmp --network=host --rm -it openmoonray_build
$ cd /openmoonray
$ cmake --preset container-release -DMOONRAY_USE_CUDA=NO
$ cmake --build --preset container-release -- -j $(nproc)
But sadly, this last step keeps failing with this funny qemu memory crash:
[ 90%] Generating GeometrySet.json, Joint.json, TraceSet.json, Layer.json, LightFilterSet.json, LightSet.json, RenderOutput.json, SceneVariables.json, ShadowSet.json, ShadowReceiverSet.json, UserData.json, Metadata.json
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
qemu: uncaught target signal 6 (Aborted) - core dumped
/bin/sh: line 1: 58827 Aborted ../../../cmd/rdl2_cmd/rdl2_json_exporter/rdl2_json_exporter --dso_path /openmoonray/moonray/scene_rdl2/lib/scene/rdl2 --builtin --in GeometrySet --out /build/moonray/scene_rdl2/lib/scene/rdl2/GeometrySet.json --in Joint --out /build/moonray/scene_rdl2/lib/scene/rdl2/Joint.json --in TraceSet --out /build/moonray/scene_rdl2/lib/scene/rdl2/TraceSet.json --in Layer --out /build/moonray/scene_rdl2/lib/scene/rdl2/Layer.json --in LightFilterSet --out /build/moonray/scene_rdl2/lib/scene/rdl2/LightFilterSet.json --in LightSet --out /build/moonray/scene_rdl2/lib/scene/rdl2/LightSet.json --in RenderOutput --out /build/moonray/scene_rdl2/lib/scene/rdl2/RenderOutput.json --in SceneVariables --out /build/moonray/scene_rdl2/lib/scene/rdl2/SceneVariables.json --in ShadowSet --out /build/moonray/scene_rdl2/lib/scene/rdl2/ShadowSet.json --in ShadowReceiverSet --out /build/moonray/scene_rdl2/lib/scene/rdl2/ShadowReceiverSet.json --in UserData --out /build/moonray/scene_rdl2/lib/scene/rdl2/UserData.json --in Metadata --out /build/moonray/scene_rdl2/lib/scene/rdl2/Metadata.json
gmake[2]: *** [moonray/scene_rdl2/lib/scene/rdl2/CMakeFiles/coredata_files.dir/build.make:84: moonray/scene_rdl2/lib/scene/rdl2/GeometrySet.json] Error 134
gmake[1]: *** [CMakeFiles/Makefile2:38668: moonray/scene_rdl2/lib/scene/rdl2/CMakeFiles/coredata_files.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
Some related issues:
I'll have another look at this and see if compiling Moonray natively on Arm leads to better results.
Upon running "cmake --preset" I get the following:
CMake Error at arras/arras4_core/CMakeLists.txt:6 (include): include could not find requested file:
packageVersion
CMake Warning at arras/arras4_core/CMakeLists.txt:8 (project): VERSION keyword not followed by a value or was followed by a value that expanded to nothing.
CMake Error at arras/arras4_core/CMakeLists.txt:34 (find_package): By not providing "FindLibuuid.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Libuuid", but CMake did not find one.
Could not find a package configuration file provided by "Libuuid" with any of the following names:
LibuuidConfig.cmake
libuuid-config.cmake
Add the installation prefix of "Libuuid" to CMAKE_PREFIX_PATH or set "Libuuid_DIR" to a directory containing one of the above files. If "Libuuid" provides a separate development package or SDK, be sure it has been installed.
How should I go about fixing this?
The packageVersion.cmake module is found in the cmake_modules repository. Is it possible you didn't include --recurse-submodules when you did your clone?
Also, which build instructions are you following ?
https://docs.openmoonray.org/getting-started/installation/building-moonray/
I'm following the instructions posted on this thread.
I solved the other issues by recloning the repo, but now have a new error:
ld: unknown option: --enable-new-dtags clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: [arras/arras4_core/arras4_message_api/lib/message_api/libmessage_api.dylib] Error 1 make[1]: [arras/arras4_core/arras4_message_api/lib/message_api/CMakeFiles/message_api.dir/all] Error 2 make: *** [all] Error 2
It works on macOS now, so that's cool!
I know, I got it working before you mentioned it!
How could I build this on Mac M1 or Raspberry Pi 4? AFAIK it relies on CUDA and x86.