-
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
"fix gpu init" #7528
"fix gpu init" #7528
Conversation
paddle/framework/init.cc
Outdated
} | ||
#else | ||
LOG(WARNING) | ||
<< "'GPU' is not supported, Please re-compile with WITH_GPU option"; | ||
<< "'CUDA' is not supported, Please re-compile with WITH_CUDA option"; |
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.
Currently, CMakeLists.txt
does not have WITH_CUDA
option.
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.
done
paddle/framework/init.cc
Outdated
int count = platform::GetCUDADeviceCount(); | ||
for (int i = 0; i < count; ++i) { | ||
places.emplace_back(platform::CUDAPlace(i)); | ||
} |
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.
The strict way to write is to put line54~56 outside try...catch
.
But it's not a big problem here. Please feel free to change it or not.
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.
done
python/paddle/v2/fluid/__init__.py
Outdated
'WARNING: CUDA_VISIBLE_DEVICES set to {0}, not empty . The computation ' | ||
'speed will not be optimized if you use multi-gpu. It will ' | ||
'fail if this PaddlePaddle binary is compiled without GPU option' | ||
.format(gpu_devices), |
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.
- You want to remind users that currently fluid does not support multi-GPU training, right?
- If the user does not compile
PaddlePaddle
with GPU option, this warning will not show. SoIt will fail if this PaddlePaddle ...
is unnecessary.
python/paddle/v2/fluid/__init__.py
Outdated
file=sys.stderr) | ||
else: | ||
gpu_devices = "0" | ||
os.environ['CUDA_VISIBLE_DEVICES'] = gpu_devices |
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.
The logic of line 99~110 maybe has some problem.
} | ||
|
||
TEST(InitDevices, CUDA) { | ||
using paddle::framework::InitDevices; |
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.
#ifdef PADDLE_WITH_CUDA
should be placed in line31.
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.
This test is compiled in nv_test.
So #ifdef PADDLE_WITH_CUDA
is no needed.
paddle/framework/init_test.cc
Outdated
try { | ||
count = paddle::platform::GetCUDADeviceCount(); | ||
} catch (const std::exception& exp) { | ||
} |
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.
If #ifdef PADDLE_WITH_CUDA
is placed in line 31, I think try ... catch
is unnecessary.
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.
done
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.
LGTM
fix init gpu error.