Title: Querying current device is slow compared to CuPy · Issue #439 · NVIDIA/cuda-python · GitHub
Open Graph Title: Querying current device is slow compared to CuPy · Issue #439 · NVIDIA/cuda-python
X Title: Querying current device is slow compared to CuPy · Issue #439 · NVIDIA/cuda-python
Description: Getting the current device using cuda.core is quite a bit slower than CuPy: In [1]: import cupy as cp In [2]: %timeit cp.cuda.Device() 69 ns ± 0.496 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each) In [3]: from cuda.core.e...
Open Graph Description: Getting the current device using cuda.core is quite a bit slower than CuPy: In [1]: import cupy as cp In [2]: %timeit cp.cuda.Device() 69 ns ± 0.496 ns per loop (mean ± std. dev. of 7 runs, 10,000,...
X Description: Getting the current device using cuda.core is quite a bit slower than CuPy: In [1]: import cupy as cp In [2]: %timeit cp.cuda.Device() 69 ns ± 0.496 ns per loop (mean ± std. dev. of 7 runs, 10,000,...
Opengraph URL: https://github.com/NVIDIA/cuda-python/issues/439
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Querying current device is slow compared to CuPy","articleBody":"Getting the current device using `cuda.core` is quite a bit slower than CuPy:\n\n```python\nIn [1]: import cupy as cp\n\nIn [2]: %timeit cp.cuda.Device()\n69 ns ± 0.496 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)\n\nIn [3]: from cuda.core.experimental import Device\n\nIn [4]: %timeit Device()\n795 ns ± 0.273 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n```\n\nUltimately, my goal is to get the compute capability of the current device, and this is even slower:\n\n```python\nIn [5]: %timeit cp.cuda.Device().compute_capability\n89.1 ns ± 0.413 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)\n\nIn [6]: %timeit Device().compute_capability\n2.64 μs ± 122 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n```\n\nAre there tricks (e.g., caching) CuPy is employing here that `cuda.core` can use as well? Alternately, is there another way for me to use `cuda.core` or `cuda.bindings` to get this information quickly? Note that for my use case, I'm not super concerned about the _first_ call to `Device()`, but I do want _subsequent_ calls to be trivially inexpensive if the current device hasn't changed.\n\n---\n\nUsing the low-level cuda.bindings is also not quite as fast:\n\n```python\nIn [11]: def get_cc():\n ...: dev = runtime.cudaGetDevice()[1]\n ...: return driver.cuDeviceComputeCapability(dev)\n ...:\n\nIn [12]: get_cc()\nOut[12]: (\u003cCUresult.CUDA_SUCCESS: 0>, 7, 5)\n\nIn [13]: %timeit get_cc()\n597 ns ± 0.494 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n```\n","author":{"url":"https://github.com/shwina","@type":"Person","name":"shwina"},"datePublished":"2025-02-07T16:17:52Z","url":"https://github.com/NVIDIA/cuda-python/issues/439"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8a389d93-8d58-367f-3182-259f770f3bfc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE70:2068A3:525DEA:715D2B:6AF84557 |
| html-safe-nonce | f7f3c5787cfc48ef2ba5db8f9aeaab9b4b5df1851b4d2a426d3ff45f24c9aba8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTcwOjIwNjhBMzo1MjVERUE6NzE1RDJCOjZBRjg0NTU3IiwidmlzaXRvcl9pZCI6IjU2MzQ3NDIwODQ3NTg0MjI4NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ef9768c39ebc4e9733946302d9cf86b52074b8a618642d173f07e4f871daff40 |
| hovercard-subject-tag | issue:2838552686 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NVIDIA/cuda-python/439/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2418554c6ef6e1a5d7c0426b04284a4d1fa6fa8aa5a9127893fa77d10e15f25d/NVIDIA/cuda-python/issues/439 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2418554c6ef6e1a5d7c0426b04284a4d1fa6fa8aa5a9127893fa77d10e15f25d/NVIDIA/cuda-python/issues/439 |
| og:image:alt | Getting the current device using cuda.core is quite a bit slower than CuPy: In [1]: import cupy as cp In [2]: %timeit cp.cuda.Device() 69 ns ± 0.496 ns per loop (mean ± std. dev. of 7 runs, 10,000,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shwina |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| go-import | github.com/NVIDIA/cuda-python git https://github.com/NVIDIA/cuda-python.git |
| octolytics-dimension-user_id | 1728152 |
| octolytics-dimension-user_login | NVIDIA |
| octolytics-dimension-repository_id | 381173759 |
| octolytics-dimension-repository_nwo | NVIDIA/cuda-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 381173759 |
| octolytics-dimension-repository_network_root_nwo | NVIDIA/cuda-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width