-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Executor need reasonable default value #5681
Conversation
def __init__(self, places): | ||
def __init__(self, places=None): | ||
if places is None: | ||
if core.is_compile_gpu(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to detect at runtime whether a GPU is present. It's very likely a compiled GPU version runs on a CPU only machine.
paddle/pybind/pybind.cc
Outdated
@@ -78,6 +78,14 @@ bool IsCompileGPU() { | |||
#endif | |||
} | |||
|
|||
int GetCUDADeviceCount() { | |||
#ifndef PADDLE_WITH_CUDA | |||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe return -1 here to indicate error. Because the function name is GetCUDADeviceCount
, if PADDLE_WITH_CUDA is OFF, the function can not do what its name suggests.
paddle/pybind/pybind.cc
Outdated
@@ -497,6 +505,7 @@ All parameter, weight, gradient are variables in Paddle. | |||
m.def("init_gflags", InitGflags); | |||
|
|||
m.def("is_compile_gpu", IsCompileGPU); | |||
m.def("get_cuda_device_count", GetCUDADeviceCount()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with Pybind, why it's a function invocation here? GetCUDADeviceCount()
, rather than GetCUDADeviceCount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bug. Thanks for pointing it out.
Thanks for the logic table! Very helpful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think there should be a default value of Executor.
Users can use CPU only training even the Paddle is compiled with GPU and there is a GPU on their computer.
@reyoung Thanks for your comments. The reason for this PR is more of python API thing. We want to hide |
fix #5648
When using
exe = Executor(place=None)
, the logic is the following: