#include "stdio.h"
int main()
{
printf("Hello, world\n");
return 0;
}
nvcc hello1.cu
./a.out
Hello, world
#include "stdio.h"
__global__ void add(int a, int b, int *c)
{
*c = a + b;
}
int main()
{
int a,b,c;
int *dev_c;
a=3;
b=4;
cudaMalloc((void**)&dev_c, sizeof(int));
add<<<1,1>>>(a,b,dev_c);
cudaMemcpy(&c, dev_c, sizeof(int), cudaMemcpyDeviceToHost);
printf("%d + %d is %d\n", a, b, c);
cudaFree(dev_c);
return 0;
}
nvcc add.cu
./a.out
3 + 4 is 7
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Mon_Mar_11_22:13:24_CDT_2019
Cuda compilation tools, release 10.0, V10.0.326
/usr/local/cuda-10.0/samples/5_Simulations/oceanFFT$ sudo SMS=72 EXTRA_LDFLAGS=–unresolved-symbols=ignore-in-shared-libs TARGET_ARCH=aarch64 make
/usr/local/cuda-10.0/bin/nvcc -ccbin g++ -m64 -Xlinker –unresolved-symbols=ignore-in-shared-libs -gencode arch=compute_72,code=sm_72 -gencode arch=compute_72,code=compute_72 -o oceanFFT oceanFFT.o oceanFFT_kernel.o -L/usr/lib/nvidia-container-csv-cuda -lGL -lGLU -lglut -lcufft
/usr/bin/ld: cannot find –unresolved-symbols=ignore-in-shared-libs: No such file or directory
collect2: error: ld returned 1 exit status
Makefile:314: recipe for target 'oceanFFT' failed
make: *** [oceanFFT] Error 1
I was trying to troubleshoot with Microsoft guys onnxruntime build procedure which used to fail at execution of the code
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu
"#ifndef __CUDACC__\n"
"# error \"The CMAKE_CUDA_COMPILER is set to an invalid CUDA compiler\"\n"
"#endif\n"
"int main(){return 0;}\n")
as
/usr/local/cuda-10.0/bin/nvcc -cudart shared -Xcompiler=-fPIE -x cu -c /code/onnxruntime/build/Linux/Release/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_bb43d.dir/main.cu.o