LeelaChessZero / lc0

The rewritten engine, originally for tensorflow. Now all other backends have been ported here.
GNU General Public License v3.0
2.38k stars 525 forks source link

rework selection of cuda build architecture #1905

Closed borg323 closed 1 year ago

borg323 commented 1 year ago

This pull request consists of 3 related parts:

  1. Adds support for using -arch=native for cuda code (if nvcc supports it). This is used by default unless -Dnative_cuda=false is passed to the build or code generation for a specific CC is requested with e.g. -Dcc_cuda=50.
  2. Disables fp16 cuda code that breaks the build when compiling for a CC less than 5.3 - this is needed to make -arch=native work even on older gpus.
  3. Passes -Dnative_cuda=false to appveyor builds in order to generate code for multiple gpu architectures.
whelanh commented 1 year ago

Compiling this using Windows, I received the following error message: meson.build:507:26: ERROR: The == operator of str does not accept objects of type list ([]) meson-log.txt

borg323 commented 1 year ago

@whelanh can you try the following fix?

--- a/meson.build
+++ b/meson.build
@@ -484,7 +484,7 @@ if get_option('build_backends')
     if cuda_cc != ''
       nvcc_extra_args = ['-arch=compute_' + cuda_cc, '-code=sm_' + cuda_cc]
     elif get_option('native_cuda') and nvcc_help.contains('-arch=native')
-      nvcc_extra_args = '-arch=native'
+      nvcc_extra_args = ['-arch=native']
     endif
     foreach x : get_option('cudnn_include')
       cuda_arguments += ['-I', x]
whelanh commented 1 year ago

I did try that correction of line 487 changing to:

nvcc_extra_args = ['-arch=native']

and it compiles fine without any errors. Kind regards, Hugh Whelan

On Sat, Jul 29, 2023 at 9:06 PM borg323 @.***> wrote:

@whelanh https://github.com/whelanh can you try the following fix?

--- a/meson.build+++ b/meson.build@@ -484,7 +484,7 @@ if get_option('build_backends') if cuda_cc != '' nvcc_extraargs = ['-arch=compute' + cudacc, '-code=sm' + cuda_cc] elif get_option('native_cuda') and nvcc_help.contains('-arch=native')- nvcc_extra_args = '-arch=native'+ nvcc_extra_args = ['-arch=native'] endif foreach x : get_option('cudnn_include') cuda_arguments += ['-I', x]

— Reply to this email directly, view it on GitHub https://github.com/LeelaChessZero/lc0/pull/1905#issuecomment-1656987009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2JOXNGHNQK37SLHRCHT43XSWXRDANCNFSM6AAAAAA222AELE . You are receiving this because you were mentioned.Message ID: @.***>