Skip to content
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

How to initialize onnx input CreateTensor with gpu meory instead of CreateCpu #19240

Open
wangzhenlin123 opened this issue Jan 23, 2024 · 3 comments
Labels
ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot

Comments

@wangzhenlin123
Copy link

Describe the issue

hi,How to initialize onnx input CreateTensor with gpu meory instead of CreateCpu?I haven't found a solution yet。

To reproduce

Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault);
//Ort::MemoryInfo memory_info = Ort::MemoryInfo::CreateCuda(OrtDeviceAllocator, 0);
Ort::Value input_tensor = Ort::Value::CreateTensor(memory_info, input_tensor_values.data(),
input_tensor_size, input_node_dims.data(), 4);

Urgency

No response

Platform

Windows

OS Version

win10

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.8.1 or 1.16

ONNX Runtime API

C++

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

No response

@github-actions github-actions bot added ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform labels Jan 23, 2024
@pranavsharma
Copy link
Contributor

This API helps you create memory info for any EP.

/** \brief Create an ::OrtMemoryInfo
*
* \param[in] name
* \param[in] type
* \param[in] id
* \param[in] mem_type
* \param[out] out Newly created ::OrtMemoryInfo. Must be freed with OrtAPi::ReleaseMemoryInfo
*
* \snippet{doc} snippets.dox OrtStatus Return Value
*/
ORT_API2_STATUS(CreateMemoryInfo, _In_ const char* name, enum OrtAllocatorType type, int id,
enum OrtMemType mem_type, _Outptr_ OrtMemoryInfo** out);

@yuslepukhin
Copy link
Member

auto cuda_mem_info = Ort::MemoryInfo{"cuda", OrtArenaAllocator, OrtMemTypeDefault};

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:CUDA issues related to the CUDA execution provider platform:windows issues related to the Windows platform stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

3 participants