ShahriarRezghi/Spyker

Compile error with CUDA

ggoupy opened this issue · 4 comments

Hi.

I am trying to build the Python interface using CUDA.

Unfortunately, I obtain this error message :

  -- Looking for a CUDA compiler
  -- Looking for a CUDA compiler - /home/ggoupy/anaconda3/bin/nvcc
  -- The CUDA compiler identification is NVIDIA 12.0.140
  -- Check for working CUDA compiler: /home/ggoupy/anaconda3/bin/nvcc
  -- Check for working CUDA compiler: /home/ggoupy/anaconda3/bin/nvcc -- works
  -- Detecting CUDA compiler ABI info
  -- Detecting CUDA compiler ABI info - done
  CMake Error at CMakeLists.txt:103 (find_package):
    By not providing "FindCUDAToolkit.cmake" in CMAKE_MODULE_PATH this project
    has asked CMake to find a package configuration file provided by
    "CUDAToolkit", but CMake did not find one.

    Could not find a package configuration file provided by "CUDAToolkit" with
    any of the following names:

      CUDAToolkitConfig.cmake
      cudatoolkit-config.cmake

    Add the installation prefix of "CUDAToolkit" to CMAKE_PREFIX_PATH or set
    "CUDAToolkit_DIR" to a directory containing one of the above files.  If
    "CUDAToolkit" provides a separate development package or SDK, be sure it
    has been installed.

I tried to install CUDA from the ubuntu package manager, but also from runfile and with conda. Always the same error.

I am not used to C++ compilation and this is the first time I install CUDA so I may have done something wrong (even if I followed the Nvidia instructions).

Thanks for reporting the issue. I think that you are using an older version of CMake. Can you tell me what version of CMake are you using? If you are able to, please install the latest one.

I was using version 3.16. I upgraded to 3.25 and now it finds the .cmake file and compiles.

However, it seems that CUDA is not properly initialized, as spyker.cuda_available() is false. I believe that the warning suggests that it does not find my GPU (rtx 3070) ?

 -- The C compiler identification is GNU 9.4.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- DNNL_TARGET_ARCH: X64
  -- DNNL_LIBRARY_NAME: dnnl
  -- Found OpenMP_C: -fopenmp (found version "4.5")
  -- Found OpenMP_CXX: -fopenmp (found version "4.5")
  -- Found OpenMP: TRUE (found version "4.5")
  -- Could NOT find Doxyrest (missing: DOXYREST_EXECUTABLE)
  -- Found PythonInterp: /home/ggoupy/anaconda3/bin/python (found suitable version "3.8.5", minimum required is "2.7")
  -- Found Sphinx: /home/ggoupy/anaconda3/bin/sphinx-build (found version "sphinx-build 3.2.1")
  -- Found Git: /usr/bin/git (found version "2.25.1")
  -- Enabled workload: INFERENCE
  -- Enabled primitives: CONVOLUTION;MATMUL
  -- Enabled primitive CPU ISA: ALL
  -- Enabled primitive GPU ISA: ALL
  -- Primitive cache is enabled
  -- The ASM compiler identification is GNU
  -- Found assembler: /usr/bin/cc
  -- Looking for a CUDA compiler
  -- Looking for a CUDA compiler - /home/ggoupy/anaconda3/bin/nvcc
  -- The CUDA compiler identification is NVIDIA 12.0.140
  -- Detecting CUDA compiler ABI info
  -- Detecting CUDA compiler ABI info - done
  -- Check for working CUDA compiler: /home/ggoupy/anaconda3/bin/nvcc - skipped
  -- Detecting CUDA compile features
  -- Detecting CUDA compile features - done
  -- Found CUDAToolkit: /home/ggoupy/anaconda3/include (found version "12.0.140")
  -- Could NOT find CUDNN (missing: CUDNN_LIBRARIES CUDNN_INCLUDE_DIRS)
  -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
  -- Found OpenMP: TRUE (found version "4.5")
  -- pybind11 v2.9.2
  -- Found PythonInterp: /home/ggoupy/anaconda3/bin/python (found version "3.8.5")
  -- Found PythonLibs: /home/ggoupy/anaconda3/lib/libpython3.8.so
  -- Performing Test HAS_FLTO
  -- Performing Test HAS_FLTO - Success
  --
  -- Summary:
  -- Optimization Flags: ------------ -march=native
  -- CUDA Archutecutre List: --------
  -- Python Interface: -------------- ON
  -- CUDA: -------------------------- ON
  -- CUDNN: ------------------------- OFF
  -- DNNL: -------------------------- ON
  -- BLAS: -------------------------- ON
  --
  -- Configuring done
  CMake Warning (dev) in CMakeLists.txt:
    Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
    empty CUDA_ARCHITECTURES not allowed.  Run "cmake --help-policy CMP0104"
    for policy details.  Use the cmake_policy command to set the policy and
    suppress this warning.

    CUDA_ARCHITECTURES is empty for target "spyker".
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:210 (add_library):
    Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
    enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.

    INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
    'spyker_plugin'.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) in CMakeLists.txt:
    Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
    empty CUDA_ARCHITECTURES not allowed.  Run "cmake --help-policy CMP0104"
    for policy details.  Use the cmake_policy command to set the policy and
    suppress this warning.

    CUDA_ARCHITECTURES is empty for target "spyker_plugin".
  This warning is for project developers.  Use -Wno-dev to suppress it.

