pytorch

Форк
0
/
FindCUDAToolkit.cmake 
1072 строки · 37.4 Кб
1

2
# This module is back-ported from CMake 3.17 and above to work with CMake 3.10
3

4
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
5
# file Copyright.txt or https://cmake.org/licensing for details.
6

7
#[=======================================================================[.rst:
8
FindCUDAToolkit
9
---------------
10

11
.. versionadded:: 3.17
12

13
This script locates the NVIDIA CUDA toolkit and the associated libraries, but
14
does not require the ``CUDA`` language be enabled for a given project. This
15
module does not search for the NVIDIA CUDA Samples.
16

17
.. versionadded:: 3.19
18
  QNX support.
19

20
Search Behavior
21
^^^^^^^^^^^^^^^
22

23
The CUDA Toolkit search behavior uses the following order:
24

25
1. If the ``CUDA`` language has been enabled we will use the directory
26
   containing the compiler as the first search location for ``nvcc``.
27

28
2. If the ``CUDAToolkit_ROOT`` cmake configuration variable (e.g.,
29
   ``-DCUDAToolkit_ROOT=/some/path``) *or* environment variable is defined, it
30
   will be searched.  If both an environment variable **and** a
31
   configuration variable are specified, the *configuration* variable takes
32
   precedence.
33

34
   The directory specified here must be such that the executable ``nvcc`` or
35
   the appropriate ``version.txt`` file can be found underneath the specified
36
   directory.
37

38
3. If the CUDA_PATH environment variable is defined, it will be searched
39
   for ``nvcc``.
40

41
4. The user's path is searched for ``nvcc`` using :command:`find_program`.  If
42
   this is found, no subsequent search attempts are performed.  Users are
43
   responsible for ensuring that the first ``nvcc`` to show up in the path is
44
   the desired path in the event that multiple CUDA Toolkits are installed.
45

46
5. On Unix systems, if the symbolic link ``/usr/local/cuda`` exists, this is
47
   used.  No subsequent search attempts are performed.  No default symbolic link
48
   location exists for the Windows platform.
49

50
6. The platform specific default install locations are searched.  If exactly one
51
   candidate is found, this is used.  The default CUDA Toolkit install locations
52
   searched are:
53

54
   +-------------+-------------------------------------------------------------+
55
   | Platform    | Search Pattern                                              |
56
   +=============+=============================================================+
57
   | macOS       | ``/Developer/NVIDIA/CUDA-X.Y``                              |
58
   +-------------+-------------------------------------------------------------+
59
   | Other Unix  | ``/usr/local/cuda-X.Y``                                     |
60
   +-------------+-------------------------------------------------------------+
61
   | Windows     | ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y`` |
62
   +-------------+-------------------------------------------------------------+
63

64
   Where ``X.Y`` would be a specific version of the CUDA Toolkit, such as
65
   ``/usr/local/cuda-9.0`` or
66
   ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0``
67

68
   .. note::
69

70
       When multiple CUDA Toolkits are installed in the default location of a
71
       system(e.g., both ``/usr/local/cuda-9.0`` and ``/usr/local/cuda-10.0``
72
       exist but the ``/usr/local/cuda`` symbolic link does **not** exist), this
73
       package is marked as **not** found.
74

75
       There are too many factors involved in making an automatic decision in
76
       the presence of multiple CUDA Toolkits being installed.  In this
77
       situation, users are encouraged to either (1) set ``CUDAToolkit_ROOT`` or
78
       (2) ensure that the correct ``nvcc`` executable shows up in ``$PATH`` for
79
       :command:`find_program` to find.
80

81
Arguments
82
^^^^^^^^^
83

84
``[<version>]``
85
    The ``[<version>]`` argument requests a version with which the package found
86
    should be compatible. See :ref:`find_package version format <FIND_PACKAGE_VERSION_FORMAT>`
87
    for more details.
88

89
Options
90
^^^^^^^
91

92
``REQUIRED``
93
    If specified, configuration will error if a suitable CUDA Toolkit is not
94
    found.
95

96
``QUIET``
97
    If specified, the search for a suitable CUDA Toolkit will not produce any
98
    messages.
99

100
``EXACT``
101
    If specified, the CUDA Toolkit is considered found only if the exact
102
    ``VERSION`` specified is recovered.
103

104
Imported targets
105
^^^^^^^^^^^^^^^^
106

107
An :ref:`imported target <Imported targets>` named ``CUDA::toolkit`` is provided.
108

109
This module defines :prop_tgt:`IMPORTED` targets for each
110
of the following libraries that are part of the CUDAToolkit:
111

112
- :ref:`CUDA Runtime Library<cuda_toolkit_rt_lib>`
113
- :ref:`CUDA Driver Library<cuda_toolkit_driver_lib>`
114
- :ref:`cuBLAS<cuda_toolkit_cuBLAS>`
115
- :ref:`cuFFT<cuda_toolkit_cuFFT>`
116
- :ref:`cuRAND<cuda_toolkit_cuRAND>`
117
- :ref:`cuSOLVER<cuda_toolkit_cuSOLVER>`
118
- :ref:`cuSPARSE<cuda_toolkit_cuSPARSE>`
119
- :ref:`cuPTI<cuda_toolkit_cupti>`
120
- :ref:`NPP<cuda_toolkit_NPP>`
121
- :ref:`nvBLAS<cuda_toolkit_nvBLAS>`
122
- :ref:`nvGRAPH<cuda_toolkit_nvGRAPH>`
123
- :ref:`nvJPEG<cuda_toolkit_nvJPEG>`
124
- :ref:`nvidia-ML<cuda_toolkit_nvML>`
125
- :ref:`nvRTC<cuda_toolkit_nvRTC>`
126
- :ref:`nvToolsExt<cuda_toolkit_nvToolsExt>`
127
- :ref:`OpenCL<cuda_toolkit_opencl>`
128
- :ref:`cuLIBOS<cuda_toolkit_cuLIBOS>`
129

130
.. _`cuda_toolkit_rt_lib`:
131

132
CUDA Runtime Library
133
""""""""""""""""""""
134

135
The CUDA Runtime library (cudart) are what most applications will typically
136
need to link against to make any calls such as `cudaMalloc`, and `cudaFree`.
137

138
Targets Created:
139

140
- ``CUDA::cudart``
141
- ``CUDA::cudart_static``
142

143
.. _`cuda_toolkit_driver_lib`:
144

145
CUDA Driver Library
146
""""""""""""""""""""
147

148
The CUDA Driver library (cuda) are used by applications that use calls
149
such as `cuMemAlloc`, and `cuMemFree`.
150

151
Targets Created:
152

153
- ``CUDA::cuda_driver``
154

155
.. _`cuda_toolkit_cuBLAS`:
156

157
cuBLAS
158
""""""
159

160
The `cuBLAS <https://docs.nvidia.com/cuda/cublas/index.html>`_ library.
161

162
Targets Created:
163

164
- ``CUDA::cublas``
165
- ``CUDA::cublas_static``
166
- ``CUDA::cublasLt`` starting in CUDA 10.1
167
- ``CUDA::cublasLt_static`` starting in CUDA 10.1
168

169
.. _`cuda_toolkit_cuFFT`:
170

171
cuFFT
172
"""""
173

174
The `cuFFT <https://docs.nvidia.com/cuda/cufft/index.html>`_ library.
175

176
Targets Created:
177

178
- ``CUDA::cufft``
179
- ``CUDA::cufftw``
180
- ``CUDA::cufft_static``
181
- ``CUDA::cufft_static_nocallback`` starting in CUDA 9.2, requires CMake 3.23+
182
- ``CUDA::cufftw_static``
183

184
cuRAND
185
""""""
186

187
The `cuRAND <https://docs.nvidia.com/cuda/curand/index.html>`_ library.
188

189
Targets Created:
190

191
- ``CUDA::curand``
192
- ``CUDA::curand_static``
193

194
.. _`cuda_toolkit_cuSOLVER`:
195

196
cuSOLVER
197
""""""""
198

199
The `cuSOLVER <https://docs.nvidia.com/cuda/cusolver/index.html>`_ library.
200

201
Targets Created:
202

203
- ``CUDA::cusolver``
204
- ``CUDA::cusolver_static``
205

206
.. _`cuda_toolkit_cuSPARSE`:
207

208
cuSPARSE
209
""""""""
210

211
The `cuSPARSE <https://docs.nvidia.com/cuda/cusparse/index.html>`_ library.
212

213
Targets Created:
214

215
- ``CUDA::cusparse``
216
- ``CUDA::cusparse_static``
217

218
.. _`cuda_toolkit_cupti`:
219

220
cupti
221
"""""
222

223
The `NVIDIA CUDA Profiling Tools Interface <https://developer.nvidia.com/CUPTI>`_.
224

225
Targets Created:
226

227
- ``CUDA::cupti``
228
- ``CUDA::cupti_static``
229

230
.. _`cuda_toolkit_NPP`:
231

232
NPP
233
"""
234

235
The `NPP <https://docs.nvidia.com/cuda/npp/index.html>`_ libraries.
236

237
Targets Created:
238

239
- `nppc`:
240

241
  - ``CUDA::nppc``
242
  - ``CUDA::nppc_static``
243

244
- `nppial`: Arithmetic and logical operation functions in `nppi_arithmetic_and_logical_operations.h`
245

246
  - ``CUDA::nppial``
247
  - ``CUDA::nppial_static``
248

249
- `nppicc`: Color conversion and sampling functions in `nppi_color_conversion.h`
250

251
  - ``CUDA::nppicc``
252
  - ``CUDA::nppicc_static``
253

254
- `nppicom`: JPEG compression and decompression functions in `nppi_compression_functions.h`
255
  Removed starting in CUDA 11.0, use :ref:`nvJPEG<cuda_toolkit_nvJPEG>` instead.
256

257
  - ``CUDA::nppicom``
258
  - ``CUDA::nppicom_static``
259

260
- `nppidei`: Data exchange and initialization functions in `nppi_data_exchange_and_initialization.h`
261

262
  - ``CUDA::nppidei``
263
  - ``CUDA::nppidei_static``
264

265
- `nppif`: Filtering and computer vision functions in `nppi_filter_functions.h`
266

267
  - ``CUDA::nppif``
268
  - ``CUDA::nppif_static``
269

270
- `nppig`: Geometry transformation functions found in `nppi_geometry_transforms.h`
271

272
  - ``CUDA::nppig``
273
  - ``CUDA::nppig_static``
274

275
- `nppim`: Morphological operation functions found in `nppi_morphological_operations.h`
276

277
  - ``CUDA::nppim``
278
  - ``CUDA::nppim_static``
279

280
- `nppist`: Statistics and linear transform in `nppi_statistics_functions.h` and `nppi_linear_transforms.h`
281

282
  - ``CUDA::nppist``
283
  - ``CUDA::nppist_static``
284

285
- `nppisu`: Memory support functions in `nppi_support_functions.h`
286

287
  - ``CUDA::nppisu``
288
  - ``CUDA::nppisu_static``
289

290
- `nppitc`: Threshold and compare operation functions in `nppi_threshold_and_compare_operations.h`
291

292
  - ``CUDA::nppitc``
293
  - ``CUDA::nppitc_static``
294

295
- `npps`:
296

297
  - ``CUDA::npps``
298
  - ``CUDA::npps_static``
299

300
.. _`cuda_toolkit_nvBLAS`:
301

302
nvBLAS
303
""""""
304

305
The `nvBLAS <https://docs.nvidia.com/cuda/nvblas/index.html>`_ libraries.
306
This is a shared library only.
307

308
Targets Created:
309

310
- ``CUDA::nvblas``
311

312
.. _`cuda_toolkit_nvGRAPH`:
313

314
nvGRAPH
315
"""""""
316

317
The `nvGRAPH <https://docs.nvidia.com/cuda/nvgraph/index.html>`_ library.
318
Removed starting in CUDA 11.0
319

320
Targets Created:
321

322
- ``CUDA::nvgraph``
323
- ``CUDA::nvgraph_static``
324

325

326
.. _`cuda_toolkit_nvJPEG`:
327

328
nvJPEG
329
""""""
330

331
The `nvJPEG <https://docs.nvidia.com/cuda/nvjpeg/index.html>`_ library.
332
Introduced in CUDA 10.
333

334
Targets Created:
335

336
- ``CUDA::nvjpeg``
337
- ``CUDA::nvjpeg_static``
338

339
.. _`cuda_toolkit_nvRTC`:
340

341
nvRTC
342
"""""
343

344
The `nvRTC <https://docs.nvidia.com/cuda/nvrtc/index.html>`_ (Runtime Compilation) library.
345
This is a shared library only.
346

347
Targets Created:
348

349
- ``CUDA::nvrtc``
350

351
.. _`cuda_toolkit_nvml`:
352

353
nvidia-ML
354
"""""""""
355

356
The `NVIDIA Management Library <https://developer.nvidia.com/nvidia-management-library-nvml>`_.
357
This is a shared library only.
358

359
Targets Created:
360

361
- ``CUDA::nvml``
362

363
.. _`cuda_toolkit_nvToolsExt`:
364

365
nvToolsExt
366
""""""""""
367

368
The `NVIDIA Tools Extension <https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm>`_.
369
This is a shared library only.
370

371
Targets Created:
372

373
- ``CUDA::nvToolsExt``
374

375
.. _`cuda_toolkit_opencl`:
376

377
OpenCL
378
""""""
379

380
The `NVIDIA OpenCL Library <https://developer.nvidia.com/opencl>`_.
381
This is a shared library only.
382

383
Targets Created:
384

385
- ``CUDA::OpenCL``
386

387
.. _`cuda_toolkit_cuLIBOS`:
388

389
cuLIBOS
390
"""""""
391

392
The cuLIBOS library is a backend thread abstraction layer library which is
393
static only.  The ``CUDA::cublas_static``, ``CUDA::cusparse_static``,
394
``CUDA::cufft_static``, ``CUDA::curand_static``, and (when implemented) NPP
395
libraries all automatically have this dependency linked.
396

397
Target Created:
398

399
- ``CUDA::culibos``
400

401
**Note**: direct usage of this target by consumers should not be necessary.
402

403
.. _`cuda_toolkit_cuRAND`:
404

405

406

407
Result variables
408
^^^^^^^^^^^^^^^^
409

410
``CUDAToolkit_FOUND``
411
    A boolean specifying whether or not the CUDA Toolkit was found.
412

413
``CUDAToolkit_VERSION``
414
    The exact version of the CUDA Toolkit found (as reported by
415
    ``nvcc --version`` or ``version.txt``).
416

417
``CUDAToolkit_VERSION_MAJOR``
418
    The major version of the CUDA Toolkit.
419

420
``CUDAToolkit_VERSION_MINOR``
421
    The minor version of the CUDA Toolkit.
422

423
``CUDAToolkit_VERSION_PATCH``
424
    The patch version of the CUDA Toolkit.
425

426
``CUDAToolkit_BIN_DIR``
427
    The path to the CUDA Toolkit library directory that contains the CUDA
428
    executable ``nvcc``.
429

430
``CUDAToolkit_INCLUDE_DIRS``
431
    The path to the CUDA Toolkit ``include`` folder containing the header files
432
    required to compile a project linking against CUDA.
433

434
``CUDAToolkit_LIBRARY_DIR``
435
    The path to the CUDA Toolkit library directory that contains the CUDA
436
    Runtime library ``cudart``.
437

438
``CUDAToolkit_LIBRARY_ROOT``
439
    .. versionadded:: 3.18
440

441
    The path to the CUDA Toolkit directory containing the nvvm directory and
442
    version.txt.
443

444
``CUDAToolkit_TARGET_DIR``
445
    The path to the CUDA Toolkit directory including the target architecture
446
    when cross-compiling. When not cross-compiling this will be equivalent to
447
    the parent directory of ``CUDAToolkit_BIN_DIR``.
448

449
``CUDAToolkit_NVCC_EXECUTABLE``
450
    The path to the NVIDIA CUDA compiler ``nvcc``.  Note that this path may
451
    **not** be the same as
452
    :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>`.  ``nvcc`` must be
453
    found to determine the CUDA Toolkit version as well as determining other
454
    features of the Toolkit.  This variable is set for the convenience of
455
    modules that depend on this one.
456

457

458
#]=======================================================================]
459

460
# NOTE: much of this was simply extracted from FindCUDA.cmake.
461

462
#   James Bigler, NVIDIA Corp (nvidia.com - jbigler)
463
#   Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
464
#
465
#   Copyright (c) 2008 - 2009 NVIDIA Corporation.  All rights reserved.
466
#
467
#   Copyright (c) 2007-2009
468
#   Scientific Computing and Imaging Institute, University of Utah
469
#
470
#   This code is licensed under the MIT License.  See the FindCUDA.cmake script
471
#   for the text of the license.
472

473
# The MIT License
474
#
475
# License for the specific language governing rights and limitations under
476
# Permission is hereby granted, free of charge, to any person obtaining a
477
# copy of this software and associated documentation files (the "Software"),
478
# to deal in the Software without restriction, including without limitation
479
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
480
# and/or sell copies of the Software, and to permit persons to whom the
481
# Software is furnished to do so, subject to the following conditions:
482
#
483
# The above copyright notice and this permission notice shall be included
484
# in all copies or substantial portions of the Software.
485
#
486
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
487
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
488
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
489
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
490
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
491
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
492
# DEALINGS IN THE SOFTWARE.
493
#
494
###############################################################################
495

496
# The toolkit is located during compiler detection for CUDA and stored in CMakeCUDACompiler.cmake as
497
# CMAKE_CUDA_COMPILER_TOOLKIT_ROOT and CMAKE_CUDA_COMPILER_LIBRARY_ROOT.
498
# We compute the rest based on those here to avoid re-searching and to avoid finding a possibly
499
# different installation.
500
if(CMAKE_CUDA_COMPILER_TOOLKIT_ROOT)
501
  set(CUDAToolkit_ROOT_DIR "${CMAKE_CUDA_COMPILER_TOOLKIT_ROOT}")
502
  set(CUDAToolkit_LIBRARY_ROOT "${CMAKE_CUDA_COMPILER_LIBRARY_ROOT}")
503
  set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_TOOLKIT_VERSION}")
504

505
  if(CUDAToolkit_VERSION MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
506
    set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
507
    set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
508
    set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
509
  endif()
510
else()
511
  function(_CUDAToolkit_find_root_dir )
512
    cmake_parse_arguments(arg "" "" "SEARCH_PATHS;FIND_FLAGS" ${ARGN})
513

514
    if(NOT CUDAToolkit_BIN_DIR)
515
      if(NOT CUDAToolkit_SENTINEL_FILE)
516
        find_program(CUDAToolkit_NVCC_EXECUTABLE
517
          NAMES nvcc nvcc.exe
518
          PATHS ${arg_SEARCH_PATHS}
519
          ${arg_FIND_FLAGS}
520
        )
521
      endif()
522

523
      if(NOT CUDAToolkit_NVCC_EXECUTABLE)
524
        find_file(CUDAToolkit_SENTINEL_FILE
525
          NAMES version.txt
526
          PATHS ${arg_SEARCH_PATHS}
527
          NO_DEFAULT_PATH
528
        )
529
      endif()
530

531
      if(EXISTS "${CUDAToolkit_NVCC_EXECUTABLE}")
532
        # If NVCC exists  then invoke it to find the toolkit location.
533
        # This allows us to support wrapper scripts (e.g. ccache or colornvcc), CUDA Toolkit,
534
        # NVIDIA HPC SDK, and distro's splayed layouts
535
        execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "-v" "__cmake_determine_cuda"
536
          OUTPUT_VARIABLE _CUDA_NVCC_OUT ERROR_VARIABLE _CUDA_NVCC_OUT)
537
        if(_CUDA_NVCC_OUT MATCHES "\\#\\$ TOP=([^\r\n]*)")
538
          get_filename_component(CUDAToolkit_BIN_DIR "${CMAKE_MATCH_1}/bin" ABSOLUTE)
539
        else()
540
          get_filename_component(CUDAToolkit_BIN_DIR "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY)
541
        endif()
542
        unset(_CUDA_NVCC_OUT)
543

544
        mark_as_advanced(CUDAToolkit_BIN_DIR)
545
        set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE)
546
      endif()
547

548
      if(CUDAToolkit_SENTINEL_FILE)
549
        get_filename_component(CUDAToolkit_BIN_DIR ${CUDAToolkit_SENTINEL_FILE} DIRECTORY ABSOLUTE)
550
        set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}/bin")
551

552
        set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "" FORCE)
553
        mark_as_advanced(CUDAToolkit_BIN_DIR)
554
      endif()
555
    endif()
556

557
    if(CUDAToolkit_BIN_DIR)
558
      get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE)
559
      set(CUDAToolkit_ROOT_DIR "${CUDAToolkit_ROOT_DIR}" PARENT_SCOPE)
560
    endif()
561

562
  endfunction()
563

564
  # For NVCC we can easily deduce the SDK binary directory from the compiler path.
565
  if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
566
    get_filename_component(CUDAToolkit_BIN_DIR "${CMAKE_CUDA_COMPILER}" DIRECTORY)
567
    set(CUDAToolkit_BIN_DIR "${CUDAToolkit_BIN_DIR}" CACHE PATH "")
568
    # Try language provided path first.
569
    _CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_BIN_DIR}" FIND_FLAGS NO_DEFAULT_PATH)
570
    mark_as_advanced(CUDAToolkit_BIN_DIR)
571
  endif()
572

573
  # Try user provided path
574
  if(NOT CUDAToolkit_ROOT_DIR AND CUDAToolkit_ROOT)
575
    _CUDAToolkit_find_root_dir(SEARCH_PATHS "${CUDAToolkit_ROOT}" FIND_FLAGS PATH_SUFFIXES bin NO_DEFAULT_PATH)
576
  endif()
577
  if(NOT CUDAToolkit_ROOT_DIR)
578
    _CUDAToolkit_find_root_dir(FIND_FLAGS PATHS ENV CUDA_PATH PATH_SUFFIXES bin)
579
  endif()
580

581
  # If the user specified CUDAToolkit_ROOT but the toolkit could not be found, this is an error.
582
  if(NOT CUDAToolkit_ROOT_DIR AND (DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT}))
583
    # Declare error messages now, print later depending on find_package args.
584
    set(fail_base "Could not find nvcc executable in path specified by")
585
    set(cuda_root_fail "${fail_base} CUDAToolkit_ROOT=${CUDAToolkit_ROOT}")
586
    set(env_cuda_root_fail "${fail_base} environment variable CUDAToolkit_ROOT=$ENV{CUDAToolkit_ROOT}")
587

588
    if(CUDAToolkit_FIND_REQUIRED)
589
      if(DEFINED CUDAToolkit_ROOT)
590
        message(FATAL_ERROR ${cuda_root_fail})
591
      elseif(DEFINED ENV{CUDAToolkit_ROOT})
592
        message(FATAL_ERROR ${env_cuda_root_fail})
593
      endif()
594
    else()
595
      if(NOT CUDAToolkit_FIND_QUIETLY)
596
        if(DEFINED CUDAToolkit_ROOT)
597
          message(STATUS ${cuda_root_fail})
598
        elseif(DEFINED ENV{CUDAToolkit_ROOT})
599
          message(STATUS ${env_cuda_root_fail})
600
        endif()
601
      endif()
602
      set(CUDAToolkit_FOUND FALSE)
603
      unset(fail_base)
604
      unset(cuda_root_fail)
605
      unset(env_cuda_root_fail)
606
      return()
607
    endif()
608
  endif()
609

610
  # CUDAToolkit_ROOT cmake / env variable not specified, try platform defaults.
611
  #
612
  # - Linux: /usr/local/cuda-X.Y
613
  # - macOS: /Developer/NVIDIA/CUDA-X.Y
614
  # - Windows: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y
615
  #
616
  # We will also search the default symlink location /usr/local/cuda first since
617
  # if CUDAToolkit_ROOT is not specified, it is assumed that the symlinked
618
  # directory is the desired location.
619
  if(NOT CUDAToolkit_ROOT_DIR)
620
    if(UNIX)
621
      if(NOT APPLE)
622
        set(platform_base "/usr/local/cuda-")
623
      else()
624
        set(platform_base "/Developer/NVIDIA/CUDA-")
625
      endif()
626
    else()
627
      set(platform_base "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v")
628
    endif()
629

630
    # Build out a descending list of possible cuda installations, e.g.
631
    file(GLOB possible_paths "${platform_base}*")
632
    # Iterate the glob results and create a descending list.
633
    set(versions)
634
    foreach(p ${possible_paths})
635
      # Extract version number from end of string
636
      string(REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${p})
637
      if(IS_DIRECTORY ${p} AND p_version)
638
        list(APPEND versions ${p_version})
639
      endif()
640
    endforeach()
641

642
    # Sort numerically in descending order, so we try the newest versions first.
643
    if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
644
      list(SORT versions COMPARE NATURAL ORDER DESCENDING)
645
    elseif(versions)
646
      # Alphabetical sort here is not ideal but better than nothing
647
      list(SORT versions)
648
      list(REVERSE versions)
649
    endif()
650

651
    # With a descending list of versions, populate possible paths to search.
652
    set(search_paths)
653
    foreach(v ${versions})
654
      list(APPEND search_paths "${platform_base}${v}")
655
    endforeach()
656

657
    # Force the global default /usr/local/cuda to the front on Unix.
658
    if(UNIX)
659
      list(INSERT search_paths 0 "/usr/local/cuda")
660
    endif()
661

662
    # Now search for the toolkit again using the platform default search paths.
663
    _CUDAToolkit_find_root_dir(SEARCH_PATHS "${search_paths}" FIND_FLAGS PATH_SUFFIXES bin)
664

665
    # We are done with these variables now, cleanup for caller.
666
    unset(platform_base)
667
    unset(possible_paths)
668
    unset(versions)
669
    unset(search_paths)
670

671
    if(NOT CUDAToolkit_ROOT_DIR)
672
      if(CUDAToolkit_FIND_REQUIRED)
673
        message(FATAL_ERROR "Could not find nvcc, please set CUDAToolkit_ROOT.")
674
      elseif(NOT CUDAToolkit_FIND_QUIETLY)
675
        message(STATUS "Could not find nvcc, please set CUDAToolkit_ROOT.")
676
      endif()
677

678
      set(CUDAToolkit_FOUND FALSE)
679
      return()
680
    endif()
681
  endif()
682
endif()
683

684
if(NOT CUDAToolkit_BIN_DIR)
685
  set(CUDAToolkit_BIN_DIR "${CUDAToolkit_ROOT_DIR}/bin")
686
endif()
687

688
if(NOT CUDAToolkit_NVCC_EXECUTABLE)
689
  set(CUDAToolkit_NVCC_EXECUTABLE "${CUDAToolkit_BIN_DIR}/nvcc${CMAKE_EXECUTABLE_SUFFIX}")
690
endif()
691

692
if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION)
693
  set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_TOOLKIT_VERSION}")
694
else()
695
  function(_CUDAToolkit_find_version_file result_variable)
696
    # We first check for a non-scattered installation to prefer it over a scattered installation.
697
    if(CUDAToolkit_ROOT AND EXISTS "${CUDAToolkit_ROOT}/version.txt")
698
      set(${result_variable} "${CUDAToolkit_ROOT}/version.txt" PARENT_SCOPE)
699
    elseif(CUDAToolkit_ROOT_DIR AND EXISTS "${CUDAToolkit_ROOT_DIR}/version.txt")
700
      set(${result_variable} "${CUDAToolkit_ROOT_DIR}/version.txt" PARENT_SCOPE)
701
    elseif(CMAKE_SYSROOT_LINK AND EXISTS "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt")
702
      set(${result_variable} "${CMAKE_SYSROOT_LINK}/usr/lib/cuda/version.txt" PARENT_SCOPE)
703
    elseif(EXISTS "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt")
704
      set(${result_variable} "${CMAKE_SYSROOT}/usr/lib/cuda/version.txt" PARENT_SCOPE)
705
    endif()
706
  endfunction()
707

708
  _CUDAToolkit_find_version_file( _CUDAToolkit_version_file )
709
  if(_CUDAToolkit_version_file)
710
    # CUDAToolkit_LIBRARY_ROOT contains the device library and version file.
711
    get_filename_component(CUDAToolkit_LIBRARY_ROOT "${_CUDAToolkit_version_file}" DIRECTORY ABSOLUTE)
712
  endif()
713
  unset(_CUDAToolkit_version_file)
714

715
  if(CUDAToolkit_NVCC_EXECUTABLE AND
716
     CMAKE_CUDA_COMPILER_VERSION AND
717
     CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER)
718
    # Need to set these based off the already computed CMAKE_CUDA_COMPILER_VERSION value
719
    # This if statement will always match, but is used to provide variables for MATCH 1,2,3...
720
    if(CMAKE_CUDA_COMPILER_VERSION MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
721
      set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
722
      set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
723
      set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
724
      set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_VERSION}")
725
    endif()
726
  elseif(CUDAToolkit_NVCC_EXECUTABLE)
727
    # Compute the version by invoking nvcc
728
    execute_process(COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
729
    if(NVCC_OUT MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=])
730
      set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
731
      set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
732
      set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
733
      set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
734
    endif()
735
    unset(NVCC_OUT)
736
  else()
737
    _CUDAToolkit_find_version_file(version_file)
738
    if(version_file)
739
      file(READ "${version_file}" VERSION_INFO)
740
      if(VERSION_INFO MATCHES [=[CUDA Version ([0-9]+)\.([0-9]+)\.([0-9]+)]=])
741
        set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
742
        set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
743
        set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
744
        set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
745
      endif()
746
    endif()
747
  endif()
748
endif()
749

750
# Find target directory when crosscompiling.
751
if(CMAKE_CROSSCOMPILING)
752
  if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
753
    # Support for NVPACK
754
    set(CUDAToolkit_TARGET_NAME "armv7-linux-androideabi")
755
  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
756
    set(CUDAToolkit_TARGET_NAME "armv7-linux-gnueabihf")
757
  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
758
    if(ANDROID_ARCH_NAME STREQUAL "arm64")
759
      set(CUDAToolkit_TARGET_NAME "aarch64-linux-androideabi")
760
    elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
761
      set(CUDAToolkit_TARGET_NAME "aarch64-qnx")
762
    else()
763
      set(CUDAToolkit_TARGET_NAME "aarch64-linux")
764
    endif(ANDROID_ARCH_NAME STREQUAL "arm64")
765
  elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
766
    set(CUDAToolkit_TARGET_NAME "x86_64-linux")
767
  endif()
768

769
  if(EXISTS "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
770
    set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}/targets/${CUDAToolkit_TARGET_NAME}")
771
    # add known CUDA target root path to the set of directories we search for programs, libraries and headers
772
    list(PREPEND CMAKE_FIND_ROOT_PATH "${CUDAToolkit_TARGET_DIR}")
773

774
    # Mark that we need to pop the root search path changes after we have
775
    # found all cuda libraries so that searches for our cross-compilation
776
    # libraries work when another cuda sdk is in CMAKE_PREFIX_PATH or
777
    # PATh
778
    set(_CUDAToolkit_Pop_ROOT_PATH True)
779
  endif()
780
endif()
781

782
# If not already set we can simply use the toolkit root or it's a scattered installation.
783
if(NOT CUDAToolkit_TARGET_DIR)
784
  # Not cross compiling
785
  set(CUDAToolkit_TARGET_DIR "${CUDAToolkit_ROOT_DIR}")
786
  # Now that we have the real ROOT_DIR, find components inside it.
787
  list(APPEND CMAKE_PREFIX_PATH ${CUDAToolkit_ROOT_DIR})
788

789
  # Mark that we need to pop the prefix path changes after we have
790
  # found the cudart library.
791
  set(_CUDAToolkit_Pop_Prefix True)
792
endif()
793

794
# CUDAToolkit_TARGET_DIR always points to the directory containing the include directory.
795
# On a scattered installation /usr, on a non-scattered something like /usr/local/cuda or /usr/local/cuda-10.2/targets/aarch64-linux.
796
if(EXISTS "${CUDAToolkit_TARGET_DIR}/include/cuda_runtime.h")
797
  set(CUDAToolkit_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/include")
798
elseif(NOT CUDAToolkit_FIND_QUIETLY)
799
  message(STATUS "Unable to find cuda_runtime.h in \"${CUDAToolkit_TARGET_DIR}/include\" for CUDAToolkit_INCLUDE_DIR.")
800
endif()
801

802
# The NVHPC layout moves math library headers and libraries to a sibling directory.
803
# Create a separate variable so this directory can be selectively added to math targets.
804
if(NOT EXISTS "${CUDAToolkit_INCLUDE_DIR}/cublas_v2.h")
805
  set(CUDAToolkit_MATH_INCLUDE_DIR "${CUDAToolkit_TARGET_DIR}/../../math_libs/include")
806
  get_filename_component(CUDAToolkit_MATH_INCLUDE_DIR "${CUDAToolkit_MATH_INCLUDE_DIR}" ABSOLUTE)
807
  if(NOT EXISTS "${CUDAToolkit_MATH_INCLUDE_DIR}/cublas_v2.h")
808
    if(NOT CUDAToolkit_FIND_QUIETLY)
809
      message(STATUS "Unable to find cublas_v2.h in either \"${CUDAToolkit_INCLUDE_DIR}\" or \"${CUDAToolkit_MATH_INCLUDE_DIR}\"")
810
    endif()
811
    unset(CUDAToolkit_MATH_INCLUDE_DIR)
812
  endif()
813
endif()
814

815
# Find the CUDA Runtime Library libcudart
816
find_library(CUDA_CUDART
817
  NAMES cudart
818
  PATH_SUFFIXES lib64 lib/x64
819
)
820
find_library(CUDA_CUDART
821
  NAMES cudart
822
  PATH_SUFFIXES lib64/stubs lib/x64/stubs
823
)
824

825
if(NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY)
826
  message(STATUS "Unable to find cudart library.")
827
endif()
828

829
if(_CUDAToolkit_Pop_Prefix)
830
  list(REMOVE_AT CMAKE_PREFIX_PATH -1)
831
  unset(_CUDAToolkit_Pop_Prefix)
832
endif()
833

834
#-----------------------------------------------------------------------------
835
# Perform version comparison and validate all required variables are set.
836
include(FindPackageHandleStandardArgs)
837
find_package_handle_standard_args(CUDAToolkit
838
  REQUIRED_VARS
839
    CUDAToolkit_INCLUDE_DIR
840
    CUDAToolkit_VERSION
841
    CUDA_CUDART
842
    CUDAToolkit_BIN_DIR
843
  VERSION_VAR
844
    CUDAToolkit_VERSION
845
)
846

847
mark_as_advanced(CUDA_CUDART
848
                 CUDAToolkit_INCLUDE_DIR
849
                 CUDAToolkit_NVCC_EXECUTABLE
850
                 CUDAToolkit_SENTINEL_FILE
851
                 )
852

853
#-----------------------------------------------------------------------------
854
# Construct result variables
855
if(CUDAToolkit_FOUND)
856
  set(CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIR})
857
  get_filename_component(CUDAToolkit_LIBRARY_DIR ${CUDA_CUDART} DIRECTORY ABSOLUTE)
858
endif()
859

860
#-----------------------------------------------------------------------------
861
# Construct import targets
862
if(CUDAToolkit_FOUND)
863

864
  function(_CUDAToolkit_find_and_add_import_lib lib_name)
865
    cmake_parse_arguments(arg "" "" "ALT;DEPS;EXTRA_HINTS;EXTRA_PATH_SUFFIXES;EXTRA_INCLUDE_DIRS" ${ARGN})
866

867
    set(search_names ${lib_name} ${arg_ALT})
868

869
    find_library(CUDA_${lib_name}_LIBRARY
870
      NAMES ${search_names}
871
      HINTS ${CUDAToolkit_LIBRARY_DIR}
872
            ENV CUDA_PATH
873
            ${arg_EXTRA_HINTS}
874
      PATH_SUFFIXES nvidia/current lib64 lib/x64 lib
875
                    ${arg_EXTRA_PATH_SUFFIXES}
876
    )
877
    # Don't try any stub directories until we have exhausted all other
878
    # search locations.
879
    find_library(CUDA_${lib_name}_LIBRARY
880
      NAMES ${search_names}
881
      HINTS ${CUDAToolkit_LIBRARY_DIR}
882
            ENV CUDA_PATH
883
            ${arg_EXTRA_HINTS}
884
      PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs
885
                    # Support NVHPC splayed math library layout
886
                    ../../math_libs/${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}/lib64
887
                    ../../math_libs/lib64
888
    )
889

890
    mark_as_advanced(CUDA_${lib_name}_LIBRARY)
891

892
    if(NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
893
      add_library(CUDA::${lib_name} UNKNOWN IMPORTED)
894
      set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
895
          INTERFACE_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}")
896
      set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
897
          INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}")
898
      if(DEFINED CUDAToolkit_MATH_INCLUDE_DIR)
899
        string(FIND ${CUDA_${lib_name}_LIBRARY} "math_libs" math_libs)
900
        if(NOT ${math_libs} EQUAL -1)
901
          set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
902
              INTERFACE_INCLUDE_DIRECTORIES "${CUDAToolkit_MATH_INCLUDE_DIRS}")
903
          set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
904
              INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CUDAToolkit_MATH_INCLUDE_DIRS}")
905
        endif()
906
      endif()
907
      set_property(TARGET CUDA::${lib_name} PROPERTY IMPORTED_LOCATION "${CUDA_${lib_name}_LIBRARY}")
908
      foreach(dep ${arg_DEPS})
909
        if(TARGET CUDA::${dep})
910
          set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
911
              INTERFACE_LINK_LIBRARIES CUDA::${dep})
912
        endif()
913
      endforeach()
914
      if(arg_EXTRA_INCLUDE_DIRS)
915
        set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
916
            INTERFACE_INCLUDE_DIRECTORIES "${arg_EXTRA_INCLUDE_DIRS}")
917
        set_property(TARGET CUDA::${lib_name} APPEND PROPERTY
918
            INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${arg_EXTRA_INCLUDE_DIRS}")
919
      endif()
920
    endif()
921
  endfunction()
922

923
  if(NOT TARGET CUDA::toolkit)
924
    add_library(CUDA::toolkit IMPORTED INTERFACE)
925
    set_property(TARGET CUDA::toolkit APPEND PROPERTY
926
        INTERFACE_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}")
927
    set_property(TARGET CUDA::toolkit APPEND PROPERTY
928
        INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CUDAToolkit_INCLUDE_DIRS}")
929
  endif()
930

931
  _CUDAToolkit_find_and_add_import_lib(cuda_driver ALT cuda)
932

933
  _CUDAToolkit_find_and_add_import_lib(cudart)
934
  _CUDAToolkit_find_and_add_import_lib(cudart_static)
935

936
  # setup dependencies that are required for cudart_static when building
937
  # on linux. These are generally only required when using the CUDA toolkit
938
  # when CUDA language is disabled
939
  if(NOT TARGET CUDA::cudart_static_deps
940
     AND TARGET CUDA::cudart_static)
941

942
    add_library(CUDA::cudart_static_deps IMPORTED INTERFACE)
943
    set_property(TARGET CUDA::cudart_static APPEND PROPERTY
944
        INTERFACE_LINK_LIBRARIES CUDA::cudart_static_deps)
945

946
    if(UNIX AND (CMAKE_C_COMPILER OR CMAKE_CXX_COMPILER))
947
      find_package(Threads REQUIRED)
948
      set_property(TARGET CUDA::cudart_static_deps APPEND PROPERTY
949
          INTERFACE_LINK_LIBRARIES Threads::Threads ${CMAKE_DL_LIBS})
950
    endif()
951

952
    if(UNIX AND NOT APPLE AND NOT (CMAKE_SYSTEM_NAME STREQUAL "QNX"))
953
      # On Linux, you must link against librt when using the static cuda runtime.
954
      find_library(CUDAToolkit_rt_LIBRARY rt)
955
      mark_as_advanced(CUDAToolkit_rt_LIBRARY)
956
      if(NOT CUDAToolkit_rt_LIBRARY)
957
        message(WARNING "Could not find librt library, needed by CUDA::cudart_static")
958
      else()
959
        set_property(TARGET CUDA::cudart_static_deps APPEND PROPERTY
960
            INTERFACE_LINK_LIBRARIES ${CUDAToolkit_rt_LIBRARY})
961
      endif()
962
    endif()
963
  endif()
964

965
  _CUDAToolkit_find_and_add_import_lib(culibos) # it's a static library
966
  foreach(cuda_lib cublasLt cufft curand cusparse nppc nvjpeg)
967
    _CUDAToolkit_find_and_add_import_lib(${cuda_lib})
968
    _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS culibos)
969
  endforeach()
970

971
  if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.0.0)
972
    # cublas depends on cublasLt
973
    # https://docs.nvidia.com/cuda/archive/11.0/cublas/index.html#static-library
974
    _CUDAToolkit_find_and_add_import_lib(cublas DEPS cublasLt)
975
    _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS cublasLt_static)
976
  else()
977
    _CUDAToolkit_find_and_add_import_lib(cublas)
978
    _CUDAToolkit_find_and_add_import_lib(cublas_static DEPS culibos)
979
  endif()
980

981
  # cuFFTW depends on cuFFT
982
  _CUDAToolkit_find_and_add_import_lib(cufftw DEPS cufft)
983
  _CUDAToolkit_find_and_add_import_lib(cufftw_static DEPS cufft_static)
984
  if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 9.2)
985
    _CUDAToolkit_find_and_add_import_lib(cufft_static_nocallback DEPS culibos)
986
  endif()
987

988
  # cuSOLVER depends on cuBLAS, and cuSPARSE
989
  _CUDAToolkit_find_and_add_import_lib(cusolver DEPS cublas cusparse)
990
  _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cublas_static cusparse_static culibos)
991

992

993
  if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.1.2)
994
    # cusolver depends on liblapack_static.a starting with CUDA 10.1 update 2,
995
    # https://docs.nvidia.com/cuda/archive/11.5.0/cusolver/index.html#static-link-lapack
996
    _CUDAToolkit_find_and_add_import_lib(cusolver_lapack_static ALT lapack_static) # implementation detail static lib
997
    _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cusolver_lapack_static)
998
  endif()
999

1000
  if(CUDAToolkit_VERSION VERSION_GREATER 11.2.1)
1001
    # cusolver depends on libcusolver_metis and cublasLt
1002
    # https://docs.nvidia.com/cuda/archive/11.2.2/cusolver/index.html#link-dependency
1003
    _CUDAToolkit_find_and_add_import_lib(cusolver DEPS cublasLt)
1004

1005
    _CUDAToolkit_find_and_add_import_lib(cusolver_metis_static ALT metis_static) # implementation detail static lib
1006
    _CUDAToolkit_find_and_add_import_lib(cusolver_static DEPS cusolver_metis_static cublasLt_static)
1007
  endif()
1008

1009
  # nvGRAPH depends on cuRAND, and cuSOLVER.
1010
  _CUDAToolkit_find_and_add_import_lib(nvgraph DEPS curand cusolver)
1011
  _CUDAToolkit_find_and_add_import_lib(nvgraph_static DEPS curand_static cusolver_static)
1012

1013
  # Process the majority of the NPP libraries.
1014
  foreach(cuda_lib nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu)
1015
    _CUDAToolkit_find_and_add_import_lib(${cuda_lib} DEPS nppc)
1016
    _CUDAToolkit_find_and_add_import_lib(${cuda_lib}_static DEPS nppc_static)
1017
  endforeach()
1018

1019
  find_path(CUDAToolkit_CUPTI_INCLUDE_DIR cupti.h PATHS
1020
      "${CUDAToolkit_ROOT_DIR}/extras/CUPTI/include"
1021
      "${CUDAToolkit_INCLUDE_DIR}/../extras/CUPTI/include"
1022
      "${CUDAToolkit_INCLUDE_DIR}"
1023
      NO_DEFAULT_PATH)
1024
  mark_as_advanced(CUDAToolkit_CUPTI_INCLUDE_DIR)
1025

1026
  if(CUDAToolkit_CUPTI_INCLUDE_DIR)
1027
    _CUDAToolkit_find_and_add_import_lib(cupti
1028
                                        EXTRA_PATH_SUFFIXES ../extras/CUPTI/lib64/
1029
                                                            ../extras/CUPTI/lib/
1030
                                        EXTRA_INCLUDE_DIRS "${CUDAToolkit_CUPTI_INCLUDE_DIR}")
1031
    _CUDAToolkit_find_and_add_import_lib(cupti_static
1032
                                        EXTRA_PATH_SUFFIXES ../extras/CUPTI/lib64/
1033
                                                            ../extras/CUPTI/lib/
1034
                                        EXTRA_INCLUDE_DIRS "${CUDAToolkit_CUPTI_INCLUDE_DIR}")
1035
  endif()
1036

1037
  _CUDAToolkit_find_and_add_import_lib(nvrtc DEPS cuda_driver)
1038

1039
  _CUDAToolkit_find_and_add_import_lib(nvml ALT nvidia-ml nvml)
1040

1041
  # nvtools can be installed outside the CUDA toolkit directory,
1042
  # so search the NVTOOLSEXT_PATH windows only environment variable
1043
  set(nvToolsExt_EXTRA_PATH)
1044
  if(WIN32)
1045
     set(nvToolsExt_EXTRA_PATH "C:\\Program Files\\NVIDIA Corporation\\NvToolsExt")
1046
  endif()
1047

1048
  find_path(CUDAToolkit_nvToolsExt_INCLUDE_DIR nvToolsExt.h
1049
      PATHS "${CUDAToolkit_INCLUDE_DIR}"
1050
            "${CUDAToolkit_ROOT_DIR}"
1051
            ENV NVTOOLSEXT_PATH
1052
            "${nvToolsExt_EXTRA_PATH}"
1053
      PATH_SUFFIXES include
1054
      NO_DEFAULT_PATH)
1055
  mark_as_advanced(CUDAToolkit_nvToolsExt_INCLUDE_DIR)
1056

1057
  if(CUDAToolkit_nvToolsExt_INCLUDE_DIR)
1058
    _CUDAToolkit_find_and_add_import_lib(nvToolsExt
1059
        ALT nvToolsExt64 nvToolsExt64_1
1060
        EXTRA_HINTS ENV NVTOOLSEXT_PATH
1061
                    "${nvToolsExt_EXTRA_PATH}"
1062
        EXTRA_INCLUDE_DIRS "${CUDAToolkit_nvToolsExt_INCLUDE_DIR}")
1063
  endif()
1064

1065
  _CUDAToolkit_find_and_add_import_lib(OpenCL)
1066
endif()
1067

1068
unset(CUDAToolkit_ROOT_DIR)
1069

1070
if(_CUDAToolkit_Pop_ROOT_PATH)
1071
  list(REMOVE_AT CMAKE_FIND_ROOT_PATH 0)
1072
  unset(_CUDAToolkit_Pop_ROOT_PATH)
1073
endif()
1074

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.