Finding CUDA_SDK_ROOT_DIR - cuda

I am trying to set up Point Cloud Library trunk build with CUDA options enabled.
I believe I have installed CUDA correctly, following these instructions.
In the cmake options for the PCL build, some options are unrecognised:
Is there something I can manually set CUDA_SDK_ROOT_DIR to? Likewise for the other unfound options.

CUDA_SDK_ROOT_DIR should be set to the direction in which you installed the NVIDIA's GPU Computing SDK. The GPU Computing SDK is downloadable from the same page at NVIDIA where you downloaded CUDA. By default, this SDK will install to $HOME/NVIDIA_GPU_Computing_SDK. Set it appropriately and then rerun cmake.
Edit:
The CUDA_SDK_ROOT_DIR variable is actually looking for the sub-directory beneath $HOME/NVIDIA_GPU_Computing_SDK that contains the version of CUDA you're using. For me, this is $HOME/NVIDIA_GPU_Computing_SDK/CUDA/v4.1.

The source code for FindCUDA.cmake gives some hints on how this path is found:
########################
# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with
# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory
find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h
"$ENV{NVSDKCOMPUTE_ROOT}/C"
"$ENV{NVSDKCUDA_ROOT}"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]"
"/Developer/GPU\ Computing/C"
)
I.e. check that NVSDKCOMPUTE_ROOT or NVSDKCUDA_ROOT environment variables are set correctly.

On a Linux machine,..
Add "$ENV{HOME}/NVIDIA_GPU_Computing_SDK/C" to the 'find_path' options in FindCUDA.cmake module: (usr/share/cmake-2.8/Modules/FindCUDA.cmake)
########################
# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with
# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory
find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h
"$ENV{HOME}/NVIDIA_GPU_Computing_SDK/C"
"$ENV{NVSDKCOMPUTE_ROOT}/C"
"$ENV{NVSDKCUDA_ROOT}"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]"
"/Developer/GPU\ Computing/C"
)
cmake now finds my 4.0 SDK automatically.
But my build still fails to find cutil.h, even though it is there. $HOME/NVIDIA_GPU_Computing_SDK/C/common/inc/cutil.h. I had to add an include flag to the project to get it to finally work. CUDA_NVCC_FLAGS : -I/home/bill/NVIDIA_GPU_Computing_SDK/C/common/inc
Note: -I/$HOME/NVIDIA_GPU_Computing_SDK/C/common/inc does NOT work. (The env $HOME is set correctly.)

Related

grpc-gateway runtime version conflict

