Suppose my machine has GPUs with compute capabilities XX and YY. Having read:
I know I can call nvcc like so:
nvcc \
-o myapp \
-gencode arch=compute_XX,code=sm_XX \
myapp.cu
or like so:
nvcc \
-o myapp \
-gencode arch=compute_XX,code=sm_XX \
-gencode arch=compute_YY,code=sm_YY \
myapp.cu
for both GPUs. But - suppose I want to use the arch=native
option, which we got a few years back, instead of specifying individual values. It should be easier and more straightforward, yet - I can't seem to get it right:
$ nvcc -o myapp -gencode arch=native myapp.cu
nvcc fatal : Option '--generate-code arch=native', missing code
$ nvcc -o myapp -gencode arch=native,code=sm_89 myapp.cu
nvcc fatal : Unsupported gpu architecture 'native'
Note: Using CUDA 12.6' version of NVCC.
Suppose my machine has GPUs with compute capabilities XX and YY. Having read:
https://stackoverflow/a/35657430/1593077
I know I can call nvcc like so:
nvcc \
-o myapp \
-gencode arch=compute_XX,code=sm_XX \
myapp.cu
or like so:
nvcc \
-o myapp \
-gencode arch=compute_XX,code=sm_XX \
-gencode arch=compute_YY,code=sm_YY \
myapp.cu
for both GPUs. But - suppose I want to use the arch=native
option, which we got a few years back, instead of specifying individual values. It should be easier and more straightforward, yet - I can't seem to get it right:
$ nvcc -o myapp -gencode arch=native myapp.cu
nvcc fatal : Option '--generate-code arch=native', missing code
$ nvcc -o myapp -gencode arch=native,code=sm_89 myapp.cu
nvcc fatal : Unsupported gpu architecture 'native'
Note: Using CUDA 12.6' version of NVCC.
Share Improve this question asked Nov 15, 2024 at 20:52 einpoklumeinpoklum 133k80 gold badges422 silver badges867 bronze badges1 Answer
Reset to default 1It's actually easier than all that. Use:
nvcc -o myapp -arch=native myapp.cu
without a -gencode
argument.
Note that, as the CUDA Programming Guide states:
When
-arch=native
is specified, nvcc detects the visible GPUs on the system and generates codes for them, no PTX program will be generated for this option. It is a warning if there are no visible supported GPU on the system, and the default architecture will be used.