最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

compiler errors - If I tell NVCC to -gencode arch=native, what do I use for the code= argument? - Stack Overflow

matteradmin7PV0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

It'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.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far