-
Notifications
You must be signed in to change notification settings - Fork 685
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
Dev support tensor pin memory #8073
Conversation
oneflow/core/framework/op_interpreter/eager_mirrored_op_interpreter.cpp
Outdated
Show resolved
Hide resolved
Speed stats:
|
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/8073/ |
Speed stats:
|
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/8073/ |
Speed stats:
|
CI failed when running job: cuda-benchmark. PR label automerge has been removed |
EagerBlobObject::pin_memory_入侵得特别厉害。从Functor到op_interpreter到EagerBlobObject一路都涉及。导致很多代码很突兀。 可以不可以有更为简便的做法,比如我们引入特殊的StreamRole::kComputeOnPinMemory。这样的stream的allocator就是pinned memory。 |
vm::Allocator* allocator = nullptr; | ||
if (pin_memory) { | ||
CHECK_EQ_OR_RETURN(device_ctx->device_type(), DeviceType::kCPU) | ||
<< Error::RuntimeError() << "cannot pin tensor with device: " << device_ctx->device_type() | ||
<< ", only dense CPU tensors can be pinned."; | ||
allocator = dynamic_cast<CpuDeviceCtx*>(device_ctx)->mut_pin_memory_allocator(); | ||
if (allocator == nullptr) { | ||
// for some reason, the pin_memory_allocator will fail to create | ||
// e.g. with no CUDA library support and only can use oneflow in cpu only mode | ||
return Error::RuntimeError() | ||
<< "create pin_memory allocator failed for some reason. mostly, this error has " | ||
"occurred because you are trying to use some CUDA functionality, but the CUDA " | ||
"library has not been loaded by the dynamic linker for some reason."; | ||
} | ||
} else { | ||
allocator = device_ctx->mut_allocator(); | ||
} | ||
CHECK_NOTNULL_OR_RETURN(allocator) << Error::RuntimeError() << "allocator created failed!"; |
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.
这些特判都非常突兀。
但是pin_memory支持确实存在2个需求:
不知道StreamRole::kComputeOnPinMemory这个能不能解决这两个需求😂 |
需求1的解决办法:重写XXXOp::InferDeviceAndStream方法。类似CopyOp::InferDeviceAndStream。 以上都是现成的机制。 |
相关issue:https://github.com/Oneflow-Inc/OneTeam/issues/1180