First of all, you should definitely compile with cuDNN. Without it, you will see terrible performance. Second of all, you are using CUDA 12, and I haven't set the default architectures for it yet. You need to pass CUDA_ARCH_LIST option when building, and set it to your device's architecture (which is 86, see this). For example:

CUDA_ARCH_LIST="50;52;53;60;61;62;70;72;75;80;86;87;89;90" pip ...

You should be able to see the architectures you set in the summary section of the CMake output.

Thanks for the advice, I will install it after, but first I'd like to fix the CUDA issue. (+ there is no cuDNN release for CUDA 12)

I compiled again with the CUDA_ARCH_LIST argument, uninstalled the previous spyker package with pip uninstall spyker and installed it again. But cuda is still not available.

  -- The C compiler identification is GNU 9.4.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- DNNL_TARGET_ARCH: X64
  -- DNNL_LIBRARY_NAME: dnnl
  -- Found OpenMP_C: -fopenmp (found version "4.5")
  -- Found OpenMP_CXX: -fopenmp (found version "4.5")
  -- Found OpenMP: TRUE (found version "4.5")
  -- Could NOT find Doxyrest (missing: DOXYREST_EXECUTABLE)
  -- Found PythonInterp: /home/ggoupy/anaconda3/bin/python (found suitable version "3.8.5", minimum required is "2.7")
  -- Found Sphinx: /home/ggoupy/anaconda3/bin/sphinx-build (found version "sphinx-build 3.2.1")
  -- Found Git: /usr/bin/git (found version "2.25.1")
  -- Enabled workload: INFERENCE
  -- Enabled primitives: CONVOLUTION;MATMUL
  -- Enabled primitive CPU ISA: ALL
  -- Enabled primitive GPU ISA: ALL
  -- Primitive cache is enabled
  -- The ASM compiler identification is GNU
  -- Found assembler: /usr/bin/cc
  -- Looking for a CUDA compiler
  -- Looking for a CUDA compiler - /home/ggoupy/anaconda3/bin/nvcc
  -- The CUDA compiler identification is NVIDIA 12.0.140
  -- Detecting CUDA compiler ABI info
  -- Detecting CUDA compiler ABI info - done
  -- Check for working CUDA compiler: /home/ggoupy/anaconda3/bin/nvcc - skipped
  -- Detecting CUDA compile features
  -- Detecting CUDA compile features - done
  -- Found CUDAToolkit: /home/ggoupy/anaconda3/include (found version "12.0.140")
  -- Could NOT find CUDNN (missing: CUDNN_LIBRARIES CUDNN_INCLUDE_DIRS)
  -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
  -- Found OpenMP: TRUE (found version "4.5")
  -- pybind11 v2.9.2
  -- Found PythonInterp: /home/ggoupy/anaconda3/bin/python (found version "3.8.5")
  -- Found PythonLibs: /home/ggoupy/anaconda3/lib/libpython3.8.so
  -- Performing Test HAS_FLTO
  -- Performing Test HAS_FLTO - Success
  --
  -- Summary:
  -- Optimization Flags: ------------ -march=native
  -- CUDA Archutecutre List: -------- 50;52;53;60;61;62;70;72;75;80;86;87;89;90
  -- Python Interface: -------------- ON
  -- CUDA: -------------------------- ON
  -- CUDNN: ------------------------- OFF
  -- DNNL: -------------------------- ON
  -- BLAS: -------------------------- ON
  --
  -- Configuring done
  CMake Warning (dev) at CMakeLists.txt:210 (add_library):
    Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
    enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
    cmake_policy command to set the policy and suppress this warning.

    INTERPROCEDURAL_OPTIMIZATION property will be ignored for target
    'spyker_plugin'.
  This warning is for project developers.  Use -Wno-dev to suppress it.

EDIT :
I reinstalled without conda and it worked.