from last few days the protoc generator is generating code with v2 version of github.com/grpc-ecosystem/grpc-gateway. I want to keep using github.com/grpc-ecosystem/grpc-gateway v1.16.0. I am unable to remove the v2 version which is causing conflict. I tried removing from go.mod, clearing from $GOPATH. I suppose my protoc generator is not able to use v1 version. Kindly guide me as how shall I sync the grpc-gateway runtime package.
Using below commands to generate the messages and service
protoc -I . --go-grpc_out=. api/protobuf-spec/catalog_fetch/*.proto
protoc -I . --grpc-gateway_out=logtostderr=true:. api/protobuf-spec/catalog_fetch/*.proto
Note: It is generating both grpc.pb.go file and pb.go file, which is further causing issue.
cannot use mux (type *"github.com/grpc-ecosystem/grpc-gateway/runtime".ServeMux) as type *"github.com/grpc-ecosystem/grpc-gateway/v2/runtime".ServeMux ```
I have spent 3 hours debugging the exact same problem.
You have to remove the binary from your GOPATH and GOROOT.
For simplicity, just use which protoc-gen-grpc-gateway.
This should point you to the binary protoc is using under the hood. Remove it and rerun go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway#v1.16.0.
I think you have installed the v2 version of the generator. Unfortunately, you cannot use v1.16.0 with newer versions of the go protobuf generators. If you want to keep using v1.16.0, you can download the generator from the releases page https://github.com/grpc-ecosystem/grpc-gateway/releases/tag/v1.16.0.

How to link cusparse using CMakeLists.txt

How can I add the cusparse library from CUDA in a CMakeLists.txt-file, such that the nvcc compiler includes it automatically with -lcusparse? I already added the line
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-lcusparse)
in CMakeLists.txt with no success. It looks like I'm missing something, because Nsight throws the error
undefined reference to 'cusparseDestroyMatDescr'.
Although when I exclude this line where cusparseDestroyMatDescr is called via commenting it, the Nsight project builds with no error, even with these three lines of code included
cusparseStatus_t status;
cusparseHandle_t handle=0;
cusparseMatDescr_t descr=0;
So it looks like it knows what cusparseStatus_t and so on is, but it does not know what cusparseDestroyMatDescr is.
What do I miss?
The correct way in CMake to link a library is using
target_link_libraries( target library ).
If you use FindCUDA to locate the CUDA installation, the variable CUDA_cusparse_LIBRARY will be defined. Thus, all you need to do is
target_link_libraries( target ${CUDA_cusparse_LIBRARY} )
I recommend to use the CMake CUDAToolkit package, which is available with CMake 3.17 and newer:
find_package(CUDAToolkit REQUIRED)
...
target_link_libraries(target CUDA::cusparse)

How do I specify which compiler toolchain Yocto uses to build images?

For example how could I get my image to be compiled using:
gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux
?
What does core-image-sato has to do with the toolchains (they supply with Yocto)?
I don't understand...
in local.conf, specify the path of your toolchain in your system.
EXTERNAL_TOOLCHAIN = "/home/manjunath/linaro/gcc-linaro-arm-linux-gnueabihf-4.7-2014.11-20121123_linux"
In your original toolchain distro add toolchain-external-linaro.inc
More specifically
you get a directory named meta-linaro-toolchain. you may copy complete or
Add .inc to your distribution (sources/poky/meta-yocto/conf/distro/ in my case)
Try now ...

CMake: how to add cuda to existing project

I have a project that builds a library and I want to add some cuda support to it.
The structure is:
|Basedir
|_subdir1
|_subdir2
The basic structure of the CMakeLists.txt files: (subdir2 is not important).
in Basedir:
cmake_minimum_required(VERSION 2.6)
PROJECT(myproject)
find_package(CUDA)
INCLUDE_DIRECTORIES(${MYPROJECT_SOURCE_DIR})
ADD_SUBDIRECTORY(subdir1)
ADD_SUBDIRECTORY(subdir2)
in subdir1:
ADD_LIBRARY(mylib shared
file1.cpp
file2.cpp
file3.cpp
)
INSTALL(
TARGETS mylib
DESTINATION lib
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
FILE(GLOB_RECURSE HEADERS RELATIVE ${MYPROJECT_SOURCE_DIR}/myproject *.h)
FOREACH(HEADER ${HEADERS})
STRING(REGEX MATCH "(.*)[/\\]" DIR ${HEADER})
INSTALL(FILES ${HEADER} DESTINATION include/myproject/${DIR})
ENDFOREACH(HEADER)
I actually don't really know how to put the cuda-support into it. I want to replace file2.cpp with file2.cu and I did that, but it didn't build the .cu file, only the cpp files.
Do I have to add CUDA_ADD_EXECUTABLE() to include any cuda-files? How will I then link it to the other files?
I tried adding the following to the CMakeLists.txt in subdir1:
CUDA_ADD_EXECUTABLE(cuda file2.cu OPTIONS -arch sm_20)
That will compile the file but build an executable cuda. How do I link it to mylib?
Just with?:
TARGET_LINK_LIBRARIES(cuda mylib)
I have to admit that I'm not experienced in cmake, but I guess you figured that.
You can use CUDA_ADD_LIBRARY for mylib project. It works as CUDA_ADD_EXECUTABLE but for libraries.
CUDA_ADD_LIBRARY(mylib SHARED
file1.cpp
file2.cu
file3.cpp
OPTIONS -arch sm_20
)
TARGET_LINK_LIBRARIES(mylib ${CUDA_LIBRARIES})

How do I build libmySQL?

I aim to integrate libmySQL into my executable instead of using libmySQL.dll.
I use VC++ 2008 # Windows Vista.
I've downloaded "mysql-connector-c-noinstall-6.0.2-win32-vs2005.zip" from
http://dev.mysql.com/downloads/connector/c/
It contains only ".h" files with declarations. Where is the implementation code (".c" files)?
As said, I wish to be able to manipulate the code, build it as a static library (".lib") and finally integrate it into my exe.
How do I do that? Am I looking at the wrong place? Is it available at all? And if/once I do get it, does it require any special compilation? What are the steps?
you should find a .lib inside, .h .lib and .dll are enough to link it to your app
ora select 'source code' as platform instead