jcuda / jcuda-main

Summarizes the main JCuda libraries
MIT License
99 stars 20 forks source link

Building JCuda #53

Open karnuz opened 2 years ago

karnuz commented 2 years ago

I am trying to use this with CUDA 10.1 on Windows 10. However one of the macros CUDA_ADD_NVPTXCOMPILER_STATIC_TO_TARGET is defined only for CUDA11 and later, but is always used in jcuda/JNvPTXCompilerJNI/CMakeLists.txt.28 So that raises an error during configure.

If I comment out jcuda/JNvPTXCompilerJNI/CMakeLists.txt.28, I run into undefined variables:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cuDNN_LIBRARY
    linked by target "JCudnn" in directory C:/Executables/JCuda/jcudnn/JCudnnJNI
CUDA_cublas_LIBRARY (ADVANCED)
    linked by target "JCublas" in directory C:/Executables/JCuda/jcublas/JCublasJNI
    linked by target "JCublas2" in directory C:/Executables/JCuda/jcublas/JCublas2JNI
CUDA_cufft_LIBRARY (ADVANCED)
    linked by target "JCufft" in directory C:/Executables/JCuda/jcufft/JCufftJNI
CUDA_curand_LIBRARY (ADVANCED)
    linked by target "JCurand" in directory C:/Executables/JCuda/jcurand/JCurandJNI
CUDA_cusolver_LIBRARY (ADVANCED)
    linked by target "JCusolver" in directory C:/Executables/JCuda/jcusolver/JCusolverJNI
CUDA_cusparse_LIBRARY (ADVANCED)
    linked by target "JCusparse" in directory C:/Executables/JCuda/jcusparse/JCusparseJNI

Need help resolving this.

Also, it is potentially possible for me to change to CUDA11. Does the latest JCUDA work well with CUDA 11.7 ?

jcuda commented 2 years ago

Two short notes:

Beyond that, it will hardly be possible to build the current state for an older CUDA version. Roughly speaking: JCuda will try to call some functions like someCudaFunctionFromCuda11, and ... this function does simply not exist in CUDA 10 ... (i.e. these will show up as ~"unresolved externals" during compilation).

karnuz commented 2 years ago

Thanks for the notes. I updated to CUDA 11.7 and I no more get error on CUDA_ADD_NVPTXCOMPILER_STATIC_TO_TARGET as expected.

However the undefined variables error is still there. Pasting it again for ease of reading:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_cuDNN_LIBRARY
    linked by target "JCudnn" in directory C:/Executables/JCuda/jcudnn/JCudnnJNI
CUDA_cublas_LIBRARY (ADVANCED)
    linked by target "JCublas" in directory C:/Executables/JCuda/jcublas/JCublasJNI
    linked by target "JCublas2" in directory C:/Executables/JCuda/jcublas/JCublas2JNI
CUDA_cufft_LIBRARY (ADVANCED)
    linked by target "JCufft" in directory C:/Executables/JCuda/jcufft/JCufftJNI
CUDA_curand_LIBRARY (ADVANCED)
    linked by target "JCurand" in directory C:/Executables/JCuda/jcurand/JCurandJNI
CUDA_cusolverMg_LIBRARY (ADVANCED)
    linked by target "JCusolver" in directory C:/Executables/JCuda/jcusolver/JCusolverJNI
    linked by target "JCusolver" in directory C:/Executables/JCuda/jcusolver/JCusolverJNI
CUDA_cusolver_LIBRARY (ADVANCED)
    linked by target "JCusolver" in directory C:/Executables/JCuda/jcusolver/JCusolverJNI
CUDA_cusparse_LIBRARY (ADVANCED)
    linked by target "JCusparse" in directory C:/Executables/JCuda/jcusparse/JCusparseJNI
CUDA_nvptxcompiler_static_LIBRARY (ADVANCED)
    linked by target "JNvPTXCompiler" in directory C:/Executables/JCuda/jcuda/JNvPTXCompilerJNI
jcuda commented 2 years ago

Regarding the CUDA_cuDNN_LIBRARY part: In order to compile JCuda, you also need cuDNN from https://developer.nvidia.com/cudnn . Yes, it's for registered developers only. Yes, this is a nuisance.

If you don't need JCudnn, you may try to just remove the jcudnn entries from the pom.xml and from the CMakeLists.txt - that should be enough to get it compiled without cuDNN.

But... the other messages indicate that it does not find your CUDA installation in general. When you run cmake-gui and select the jcuda-main directory and press 'Configure', then it should pick up your CUDA installation, roughly like that:

JCuda Cmake

Does this show any error message for you, like ~"No CUDA SDK found" or so...?

karnuz commented 2 years ago

ss As you said, it seems CUDA_SDK_ROOT_DIR is not found. How can I remedy this ?

jcuda commented 2 years ago

Surprisingly, CUDA_SDK_ROOT_DIR is also not found for me, but it still manages to find the actual libraries.

It may be hard to find 'the' reason for any inconsistency here: All the CMake magic is done by https://github.com/jcuda/jcuda-common/blob/master/CMake/FindCUDA.cmake , which is a 1800-lines-black-magic CMake script from the NVIDIA toolkit that automagically ~"finds stuff".

But ... try checking the 'Advanced' and 'Grouped' checkboxes.

It appears to have found the nvrtc library, so... I wonder how it could not find cublas...

karnuz commented 2 years ago

checking 'Advanced' and 'Grouped' options didn't help. I have always wondered how CMake finds stuff.

jcuda commented 2 years ago

I'm not sure what you mean by "didn't help". When you check these boxes, does it show the full configuration for CUDA (as shown in the screenshot that I posted?) If so: Does it find the right paths? (And ... I now have to ask: Did you check out all required projects? Or only jcuda-main...?)

karnuz commented 2 years ago

sorry for late reply. I did check out all the projects. It shows the full configuration. However, does not find the paths aa

jcuda commented 2 years ago

Well, the strangest thing for me right now is that it finds some of the libraries. Maybe something went wrong during the CUDA installation...? I'm not sure about the best way to proceed here.

Maybe two things to try out:

I'm not 100% that adding these paths would be sufficient (or whether it requries further information to create the build files eventually), but it should be worth a try...