Skip to content

Conversation

ronghanghu
Copy link
Member

Unless in CPU_ONLY build, always use cudaMallocHost and cudaFreeHost to allocate (and pin) and free cpu memory, so that it does not depend on Caffe::mode(), which is changable during runtime and can result in inconsistency between host memory allocation and free. This should fix #3053.

Eventually it is better to give mode and device to net and layers, in the spirit of #1500. But it seems like a short-term fix to always use cudaMallocHost to allocate cpu memory regardless of the mode of the net to avoid this crash without significant overhead.

However, although mode/device is right now not a member of Net and Layer and thus changable in runtime, it is better to set them in advance and not change them during a lifecycle of a net.

Unless in CPU_ONLY build, always use cudaMallocHost and cudaFreeHost to allocate (and pin) and free cpu memory, so that it does not depend on Caffe::mode(), which is changable during runtime and can result in inconsistency between host memory allocation and free.
@ronghanghu
Copy link
Member Author

Ah, Travis CI Failed because cudaMallocHost seems to assume at least one GPU is there (I don't know why since allocating and pinning memory shouldn't involve any GPU).

seem to be running into the same issue as mentioned in 46a431a

@ronghanghu ronghanghu closed this Sep 13, 2015
@ronghanghu ronghanghu deleted the always-use-cudamallochost branch September 23, 2015 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error with cudaFreeHost(ptr) in syncedmem.hpp:30

1 participant