[OpenCL] Refactor OpenCL init function#13919
Merged
masahi merged 1 commit intoapache:mainfrom Feb 7, 2023
Merged
Conversation
On the platforms with several OpenCL platforms (e.g. Intel CPU and
NVidia GPU) it was possible to use OpenCL device only from one
platform. And in case when Intel was the first in the platforms list
than it wasn't possible to run model on NVidia GPU.
In this PR the init function was modified and now it is possible to use
OpenCL devices from different platforms. In case when there are several
GPU accelerators then it is possible to select one of them. You can use
device id to select GPU device. On the code below the device names of
two OpenCL devices are printed:
```python
import tvm
print("opencl 0: ", tvm.opencl(0).device_name)
print("opencl 1: ", tvm.opencl(1).device_name)
```
In case then the machine doesn't contain any GPUs then we will try to
use CPU if OpenCL runtime is available.
Collaborator
|
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment. Generated by tvm-bot |
Contributor
Author
|
cc: @masahi, @elvin-n, @srkreddy1238 |
masahi
approved these changes
Feb 7, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the platforms with several OpenCL platforms (e.g. Intel CPU and NVidia GPU) it was possible to use OpenCL device only from one platform. And in case when Intel was the first in the platforms list than it wasn't possible to run model on NVidia GPU.
In this PR the init function was modified and now it is possible to use OpenCL devices from different platforms. In case when there are several GPU accelerators then it is possible to select one of them. You can use device id to select GPU device. On the code below the device names of two OpenCL devices are printed:
In case then the machine doesn't contain any GPUs then we will try to use CPU if OpenCL runtime is available.