René's URL Explorer Experiment


Title: Cannot use CUDA Python to interact with external C/C++ code · Issue #22 · NVIDIA/cuda-python · GitHub

Open Graph Title: Cannot use CUDA Python to interact with external C/C++ code · Issue #22 · NVIDIA/cuda-python

X Title: Cannot use CUDA Python to interact with external C/C++ code · Issue #22 · NVIDIA/cuda-python

Description: The problem The Cython example below demonstrates an attempt to use CUDA Python to interact with some external C++ code. Note that the "external code" is included inline in the Cython. # distutils: language=c++ # distutils: extra_compile...

Open Graph Description: The problem The Cython example below demonstrates an attempt to use CUDA Python to interact with some external C++ code. Note that the "external code" is included inline in the Cython. # distutils:...

X Description: The problem The Cython example below demonstrates an attempt to use CUDA Python to interact with some external C++ code. Note that the "external code" is included inline in the Cython. # ...

Opengraph URL: https://github.com/NVIDIA/cuda-python/issues/22

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot use CUDA Python to interact with external C/C++ code","articleBody":"# The problem\r\n\r\nThe Cython example below demonstrates an attempt to use CUDA Python to interact with some external C++ code. Note that the \"external code\" is included inline in the Cython.\r\n\r\n```cython\r\n# distutils: language=c++\r\n# distutils: extra_compile_args=-I/usr/local/cuda/include/\r\n\r\nfrom cuda.ccudart cimport cudaMemAllocationHandleType\r\n\r\ncdef extern from *:\r\n    \"\"\"\r\n    #include \u003ccuda_runtime_api.h>\r\n    \r\n    void foo(cudaMemAllocationHandleType x) {\r\n        return;\r\n    }\r\n    \"\"\"\r\n    void foo(cudaMemAllocationHandleType x)\r\n\r\nfoo(cudaMemAllocationHandleType.cudaMemHandleTypeNone)\r\n```\r\n\r\nThe external code is a function `foo` that accepts a `cudaMemAllocationHandleType`. We attempt to invoke that function from Cython by passing  in a  `cuda.ccudart.cudaMemAlloccationHandleType`, but this fails with an error like:\r\n\r\n```cython\r\nerror: cannot convert '__pyx_t_4cuda_7ccudart_cudaMemAllocationHandleType' to 'cudaMemAllocationHandleType'\r\n 4857 |   foo(__pyx_e_4cuda_7ccudart_cudaMemHandleTypeNone);\r\n```\r\n\r\nTo reproduce the problem, save the example above to a flle `foo.pyx`, then run  `cythonize -i foo.pyx`.\r\n\r\n# Why this happens\r\n\r\nThis is because the function `foo` expects a `cudaMemAllocationHandleType` that is defined in the CUDA runtime library. But CUDA Python \"rewrites\" the runtime library at the Cython layer, and has its _own_ `cudaMemAllocationHandleType` (which ends up with a mangled name when transpiled from Cython to C++). The two are not interchangeable.\r\n\r\n# A potential solution\r\n\r\nA potential solution, proposed by @leofang in an offline discussion, is to use extern declarations for types in `ccudart.pxd`, rather than to redefine them. For example:\r\n\r\n```diff\r\ndiff --git a/cuda/ccudart.pxd b/cuda/ccudart.pxd\r\nindex 57e1e96..6c0b5d4 100644\r\n--- a/cuda/ccudart.pxd\r\n+++ b/cuda/ccudart.pxd\r\n@@ -678,11 +678,12 @@ cdef enum cudaMemAllocationType:\r\n     cudaMemAllocationTypePinned = 1\r\n     cudaMemAllocationTypeMax = 2147483647\r\n \r\n-cdef enum cudaMemAllocationHandleType:\r\n-    cudaMemHandleTypeNone = 0\r\n-    cudaMemHandleTypePosixFileDescriptor = 1\r\n-    cudaMemHandleTypeWin32 = 2\r\n-    cudaMemHandleTypeWin32Kmt = 4\r\n+cdef extern from 'driver_types.h':\r\n+    ctypedef enum cudaMemAllocationHandleType 'cudaMemAllocationHandleType':\r\n+        cudaMemHandleTypeNone = 0\r\n+        cudaMemHandleTypePosixFileDescriptor = 1\r\n+        cudaMemHandleTypeWin32 = 2\r\n+        cudaMemHandleTypeWin32Kmt = 4\r\n \r\n cdef struct cudaMemPoolProps:\r\n     cudaMemAllocationType allocType\r\ndiff --git a/setup.py b/setup.py\r\nindex 394166e..16fad9f 100644\r\n--- a/setup.py\r\n+++ b/setup.py\r\n@@ -30,6 +30,7 @@ except Exception:\r\n \r\n include_dirs = [\r\n     os.path.dirname(sysconfig.get_path(\"include\")),\r\n+    '/usr/local/cuda-11.4/include',\r\n ]\r\n \r\n library_dirs = [get_python_lib(), os.path.join(os.sys.prefix, \"lib\")]\r\n```\r\n\r\n## Gotcha\r\n\r\nCurrently, we ship a single version of CUDA Python that is built with the latest CUDA toolkit, and we expect it to work for older minor versions of  the CUDA toolkit by leveraging CUDA enhanced compatibility.\r\n\r\nHistorically, there have been cases when the runtime API has changed across minor versions of the CUDA toolkit. In particular, the names/ordering of enum members have changed between minor versions. For example, in CUDA 10.1, there was a typo in the enum member `cudaErrorDeviceUninitilialized` that was fixed in 10.2.\r\n\r\nIt's not clear how we would handle the situation if something like that were to happen again. In the example above, we would have to have separate extern declarations for 10.1 and 10.2 somehow.","author":{"url":"https://github.com/shwina","@type":"Person","name":"shwina"},"datePublished":"2022-05-11T19:10:53Z","url":"https://github.com/NVIDIA/cuda-python/issues/22"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f463560f-35f4-9ad2-1c2e-99d2dd857380
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBE9A:1E497:428A1F:5C25B0:6AF840B2
html-safe-nonce8d822bd3352a95710f80e8d889fc8cc034e405a18dc41189fd6c783880c156bf
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTlBOjFFNDk3OjQyOEExRjo1QzI1QjA6NkFGODQwQjIiLCJ2aXNpdG9yX2lkIjoiNjk4NTc0MTA0NjE2Nzc5OTU1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6ac27a8ddcb79c798f13191f05add01964e078ac4442db6f95da97d9c0ee7da3
hovercard-subject-tagissue:1233073815
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NVIDIA/cuda-python/22/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5b30cb459de6ab9dc6306ecc1cc93858aa86e234cc35b2bf8fdea06e4102846d/NVIDIA/cuda-python/issues/22
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5b30cb459de6ab9dc6306ecc1cc93858aa86e234cc35b2bf8fdea06e4102846d/NVIDIA/cuda-python/issues/22
og:image:altThe problem The Cython example below demonstrates an attempt to use CUDA Python to interact with some external C++ code. Note that the "external code" is included inline in the Cython. # distutils:...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameshwina
hostnamegithub.com
expected-hostnamegithub.com
None5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db
turbo-cache-controlno-preview
go-importgithub.com/NVIDIA/cuda-python git https://github.com/NVIDIA/cuda-python.git
octolytics-dimension-user_id1728152
octolytics-dimension-user_loginNVIDIA
octolytics-dimension-repository_id381173759
octolytics-dimension-repository_nwoNVIDIA/cuda-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id381173759
octolytics-dimension-repository_network_root_nwoNVIDIA/cuda-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release653be32ff5c755082a4db662491bfbbcfc9112c1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/NVIDIA/cuda-python/issues/22#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNVIDIA%2Fcuda-python%2Fissues%2F22
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNVIDIA%2Fcuda-python%2Fissues%2F22
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=NVIDIA%2Fcuda-python
Reloadhttps://github.com/NVIDIA/cuda-python/issues/22
Reloadhttps://github.com/NVIDIA/cuda-python/issues/22
Reloadhttps://github.com/NVIDIA/cuda-python/issues/22
NVIDIAhttps://github.com/NVIDIA
cuda-pythonhttps://github.com/NVIDIA/cuda-python
Codehttps://github.com/NVIDIA/cuda-python
Issues219 (219)https://github.com/NVIDIA/cuda-python/issues
Pull requests92 (92)https://github.com/NVIDIA/cuda-python/pulls
Discussionshttps://github.com/NVIDIA/cuda-python/discussions
Actionshttps://github.com/NVIDIA/cuda-python/actions
Projectshttps://github.com/NVIDIA/cuda-python/projects
Wikihttps://github.com/NVIDIA/cuda-python/wiki
Security and qualityhttps://github.com/NVIDIA/cuda-python/security
Insightshttps://github.com/NVIDIA/cuda-python/pulse
https://github.com/NVIDIA/cuda-python
New issuehttps://github.com/login?return_to=https://github.com/NVIDIA/cuda-python/issues/22
New issuehttps://github.com/login?return_to=https://github.com/NVIDIA/cuda-python/issues/22
Cannot use CUDA Python to interact with external C/C++ codehttps://github.com/NVIDIA/cuda-python/issues/22#top
https://github.com/shwina
shwinahttps://github.com/shwina
on May 11, 2022https://github.com/NVIDIA/cuda-python/issues/22#issue-1233073815
@leofanghttps://github.com/leofang
https://github.com/jakirkham
jakirkhamhttps://github.com/jakirkham
on May 11, 2022https://github.com/NVIDIA/cuda-python/issues/22#issuecomment-1124199527
@vzhurba01https://github.com/vzhurba01
https://github.com/vzhurba01
vzhurba01https://github.com/vzhurba01
on Jun 29, 2022https://github.com/NVIDIA/cuda-python/issues/22#issuecomment-1170505743
v11.7.1https://github.com/NVIDIA/cuda-python/releases/tag/v11.7.1
vzhurba01https://github.com/vzhurba01
completedhttps://github.com/NVIDIA/cuda-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 29, 2022https://github.com/NVIDIA/cuda-python/issues/22#event-6905947252
https://github.com/leofang
leofanghttps://github.com/leofang
on Mar 4, 2025https://github.com/NVIDIA/cuda-python/issues/22#issuecomment-2696153817
conda-forge/cuda-python-feedstock#15https://github.com/conda-forge/cuda-python-feedstock/issues/15
rparolinhttps://github.com/rparolin
on Aug 12, 2026https://github.com/NVIDIA/cuda-python/issues/22#event-29356204967
docs: document per-subproject license files in root READMEhttps://github.com/rparolin/cuda-python/commit/6079aaf1cee436e6d5c135c1bf21c7838dea2a0c
6079aafhttps://github.com/rparolin/cuda-python/commit/6079aaf1cee436e6d5c135c1bf21c7838dea2a0c
chore: fix Apache-2.0 license notice and attribution gaps (#2605)https://github.com/NVIDIA/cuda-python/commit/7c9dc09e90443787b454adb8ab53ddca06bd5fe6
#2605https://github.com/NVIDIA/cuda-python/pull/2605
7c9dc09https://github.com/NVIDIA/cuda-python/commit/7c9dc09e90443787b454adb8ab53ddca06bd5fe6
leofanghttps://github.com/leofang
on Sep 9, 2026https://github.com/NVIDIA/cuda-python/issues/22#event-30863809446
Prepare for 13.4.1 release (#2788)https://github.com/NVIDIA/cuda-python/commit/0770ab6ced8931ae8b6c6e5f622f48cb07ea99fa
#2788https://github.com/NVIDIA/cuda-python/pull/2788
0770ab6https://github.com/NVIDIA/cuda-python/commit/0770ab6ced8931ae8b6c6e5f622f48cb07ea99fa
Pull 13.4.1 changes into main (#2789)https://github.com/NVIDIA/cuda-python/commit/3ae71cab3f54a84f66b84eb4e6daf925d60bd2e9
#2789https://github.com/NVIDIA/cuda-python/pull/2789
3ae71cahttps://github.com/NVIDIA/cuda-python/commit/3ae71cab3f54a84f66b84eb4e6daf925d60bd2e9
Sign up for freehttps://github.com/signup?return_to=https://github.com/NVIDIA/cuda-python/issues/22
Sign in to commenthttps://github.com/login?return_to=https://github.com/NVIDIA/cuda-python/issues/22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.