public void cudaSetDevice_cudaGetDeviceProperties_cudaDriverGetVersion_cudaRuntimeGetVersion_test() { int deviceCount = 0; var status = CudaRuntimeApi.cudaGetDeviceCount(ref deviceCount); Assert.AreEqual(status, cudaError.cudaSuccess); // This function call returns 0 if there are no CUDA capable devices. if (deviceCount == 0) { Console.WriteLine("There are no available device(s) that support CUDA"); } else { Console.WriteLine("Detected {0} CUDA Capable device(s)", deviceCount); } for (int i = 0; i < deviceCount; i++) { status = CudaRuntimeApi.cudaSetDevice(i); Assert.AreEqual(status, cudaError.cudaSuccess); int driverVersion = 0; int runtimeVersion = 0; status = CudaRuntimeApi.cudaDriverGetVersion(ref driverVersion); Assert.AreEqual(status, cudaError.cudaSuccess); status = CudaRuntimeApi.cudaRuntimeGetVersion(ref runtimeVersion); Assert.AreEqual(status, cudaError.cudaSuccess); var deviceProp = new cudaDeviceProp(); CudaRuntimeApi.cudaGetDeviceProperties(ref deviceProp, i); var uuid = HexStringFromByteArray(UnsignedBytesFromSignedBytes(deviceProp.uuid.bytes)); var devName = Encoding.Default.GetString(UnsignedBytesFromSignedBytes(deviceProp.name)).TrimEnd('\0'); Console.WriteLine("\nDevice {0}: \"{1}\", uuid = {2}", i, devName, uuid); Console.WriteLine(" CUDA Driver Version / Runtime Version {0}.{1} / {2}.{3}", driverVersion / 1000, (driverVersion % 100) / 10, runtimeVersion / 1000, (runtimeVersion % 100) / 10); Console.WriteLine(" CUDA Capability Major/Minor version number: {0}.{1}", deviceProp.major, deviceProp.minor); Console.WriteLine( " Total amount of global memory: {0:0} MBytes ({1} bytes)", Convert.ToSingle(deviceProp.totalGlobalMem / 1048576.0f), deviceProp.totalGlobalMem); } }