diff --git a/paddle/framework/tensor.h b/paddle/framework/tensor.h index b405e3877c9f15712dd5bbf08de1e4f7148e0fd9..802471b341e1ff8b3db4be39b32efa6b993a576f 100644 --- a/paddle/framework/tensor.h +++ b/paddle/framework/tensor.h @@ -55,14 +55,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; }