ingowald / optix7course

Apache License 2.0
452 stars 80 forks source link

BIN2C-NOTFOUND: not found - debug build #28

Closed kfiros1 closed 2 years ago

kfiros1 commented 2 years ago

Hi,

Thanks for this great project.

I succeed build and run the whole project in release mode, however, when I try to debug it, I cant build it successfully. I've tried to debug it using CLion IDE from remote host (by deployment).

The problem occurs from ex02 onwards (ex01 is just loading the Optix and it works correctly for both release and debug).

For ex02: in Release mode, it builds it and runs successfully:

====================[ Build | ex02_pipelineAndRayGen | Release ]================
/usr/local/bin/cmake --build /home/kfir/code/optix7course/cmake-build-release --target ex02_pipelineAndRayGen -- -j 6
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kfir/code/optix7course/cmake-build-release
Consolidate compiler generated dependencies of target gdt
[ 25%] Built target gdt
Consolidate compiler generated dependencies of target ex02_pipelineAndRayGen
[100%] Built target ex02_pipelineAndRayGen

in Debug mode, it doesnt recognize BIN2C-NOTFOUND:

====================[ Build | ex02_pipelineAndRayGen | Debug ]==================
/usr/local/bin/cmake --build /home/kfir/code/optix7course/cmake-build-debug --target ex02_pipelineAndRayGen -- -j 6
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kfir/code/optix7course/cmake-build-debug
Consolidate compiler generated dependencies of target gdt
[ 25%] Built target gdt
[ 37%] compiling (and embedding ptx from) devicePrograms.cu
**/bin/sh: 1: BIN2C-NOTFOUND: not found**
example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/build.make:73: recipe for target 'example02_pipelineAndRayGen/cuda_compile_ptx_1_generated_devicePrograms.cu.ptx_embedded.c' failed
make[3]: *** [example02_pipelineAndRayGen/cuda_compile_ptx_1_generated_devicePrograms.cu.ptx_embedded.c] Error 127
make[3]: *** Deleting file 'example02_pipelineAndRayGen/cuda_compile_ptx_1_generated_devicePrograms.cu.ptx_embedded.c'
CMakeFiles/Makefile2:407: recipe for target 'example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/all' failed
make[2]: *** [example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/all] Error 2
CMakeFiles/Makefile2:414: recipe for target 'example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/rule' failed
make[1]: *** [example02_pipelineAndRayGen/CMakeFiles/ex02_pipelineAndRayGen.dir/rule] Error 2
Makefile:163: recipe for target 'ex02_pipelineAndRayGen' failed
make: *** [ex02_pipelineAndRayGen] Error 2

I guess the problem is: /bin/sh: 1: BIN2C-NOTFOUND: not found

In the CMAKE, it seems that this line is the problematic: find_program(BIN2C bin2c DOC "Path to the cuda-sdk bin2c executable.")

Do I need to locate some library? is this something about the cuda library? So why in release it works and debug mode does not? What do I miss?

Notes:

Thanks, Kfir

ingowald commented 2 years ago

Hey, Kfir,

bin2c is a tool that comes with CUDA; it takes a binary binary file (in our case, the PTX output from compiling the device code), and creates as output a c file that contains a string whose value is the same as that binary file. We use this to "fuse" the compiled PTX code into the binary by compiliing and linking to that C file (then we can use that PTX string as symbol, without having to deal with paths to fine and read that file).

The reason that ex01 still works without bin2c is that the first sample doesn't actually use any device code, yet; so that is OK. Ex02 and ongoing however will need it, because these do have device code.

As said bin2c comes with CUDA; if you have a cuda install (and have cuda in your path), then bin2c should also be in that path; it shold be in the same locatoin as nvcc. So; what I assume is that you have some "funky" cuda install where for some reason nvcc can be found, but bin2c cannot. The only thing that confuses me is that you're saying it works in release mode, but not in debug!? That doesn't make sense - either cmake can find bin2c, or it can't - it's the same tool, and in the cmake scripts gets used in the same way.

One simply thing I'd try first though is removing the CMakeCache.txt, and running the cmake call again, without -j (just in case). And of course, check if bin2c is in the path. (The upper-case BIN2C_NOTFOUND is cmake's way of telling you that the variable 'BIN2C" (which shold point to that binary) couldn't be computed, i.e., that bin2c couldn't be found).

kfiros1 commented 2 years ago

Hi,

Thanks for the answer. I agree, this is very strange that Release can find it and Debug not, but that's what's happening! I'm not sure why this happens but you gave me the idea to check CMakeCache.txt for both.

I saw that in CMakeCache.txt in the release: BIN2C:FILEPATH=/usr/local/cuda/bin/bin2c

In debug it was NOTFOUND, so I set it manually in configure_optix.cmake: set(BIN2C /usr/local/cuda/bin/bin2c)

instead of: find_program(BIN2C bin2c DOC "Path to the cuda-sdk bin2c executable.")

Now it works for both.

Thanks a lot, Kfir

bipul-mohanto commented 2 years ago

I had the exact same problem, but for my case both BUILD and RELEASE gave BIN2C NOT FOUND. I followed @kfiros1 first option, manually edit the CMakeCache.txt. Its working, thanks a lot @kfiros1 .