最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论