Title: Backend choice reset inside of threads · Issue #257 · arrayfire/arrayfire-python · GitHub
Open Graph Title: Backend choice reset inside of threads · Issue #257 · arrayfire/arrayfire-python
X Title: Backend choice reset inside of threads · Issue #257 · arrayfire/arrayfire-python
Description: Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread: >>> import arrayfire as af >>> af.get_available_backends() ('cpu', 'cuda', 'opencl') >>> af.get_active_backend() 'cuda' >>> af.set_...
Open Graph Description: Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread: >>> import arrayfire as af >>> af.get_available_backends() ('cpu', 'cuda', 'opencl') >>> af...
X Description: Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread: >>> import arrayfire as af >>> af.get_available_backends() ('cpu'...
Opengraph URL: https://github.com/arrayfire/arrayfire-python/issues/257
X: @github
Domain: redirect.github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Backend choice reset inside of threads","articleBody":"Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread:\r\n\r\n```python\r\n\u003e\u003e\u003e import arrayfire as af\r\n\u003e\u003e\u003e af.get_available_backends()\r\n('cpu', 'cuda', 'opencl')\r\n\u003e\u003e\u003e af.get_active_backend()\r\n'cuda'\r\n\u003e\u003e\u003e af.set_backend('opencl')\r\n\u003e\u003e\u003e af.get_active_backend()\r\n'opencl'\r\n\u003e\u003e\u003e from threading import Thread\r\n\u003e\u003e\u003e Thread(target=lambda: print(af.get_active_backend())).start()\r\ncuda\r\n```\r\n\r\nIs this expected behavior and/or documented anywhere? I would think that the active backend should be process local rather than thread local.\r\n\r\nIf it matters, here's my version info:\r\nOS: Ubuntu 20.04\r\narrayfire: 3.9.0 (commit [955152b6](https://github.com/arrayfire/arrayfire/commit/955152b6570c608ae74ebd9e6b31d48351cb8a16))\r\narrayfire-python: 3.8.10\r\n\r\ncuda: 11.4.0-1\r\nocl-icd-libopencl1: 2.2.11-1\r\nintel-mkl: 2020.0.166-1","author":{"url":"https://github.com/hexane360","@type":"Person","name":"hexane360"},"datePublished":"2021-07-07T06:58:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/257/arrayfire-python/issues/257"}
| 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:bfcb501e-3c2c-14fb-e8e0-c842c320d2b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E94A:2F21B4:9B5122:C9210A:696B203D |
| html-safe-nonce | 5899416ba7531e383b549ebb2813458a041796fea41267723dd3daba72265dc3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTRBOjJGMjFCNDo5QjUxMjI6QzkyMTBBOjY5NkIyMDNEIiwidmlzaXRvcl9pZCI6IjMyMDAxMTc2MjA3NjkyMzUwMDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 40e3d8079e42cb02d93251932b474266cf2116e8f91bdc678c288579d6696969 |
| hovercard-subject-tag | issue:938556120 |
| 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/arrayfire/arrayfire-python/257/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db6829030e4951d72f1c6d86272165141ab78eb133bac6fa326cfbf00b36b50a/arrayfire/arrayfire-python/issues/257 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db6829030e4951d72f1c6d86272165141ab78eb133bac6fa326cfbf00b36b50a/arrayfire/arrayfire-python/issues/257 |
| og:image:alt | Inside a new thread, Arrayfire uses the default backend rather than the backend set by the parent thread: >>> import arrayfire as af >>> af.get_available_backends() ('cpu', 'cuda', 'opencl') >>> af... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hexane360 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/arrayfire/arrayfire-python git https://github.com/arrayfire/arrayfire-python.git |
| octolytics-dimension-user_id | 5395442 |
| octolytics-dimension-user_login | arrayfire |
| octolytics-dimension-repository_id | 37599258 |
| octolytics-dimension-repository_nwo | arrayfire/arrayfire-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 37599258 |
| octolytics-dimension-repository_network_root_nwo | arrayfire/arrayfire-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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width