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: patch-diff.githubusercontent.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:354dc3be-1922-badb-8e3a-310426b13dc6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB02:3410DA:8AF5964:B595C34:696CCDB2 |
| html-safe-nonce | 18ea049e9f1972c4decb8695ece5cc7579489aa9faa59cf7deaa4cfe132e7569 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjAyOjM0MTBEQTo4QUY1OTY0OkI1OTVDMzQ6Njk2Q0NEQjIiLCJ2aXNpdG9yX2lkIjoiMTc3MzQ1MzI1NzQwNTY4MTA3NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | eba58e1a5d871f872b451e76d51d52c0c46e704384f0fd9c97a886ca921f0d3c |
| 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 | 31994babd8463b50f2371f63aab0826561f4efe3981ac0ebc4c33e6c41032dbd |
| 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 | f5a202c3c4aefc9cf00c8c78951a1e72eaebebeb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width