NVIDIA / gvdb-voxels

Sparse volume compute and rendering on NVIDIA GPUs
Other
672 stars 144 forks source link

Undefined symbols when linking CUDA 10.1 on macOS 10.13 #100

Closed mateuszwojt closed 3 years ago

mateuszwojt commented 4 years ago

I'm trying to compile this library on a Mac, after some modifications. I'm running into an issue when linking CUDA. It's a series of errors, but there's a common pattern, where I get:

Undefined symbols for architecture x86_64:
  "_cuArray3DCreate_v2", referenced from:
      nvdb::Allocator::AllocateTextureGPU(nvdb::DataPtr&, unsigned char, nvdb::Vector3D<int>, bool, unsigned long long) in gvdb_allocator.cpp.o
     (maybe you meant: __ZN6cudart24__fun_cuArray3DCreate_v2E)

Every undefined symbol ends with this v2E suffix, which appears to exist only on macOS platform. I tried the same on Windows and the linking process there is working fine. I'm not sure where this E comes from, couldn't find any info in the documentation. Is that a macOS-specific thing?

My environment:

NBickford-NV commented 4 years ago

Hi GreenEminence!

This is interesting - do the samples that come with CUDA build for you (they should be in a folder such as /Developer/NVIDIA/CUDA-10.1/samples)? If so, then I'm guessing this is probably a bug in GVDB's new CMakeLists (atsource/gvdb_library/CMakeLists.txt) - it's been tested on Windows and Ubuntu, but not on macOS yet.

Looking at the CMakeLists.txt file, I'm not seeing anything that stands out so far as being a bug, though - we enable CUDA support using

project(gvdb LANGUAGES CUDA CXX C)

configure the CUDA C++ standard using

if(NOT DEFINED CMAKE_CUDA_STANDARD)
    set(CMAKE_CUDA_STANDARD 11)
    set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()

and then link CUDA using

if(WIN32)
    target_link_libraries(gvdb PUBLIC cuda.lib)
elseif(UNIX)
    find_package(X11 REQUIRED)
    target_link_libraries(gvdb
        PUBLIC  cuda
                ${X11_LIBRARIES})
endif()

This should hopefully go down the second branch - UNIX seems to be defined for macOS platforms in CMake, right? (Maybe there's something else that needs to be done in the CMake file for macOS platforms?)

Thank you!

djspecialagent commented 4 years ago

Would be so awesome if gvdb could be run on Mac!

On Jul 31, 2020, at 2:55 PM, Neil Bickford notifications@github.com wrote:

 Hi GreenEminence!

This is interesting - do the samples that come with CUDA build for you (they should be in a folder such as /Developer/NVIDIA/CUDA-10.1/samples)? If so, then I'm guessing this is probably a bug in GVDB's new CMakeLists (atsource/gvdb_library/CMakeLists.txt) - it's been tested on Windows and Ubuntu, but not on macOS yet.

Looking at the CMakeLists.txt file, I'm not seeing anything that stands out so far as being a bug, though - we enable CUDA support using

project(gvdb LANGUAGES CUDA CXX C) configure the CUDA C++ standard using

if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 11) set(CMAKE_CUDA_STANDARD_REQUIRED ON) endif() and then link CUDA using

if(WIN32) target_link_libraries(gvdb PUBLIC cuda.lib) elseif(UNIX) find_package(X11 REQUIRED) target_link_libraries(gvdb PUBLIC cuda ${X11_LIBRARIES}) endif() This should hopefully go down the second branch - UNIX seems to be defined for macOS platforms in CMake, right? (Maybe there's something else that needs to be done in the CMake file for macOS platforms?)

Thank you!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

NBickford-NV commented 4 years ago

Hi all - just checking in on the questions in the previous post to see if there have been any updates!

Also, just quickly checking - is it possible this could be a compiler mismatch? On Mac OS, CUDA 10.1 update 2 requires a specific version of Xcode and the Clang compiler and toolchain - see https://docs.nvidia.com/cuda/archive/10.1/cuda-installation-guide-mac-os-x/index.html#system-requirements. You can verify your installation using https://docs.nvidia.com/cuda/archive/10.1/cuda-installation-guide-mac-os-x/index.html#compiler-verification.

mateuszwojt commented 3 years ago

Hi @NeilBickford-NV sorry for such a late response. I couldn't make it link correctly on Mac, even after confirming all specific versions of the compiler and toolchains are correct. I think I'm gonna pass on this one, as developing anything CUDA-related on a Mac is becoming quite difficult due to lack of modern GPUs and driver support. Thanks a lot! Cheers!

NBickford-NV commented 3 years ago

Ah, OK, sorry about that!