Skip to content

Conversation

forresti
Copy link
Contributor

@forresti forresti commented Mar 7, 2014

When CUDA has an error, it throws a number like "2" or "7" or something like that. Previously, Caffe was just printing out the error number, and the user needed to go look up the meaning of the error number. With this addition to the code, CUDA errors are now printed in plaintext (e.g. "out of memory.")

I verified that errors are still caught properly, and that the tests still pass. Still gives the correct ImageNet-val results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably using LOG(ERROR) or LOG(FATAL) will be better in this case

@forresti
Copy link
Contributor Author

forresti commented Mar 8, 2014

@sguada Good idea, Sergio. I changed the code so that it writes the error to LOG(FATAL), and I verified that it handles errors appropriately. Does this look reasonable to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why printf? You can just concatenate by << as the other LOG in Caffe do.

@shelhamer
Copy link
Member

Hey Forrest, thanks for polishing away this rough edge! Having more informative errors should help quiet down recurring questions about memory and hardware too.

Let's merge after the slight style changes I commented on.

@forresti
Copy link
Contributor Author

@shelhamer @kloudkl All right, I polished away that rough edge. We're now writing CUDA errors to glog with cout<< instead of printf style syntax.

@shelhamer shelhamer merged this pull request into BVLC:dev Mar 10, 2014
@shelhamer
Copy link
Member

Thanks Forrest!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CHECK_EQ(res, cudaSuccess) << your_message_here instead of an if statement maybe. It will deal with log and exit automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants