From 164284d86be7590f0162a18f9189eded1caa5374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jack=C2=B7Boos=C2=B7Yu?= <47264268+JackBoosY@users.noreply.github.com> Date: Fri, 8 May 2020 03:35:22 +0800 Subject: [PATCH] [cuda] Fix find cuda in UNIX (#10838) * [cuda] Fix find cuda in UNIX * update baseline * [cuda] Add homepage * add newline to end of CONTROL * Update ports/cuda/portfile.cmake Co-authored-by: nicole mazzuca Co-authored-by: nicole mazzuca --- ports/cuda/CONTROL | 3 +- ports/cuda/portfile.cmake | 58 +++++++++++++++++++++++++++++++-------- scripts/ci.baseline.txt | 1 - 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/ports/cuda/CONTROL b/ports/cuda/CONTROL index ba5208c2f..cf909e0ce 100644 --- a/ports/cuda/CONTROL +++ b/ports/cuda/CONTROL @@ -1,3 +1,4 @@ Source: cuda -Version: 10.1 +Version: 10.1-1 Description: A parallel computing platform and programming model +Homepage: https://developer.nvidia.com/cuda-toolkit diff --git a/ports/cuda/portfile.cmake b/ports/cuda/portfile.cmake index 63e3f9cee..63c761a1a 100644 --- a/ports/cuda/portfile.cmake +++ b/ports/cuda/portfile.cmake @@ -2,14 +2,50 @@ # Other packages can depend on this package to declare a dependency on CUDA. # If this package is installed, we assume that CUDA is properly installed. -find_program(NVCC - NAMES nvcc nvcc.exe - PATHS - ENV CUDA_PATH - ENV CUDA_BIN_PATH - PATH_SUFFIXES bin bin64 - DOC "Toolkit location." - NO_DEFAULT_PATH) +#note: this port must be kept in sync with CUDNN port: every time one is upgraded, the other must be too +set(CUDA_REQUIRED_VERSION "10.1.0") + +if (VCPKG_TARGET_IS_WINDOWS) + find_program(NVCC + NAMES nvcc.exe + PATHS + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) +else() + if (VCPKG_TARGET_IS_LINUX) + set(platform_base "/usr/local/cuda-") + else() + set(platform_base "/Developer/NVIDIA/CUDA-") + endif() + + file(GLOB possible_paths "${platform_base}*") + set(FOUND_PATH ) + foreach (p ${possible_paths}) + # Extract version number from end of string + string(REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${p}) + if (IS_DIRECTORY ${p} AND p_version) + if (p_version VERSION_GREATER_EQUAL CUDA_REQUIRED_VERSION) + set(FOUND_PATH ${p}) + break() + endif() + endif() + endforeach() + + find_program(NVCC + NAMES nvcc + PATHS + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATHS ${FOUND_PATH} + PATH_SUFFIXES bin bin64 + DOC "Toolkit location." + NO_DEFAULT_PATH + ) +endif() set(error_code 1) if (NVCC) @@ -19,11 +55,9 @@ if (NVCC) RESULT_VARIABLE error_code) endif() -#note: this port must be kept in sync with CUDNN port: every time one is upgraded, the other must be too -set(CUDA_REQUIRED_VERSION "V10.1.0") if (error_code) - message(FATAL_ERROR "Could not find CUDA. Before continuing, please download and install CUDA (${CUDA_REQUIRED_VERSION} or higher) from:" + message(FATAL_ERROR "Could not find CUDA. Before continuing, please download and install CUDA (v${CUDA_REQUIRED_VERSION} or higher) from:" "\n https://developer.nvidia.com/cuda-downloads\n") endif() @@ -39,7 +73,7 @@ set(CUDA_VERSION_MINOR ${CMAKE_MATCH_2}) set(CUDA_VERSION_PATCH ${CMAKE_MATCH_3}) if (CUDA_VERSION_MAJOR LESS 10 AND CUDA_VERSION_MINOR LESS 1) - message(FATAL_ERROR "CUDA ${CUDA_VERSION} found, but ${CUDA_REQUIRED_VERSION} is required. Please download and install a more recent version of CUDA from:" + message(FATAL_ERROR "CUDA ${CUDA_VERSION} found, but v${CUDA_REQUIRED_VERSION} is required. Please download and install a more recent version of CUDA from:" "\n https://developer.nvidia.com/cuda-downloads\n") endif() diff --git a/scripts/ci.baseline.txt b/scripts/ci.baseline.txt index 435dc8f49..7fcbbd9b5 100644 --- a/scripts/ci.baseline.txt +++ b/scripts/ci.baseline.txt @@ -301,7 +301,6 @@ ctemplate:arm64-windows=fail ctemplate:arm-uwp=fail ctemplate:x64-linux=fail ctemplate:x64-osx=fail -cuda:x64-linux=fail cuda:x64-osx=fail cudnn:arm64-windows=fail cudnn:arm-uwp=fail