common: added DeviceQuery() function
authorYangqing Jia <jiayq84@gmail.com>
Thu, 24 Oct 2013 17:01:19 +0000 (10:01 -0700)
committerYangqing Jia <jiayq84@gmail.com>
Thu, 24 Oct 2013 17:01:19 +0000 (10:01 -0700)
include/caffe/common.hpp
src/caffe/common.cpp
src/caffe/solver.cpp

index cc6e31b705b0b22840d6e51821e0489eee924619..7362b233780d7d205906df1e53bbab2950e86fa5 100644 (file)
@@ -91,6 +91,8 @@ class Caffe {
   inline static void set_phase(Phase phase) { Get().phase_ = phase; }
   // Sets the random seed of both MKL and curand
   static void set_random_seed(const unsigned int seed);
+  // Prints the current GPU status.
+  static void DeviceQuery();
 
  protected:
   cublasHandle_t cublas_handle_;
index 373fc585342845b67b7aab91a6b8be6270878d9f..1fce86a2d17a1fe174bb948ba92ad50fc2b2257f 100644 (file)
@@ -1,5 +1,6 @@
 // Copyright 2013 Yangqing Jia
 
+#include <cstdio>
 #include <ctime>
 
 #include "caffe/common.hpp"
@@ -73,4 +74,33 @@ void Caffe::set_random_seed(const unsigned int seed) {
   VSL_CHECK(vslNewStream(&(Get().vsl_stream_), VSL_BRNG_MT19937, seed));
 }
 
+void Caffe::DeviceQuery() {
+  cudaDeviceProp prop;
+  int device;
+  CUDA_CHECK(cudaGetDevice(&device));
+  CUDA_CHECK(cudaGetDeviceProperties(&prop, device));
+  printf("Major revision number:         %d\n", prop.major);
+  printf("Minor revision number:         %d\n", prop.minor);
+  printf("Name:                          %s\n", prop.name);
+  printf("Total global memory:           %lu\n", prop.totalGlobalMem);
+  printf("Total shared memory per block: %lu\n", prop.sharedMemPerBlock);
+  printf("Total registers per block:     %d\n", prop.regsPerBlock);
+  printf("Warp size:                     %d\n", prop.warpSize);
+  printf("Maximum memory pitch:          %lu\n", prop.memPitch);
+  printf("Maximum threads per block:     %d\n", prop.maxThreadsPerBlock);
+  printf("Maximum dimension of block:    %d, %d, %d\n",
+      prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]);
+  printf("Maximum dimension of grid:     %d, %d, %d\n",
+      prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]);
+  printf("Clock rate:                    %d\n", prop.clockRate);
+  printf("Total constant memory:         %lu\n", prop.totalConstMem);
+  printf("Texture alignment:             %lu\n", prop.textureAlignment);
+  printf("Concurrent copy and execution: %s\n",
+      (prop.deviceOverlap ? "Yes" : "No"));
+  printf("Number of multiprocessors:     %d\n", prop.multiProcessorCount);
+  printf("Kernel execution timeout:      %s\n",
+      (prop.kernelExecTimeoutEnabled ? "Yes" : "No"));
+  return;
+}
+
 }  // namespace caffe
index 6fe2ce91257d7601ce44093cbf0a5312445ed8af..87c346f7036bd32a29d6364cc619efcd3ea2d7e2 100644 (file)
@@ -202,6 +202,7 @@ template <typename Dtype>
 void SGDSolver<Dtype>::RestoreSolverState(const SolverState& state) {
   CHECK_EQ(state.history_size(), history_.size())
       << "Incorrect length of history blobs.";
+  LOG(INFO) << "SGDSolver: restoring history";
   for (int i = 0; i < history_.size(); ++i) {
     history_[i]->FromProto(state.history(i));
   }