-
-
Notifications
You must be signed in to change notification settings - Fork 818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes doesn't link when compiling cuda programs #6089
Comments
Try |
It works for me. ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.594s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.425s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.437s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.423s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.487s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.503s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake -r
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 2.72s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/c |
This should be a problem with incremental compilation, although I can't reproduce it here. ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake
checking for Cuda SDK directory ... /usr/local/cuda
[ 50%]: compiling.release src/main.cu
[ 75%]: devlinking.release cuda_console_gpucode.cu.o
[ 75%]: linking.release cuda_console
[100%]: build ok, spent 11.005s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake
[100%]: build ok, spent 0.058s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake
[100%]: build ok, spent 0.052s
ruki@73e655426012:/mnt/xmake/tests/projects/cuda/console$ xmake
[100%]: build ok, spent 0.08s you can run or debug
|
To reproduce the problem, I think maybe you can use the following file structure: |
I cannot build it. [ 24%]: cache compiling.release ntt/src/inplace_transpose/common/gcd.cpp
[ 25%]: cache compiling.release runtime/tests/simple_json.cpp
[ 26%]: compiling.release ntt/tests/test-4step.cu
[ 26%]: compiling.release ntt/tests/test-big.cu
[ 26%]: compiling.release ntt/src/inplace_transpose/cuda/introspect.cu
[ 26%]: compiling.release ntt/src/inplace_transpose/common/reduced_math.cu
[ 26%]: compiling.release ntt/src/inplace_transpose/cuda/timer.cu
[ 26%]: compiling.release ntt/tests/test-int.cu
error: /usr/local/cuda/include/cuda/std/barrier:15:4: error: #error "CUDA synchronization primitives are only supported for sm_70 and up."
15 | # error "CUDA synchronization primitives are only supported for sm_70 and up."
| ^~~~~
In file included from /usr/local/cuda/include/cuda/std/detail/libcxx/include/barrier:459,
from /usr/local/cuda/include/cuda/std/barrier:30:
/usr/local/cuda/include/cuda/std/__cuda/barrier.h:17:4: error: #error "CUDA synchronization primitives are only supported for sm_70 and up."
17 | # error "CUDA synchronization primitives are only supported for sm_70 and up."
| ^~~~~
> in ntt/tests/test-big.cu
warning: failed to find cuda devices: cudaErrorInsufficientDriver (CUDA driver version is insufficient for CUDA runtime version) Did you provide a minimal example project? |
May be you can try this by modifying a.cuh a little each time and rerun
|
try this patch. #6104 xmake update -s dev ruki@73e655426012:/tmp/testcu$ rm -rf build/; xmake; sleep 1; touch a.cuh; sleep 1; xmake
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.147s
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.216s
ruki@73e655426012:/tmp/testcu$ rm -rf build/; xmake; sleep 1; touch a.cuh; sleep 1; xmake
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.292s
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.273s
ruki@73e655426012:/tmp/testcu$ rm -rf build/; xmake; sleep 1; touch a.cuh; sleep 1; xmake
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.24s
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.245s
ruki@73e655426012:/tmp/testcu$ touch a.cuh
ruki@73e655426012:/tmp/testcu$ xmake
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.227s
ruki@73e655426012:/tmp/testcu$ touch a.cuh
ruki@73e655426012:/tmp/testcu$ xmake
[ 50%]: compiling.release a.cu
[ 75%]: devlinking.release test_gpucode.cu.o
[ 75%]: linking.release test
[100%]: build ok, spent 1.241s |
Thanks! It worked. |
Xmake Version
v2.9.6+20241218
Operating System Version and Architecture
Ubuntu 20.04
Describe Bug
Sometimes when compiling the Cuda program, the xmake won't link the program, and I have to call xmake again to let it do the linking.
Expected Behavior
The xmake should link the program at the first run
Project Configuration
target("bench-mont")
set_languages(("c++17"))
add_cugencodes("native")
add_options("-lineinfo")
add_options("--expt-relaxed-constexpr")
add_files("mont/tests/bench.cu")
Additional Information and Error Logs
[ 50%]: compiling.release mont/tests/bench.cu
/usr/local/cuda/bin/nvcc -c -Xcompiler -fPIE -O3 -I/usr/local/cuda/include --std c++17 -m64 -rdc=true -ccbin=gcc-11 -gencode arch=compute_80,code=sm_80 -DNDEBUG -o build/.objs/bench-mont/linux/x86_64/release/mont/tests/bench.cu.o mont/tests/bench.cu
checking for the cuda linker (culd) ... nvcc
[ 75%]: devlinking.release bench-mont_gpucode.cu.o
/usr/local/cuda/bin/nvcc -o build/.objs/bench-mont/linux/x86_64/release/rules/cuda/devlink/bench-mont_gpucode.cu.o build/.objs/bench-mont/linux/x86_64/release/mont/tests/bench.cu.o -L/usr/local/cuda/lib64 -lcudadevrt -lcudart_static -lrt -lpthread -ldl -m64 -ccbin=gcc-11 -gencode arch=compute_80,code=sm_80 -dlink
checking for the linker (ld) ... g++
checking for flags (-Wl,-rpath=/usr/local/cuda/lib64) ... ok
build cache stats:
cache directory: build/.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s
[100%]: build ok, spent 5.724s
The text was updated successfully, but these errors were encountered: