-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Legacy nvcc support #1236
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
Legacy nvcc support #1236
Conversation
|
On second thought, there is an even simpler solution:
This way there's no need for conditional includes, hence no macros. Warning: this PR needs to be tested in OSX. Further details: If we avoid opencv includes in headers (which breaks compilation with legacy nvcc), we need a forward declaration of A potentially better approach would be to drop the opencv dependency in Caffe's public API by introducing a wrapper for |
This was the approach taken for boost RNG when it conflicted in this same way with NVCC. It is more work to have a dummy class for nothing but legacy compatibility. Ideally we can go without it, since the RNG class was comparatively simple compared to |
|
@sguada dropping the problematic OpenCV includes from the headers seems like a reasonable fix and this works for me on OS X 10.9. Please double-check and merge. |
|
OpenCV has a CUDA module in itself. How does it build successfully? |
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 solution doesn't work for vectorcv::Mat, any idea why?
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 line simply declares "there's class Mat in namespace cv". Clearly, it won't work for other namespaces, like the vectorcv. Now, I'm not sure about the details here (what is the vectorcv?), but one way to fix it could be to add a similar line with the vectorcv namespace.
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.
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.
@bhack thanks, I also suspected it, but then it should actually work (and it does work for me - see below).
@sguada I would need more details to help here - what exactly doesn't work?
This compiles on my machine:
in data_transformer.hpp:
void Transform(const vector<cv::Mat>& cv_img, Blob<Dtype>* transformed_blob);
in data_transformer.cpp:
template<typename Dtype>
void DataTransformer<Dtype>::Transform(const vector<cv::Mat>& cv_img, Blob<Dtype>* transformed_blob) {
for (int item_id = 0; item_id < cv_img.size(); ++item_id) {
Transform(cv_img[item_id], transformed_blob);
}
}
Drop OpenCV includes from NVCC code for legacy reasons.
|
This ended up fine on OS X. While I'm not so enthused to bring an OpenCV declaration into |
I guess if you use vector::resize() which takes matrix by value, class definition is required. |
Hey,
unfortunately, commit 0ba046b (merge PR #1070) breaks compilation in our legacy environment (we currently use cuda toolkit 5.0 and nvcc with gcc 4.4). The compilation errors we get are of the following type:
This could be related to a similar issue with intrinsics when compiling under OSX (mentioned in #1070).
The proposed fix is to avoid inclusion of the opencv header when compiling with nvcc and the host gcc is < 4.7.
I kept the original workaround with the OSX flag for now, but my guess is the whole check could be simplified as:
that is, the cuda code does not actually require opencv, except for the class declaration
cv::Mat.The downside of this approach is that
ReadImageToCVMatis not inlined.