Commit 9832489dc2830cbdce42deea77857b7979904761

Authored by David Mayerich
1 parent fab07d70

edited main.cu to make the program more robust if a GPU isn't available

Showing 1 changed file with 5 additions and 2 deletions   Show diff stats
@@ -822,8 +822,11 @@ void setdevice(int &device){ @@ -822,8 +822,11 @@ void setdevice(int &device){
822 int count; 822 int count;
823 cudaGetDeviceCount(&count); // numbers of device that are available 823 cudaGetDeviceCount(&count); // numbers of device that are available
824 if(count < device + 1){ 824 if(count < device + 1){
825 - std::cout<<"No such device available, please set another device"<<std::endl;  
826 - exit(1); 825 + std::cout<<"The selected CUDA device ("<<device<<") is unavailable. "<<count<<" devices are detected."<<std::endl;
  826 + if (count == 0)
  827 + device = -1;
  828 + else
  829 + exit(1);
827 } 830 }
828 } 831 }
829 #else 832 #else