question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Separate compilation not working on Windows

See original GitHub issue

The following code runs fine on Linux but fails on Windows:

import cupy
kernel = cupy.RawKernel('extern "C" __global__ void test() {}', 'test', backend='nvcc', enable_cooperative_groups=True)
kernel.compile()

Error raised in Windows:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cupy\core\raw.pyx", line 282, in cupy.core.raw.RawKernel.compile
  File "cupy\core\raw.pyx", line 110, in cupy.core.raw.RawKernel._kernel
  File "cupy\cuda\function.pyx", line 234, in cupy.cuda.function.Module.get_function
  File "cupy\cuda\function.pyx", line 175, in cupy.cuda.function.Function.__init__
  File "cupy_backends\cuda\api\driver.pyx", line 262, in cupy_backends.cuda.api.driver.moduleGetFunction
  File "cupy_backends\cuda\api\driver.pyx", line 124, in cupy_backends.cuda.api.driver.check_status
cupy_backends.cuda.api.driver.CUDADriverError: CUDA_ERROR_NOT_FOUND: named symbol not found

Internally, the above code does the following nvcc separate compilation:

nvcc -gencode=arch=compute_70,code=sm_70 -ftz=true -rdc=true -Xcompiler -fPIC -shared -o test_rdc.o test.cu
nvcc -gencode=arch=compute_70,code=sm_70 --cubin -ftz=true -rdc=true -Xcompiler -fPIC -shared test_rdc.o --device-link -o test_rdc.cubin

It generates a correct cubin on Linux:

% cuobjdump -symbols test_rdc.cubin

symbols:
STT_FUNC         STB_GLOBAL STO_ENTRY      test

But on Windows it generates an empty (?) cubin, which is causing named symbol not found error:

C:\Users\chainer\Documents>cuobjdump -all -symbols test_rdc.cubin

symbols:

It seems we need some other commands to do separate compilation on Windows.

cc/ @leofang @anaruse

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
kmaehashicommented, Dec 21, 2020

--device-c magically solved the issue! (#4470) Thank you very much 👍🏼

1reaction
anarusecommented, Dec 10, 2020

I don’t know well about Windows, but the Windows compiler probably dosen’t have a -fPIC option, does it?

nvcc -gencode=arch=compute_70,code=sm_70 -ftz=true -rdc=true -Xcompiler -fPIC -shared -o test_rdc.o test.cu
nvcc -gencode=arch=compute_70,code=sm_70 --cubin -ftz=true -rdc=true -Xcompiler -fPIC -shared test_rdc.o --device-link -o test_rdc.cubin
Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake CUDA separate compilation static lib link error on ...
I am using CMake to compile a CUDA project, which contains a static lib and a main file. MWE here. The directory is:....
Read more >
A formerly working Windows 10 program, that I compiled & ...
A program I had gotten to compile and run, suddenly developed a problem that made Windows not allow it to run anymore.
Read more >
Separate Compilation Tutorial
Include Files. This is a clumsy way to go about declaring functions that are implemented in a separate file. Can you think of...
Read more >
Separate Compilation
What are header files for? Multiple source file programs sound great, but there is a problem. While the compiler is willing to accept...
Read more >
Separate Compilation and Linking of CUDA C++ Device ...
I assume you're talking about https://github.com/serban/k.... I checked this out and as it is in the repo, the makefile is not setup to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found