{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/6022","labels_url":"https://api.github.com/repos/numpy/numpy/issues/6022/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/6022/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/6022/events","html_url":"https://github.com/numpy/numpy/issues/6022","id":91496948,"number":6022,"title":"Invalid offset in buffer format string generation, when trying to use PyOpenCl with Numpy","user":{"login":"Ragingdolphin","id":13079440,"avatar_url":"https://avatars.githubusercontent.com/u/13079440?v=3","gravatar_id":"","url":"https://api.github.com/users/Ragingdolphin","html_url":"https://github.com/Ragingdolphin","followers_url":"https://api.github.com/users/Ragingdolphin/followers","following_url":"https://api.github.com/users/Ragingdolphin/following{/other_user}","gists_url":"https://api.github.com/users/Ragingdolphin/gists{/gist_id}","starred_url":"https://api.github.com/users/Ragingdolphin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ragingdolphin/subscriptions","organizations_url":"https://api.github.com/users/Ragingdolphin/orgs","repos_url":"https://api.github.com/users/Ragingdolphin/repos","events_url":"https://api.github.com/users/Ragingdolphin/events{/privacy}","received_events_url":"https://api.github.com/users/Ragingdolphin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-06-27T18:02:17Z","updated_at":"2015-06-27T18:44:42Z","closed_at":null,"body":"I am porting over one of my projects from cpu to gpu and in the process I simply copied some of the code from http://documen.tician.de/pyopencl/howto.html\r\nHowever I keep getting a numpy error. Code:\r\n\r\n    import pyopencl as cl\r\n    import pyopencl.tools\r\n    import pyopencl.array\r\n    import numpy as np\r\n\r\n    def gpuTest():\r\n\t    context = cl.create_some_context(interactive=False)\r\n\t    queue = cl.CommandQueue(context)\r\n \t    my_struct = np.dtype([(\"field1\", np.int32), (\"field2\", np.float32)])\r\n\t    my_struct, my_struct_c_decl = cl.tools.match_dtype_to_c_struct(context.devices[0], \"my_struct\", my_struct)\r\n\t    my_struct = cl.tools.get_or_register_dtype(\"my_struct\", my_struct)\r\n\t\r\n\t    print(my_struct_c_decl)\r\n\t\r\n\t    ary_host = np.empty(20, my_struct)\r\n\t    ary_host[\"field1\"].fill(217)\r\n\t    ary_host[\"field2\"].fill(1000)\r\n\t    ary_host[13][\"field2\"] = 12\r\n\t\r\n\t    print(ary_host)\r\n\t\r\n\t    ary = cl.array.to_device(queue, ary_host)\r\n\t\r\n\t    prg = cl.Program(context, my_struct_c_decl + \"\"\"\r\n\t    ...     __kernel void set_to_1(__global my_struct *a)\r\n\t    ...     {\r\n\t    ...         a[get_global_id(0)].field1 = 1;\r\n\t    ...     }   \r\n\t    ...     \"\"\").build()\r\n\t\r\n\t    evt = prg.set_to_1(queue, ary.shape, None, ary.data)\r\n\t\r\n\t    print(ary)\r\n\t\r\n\t\r\n    gpuTest()\r\n    input()\r\n\r\nHere is the console output:\r\n\r\n    typedef struct {\r\n      int field1;\r\n      float field2;\r\n    } my_struct;\r\n\r\n\r\n    [(217, 1000) (217, 1000) (217, 1000) (217, 1000) (217, 1000) (217, 1000)\r\n     (217, 1000) (217, 1000) (217, 1000) (217, 1000) (217, 1000) (217, 1000)\r\n     (217, 1000) (217, 12) (217, 1000) (217, 1000) (217, 1000) (217, 1000)\r\n     (217, 1000) (217, 1000)]\r\n    Traceback (most recent call last):\r\n      File \"C:\\Users\\\\Desktop\\Programming\\Python Programming\\Pygpu\\main.py\", line 36, in <module>\r\n        gpuTest()\r\n      File \"C:\\Users\\\\Desktop\\Programming\\Python Programming\\Pygpu\\main.py\", line 22, in gpuTest\r\n        ary = cl.array.to_device(queue, ary_host)\r\n      File \"C:\\Python34\\lib\\site-packages\\pyopencl\\array.py\", line 1680, in to_device\r\n        result.set(ary, async=async)\r\n      File \"C:\\Python34\\lib\\site-packages\\pyopencl\\array.py\", line 670, in set\r\n        is_blocking=not async)\r\n      File \"C:\\Python34\\lib\\site-packages\\pyopencl\\__init__.py\", line 1051, in enqueue_copy\r\n        return _cl._enqueue_write_buffer(queue, dest, src, **kwargs)\r\n    RuntimeError: This should never happen: Invalid offset in buffer format string generation. Please \r\n    report a bug to the Numpy developers.\r\n    Press any key to continue . . .\r\n\r\nI cant seem to find anyone else who has had this kind of problem, is there something I could have done wrong when installing?\r\nThank you in advance"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/116115590","html_url":"https://github.com/numpy/numpy/issues/6022#issuecomment-116115590","issue_url":"https://api.github.com/repos/numpy/numpy/issues/6022","id":116115590,"user":{"login":"pv","id":35046,"avatar_url":"https://avatars.githubusercontent.com/u/35046?v=3","gravatar_id":"","url":"https://api.github.com/users/pv","html_url":"https://github.com/pv","followers_url":"https://api.github.com/users/pv/followers","following_url":"https://api.github.com/users/pv/following{/other_user}","gists_url":"https://api.github.com/users/pv/gists{/gist_id}","starred_url":"https://api.github.com/users/pv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pv/subscriptions","organizations_url":"https://api.github.com/users/pv/orgs","repos_url":"https://api.github.com/users/pv/repos","events_url":"https://api.github.com/users/pv/events{/privacy}","received_events_url":"https://api.github.com/users/pv/received_events","type":"User","site_admin":false},"created_at":"2015-06-27T18:44:42Z","updated_at":"2015-06-27T18:44:42Z","body":"@Ragingdolphin: as a work-around you can re-construct the dtype from the\ncontents of `my_struct.field`, but do it so that the fields are ordered\nso that offsets are increasing. Can't tell you exactly how this goes\nfrom the top of my head --- you'd need to look into the docs of np.dtype.\n"}}