diff --git a/paddle/framework/tensor.h b/paddle/framework/tensor.h index 4f07350e59dea72431417876f41f172e51ea53f9..1dd421cdb681e15486e309ff912574af35b5a0c2 100644 --- a/paddle/framework/tensor.h +++ b/paddle/framework/tensor.h @@ -71,14 +71,14 @@ class Tensor { holder_.reset(new PlaceholderImpl( boost::get(place), product(dims_) * sizeof(T))); } else if (platform::is_gpu_place(place)) { -#ifdef __CUDACC__ +#ifdef PADDLE_ONLY_CPU + PADDLE_THROW("'GPUPlace' is not supported in CPU only device."); +#else holder_.reset(new PlaceholderImpl( boost::get(place), product(dims_) * sizeof(T))); -#else - PADDLE_ENFORCE(true, "'GPUPlace' is not supported in CPU only device."); #endif } else { - PADDLE_ENFORCE(true, "Unknown 'place'."); + PADDLE_THROW("Unknown 'place'."); } offset_ = 0; }