-
Notifications
You must be signed in to change notification settings - Fork 171
Switch to use CUDA driver APIs in Device
constructor
#460
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
base: main
Are you sure you want to change the base?
Conversation
Device
constructorDevice
constructor
/ok to test |
|
/ok to test c9fac0b |
This is ready. |
/ok to test d70ec24 |
err, dev = driver.cuCtxGetDevice() | ||
if err == 0: | ||
device_id = int(dev) | ||
elif err == 201: # CUDA_ERROR_INVALID_CONTEXT |
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.
Can we use the enum value from driver
here instead of 201?
@@ -959,7 +960,7 @@ class Device: | |||
|
|||
__slots__ = ("_id", "_mr", "_has_inited", "_properties") | |||
|
|||
def __new__(cls, device_id=None): | |||
def __new__(cls, device_id: int = None): |
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.
I think this should be Optional[int]
?
if not (0 <= device_id < total): | ||
raise ValueError(f"device_id must be within [0, {total}), got {device_id}") | ||
err, dev = driver.cuCtxGetDevice() | ||
if err == 0: |
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.
+1 would be good to use driver.CUResult.CUDA_SUCCESS
?
/ok to test d279e50 |
Blocked by #687. |
Before this PR:
With this PR:
(Bindings are built from the main branch.)