Skip to content

Instantly share code, notes, and snippets.

@shadiakiki1986
Created July 28, 2020 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadiakiki1986/e2e4612ec62da3e53b639631da7dd43a to your computer and use it in GitHub Desktop.
Save shadiakiki1986/e2e4612ec62da3e53b639631da7dd43a to your computer and use it in GitHub Desktop.
show gpu devices with CUDA C++
// from https://github.com/FBerendsen/niftireg/blob/fc526c152fd5eaced271d1d6de7c16661b2abd3e/reg-lib/cuda/checkCudaCard.cpp
//
// rm test
// g++ -I/usr/local/cuda/include -L/usr/local/cuda/lib64 -lcuda test.cpp # undefined reference to cudaGetDeviceCount
// PATH=$PATH:/usr/local/cuda/bin/
// nvcc -x cu test.cpp --std=c++11 -lineinfo -o test
#include <cuda_runtime.h>
//#include <cuda.h>
//#include <stdio.h>
#include <iostream>
int main() {
int deviceCount = 0;
cudaGetDeviceCount(&deviceCount);
std::cout<<"Devices: "<<deviceCount<<std::endl;
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment