<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<font face="serif">Gentlemen -- as a few of you had issues with the
CUDA cards dying on your last week and then not letting you run
subsequent codes on the cards, I took a few minutes Friday morning
and came up with a solution that will at lease let your do
subsequent calculations.<br>
<br>
In this code I get the device error from the card (which should be
no error, the devices are working fine they just can't allocate
the memory) and then free up the device pointer(s), and then reset
the card before terminating.<br>
<br>
</font><br>
<font face="serif"> </font><tt>// Allocate memory on the card to
store the matrices</tt><tt><br>
</tt><tt> if ( (cudaStat = cudaMalloc(&d_A, DIM*DIM *
sizeof(double))) != cudaSuccess ){</tt><tt><br>
</tt><tt> errorstring = cudaGetErrorString(err);</tt><tt><br>
</tt><tt> printf("Device memory allocation failed with err:
%s.\n", errorstring);</tt><tt><br>
</tt><tt> cudaFree(d_A);</tt><tt><br>
</tt><tt> cudaDeviceReset();</tt><tt><br>
</tt><tt> exit(1);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> if ( (cudaStat = cudaMalloc(&d_B, DIM*DIM *
sizeof(double))) != cudaSuccess ){</tt><tt><br>
</tt><tt> errorstring = cudaGetErrorString(err);</tt><tt><br>
</tt><tt> printf("Device memory allocation failed with err:
%s.\n", errorstring);</tt><tt><br>
</tt><tt> cudaFree(d_A);</tt><tt><br>
</tt><tt> cudaFree(d_B);</tt><tt><br>
</tt><tt> cudaDeviceReset();</tt><tt><br>
</tt><tt> exit(1);</tt><tt><br>
</tt><tt> }</tt><tt><br>
</tt><tt> if ( (cudaStat = cudaMalloc(&d_C, DIM*DIM *
sizeof(double))) != cudaSuccess ){</tt><tt><br>
</tt><tt> errorstring = cudaGetErrorString(err);</tt><tt><br>
</tt><tt> printf("Device memory allocation failed with err:
%s.\n", errorstring);</tt><tt><br>
</tt><tt> cudaFree(d_A);</tt><tt><br>
</tt><tt> cudaFree(d_B);</tt><tt><br>
</tt><tt> cudaFree(d_C);</tt><tt><br>
</tt><tt> cudaDeviceReset();</tt><tt><br>
</tt><tt> exit(1);</tt><tt><br>
</tt><tt> }</tt><br>
<font face="serif"><br>
</font>
<pre class="moz-signature" cols="72">--
Andrew J. Pounds, Ph.D. (<a class="moz-txt-link-abbreviated" href="mailto:pounds_aj@mercer.edu">pounds_aj@mercer.edu</a>)
Professor of Chemistry and Computer Science
Mercer University, Macon, GA 31207 (478) 301-5627
<a class="moz-txt-link-freetext" href="http://faculty.mercer.edu/pounds_aj">http://faculty.mercer.edu/pounds_aj</a>
</pre>
</body>
</html>