{"id":5607,"date":"2018-01-03T13:35:57","date_gmt":"2018-01-03T13:35:57","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=5607"},"modified":"2018-01-03T13:35:57","modified_gmt":"2018-01-03T13:35:57","slug":"fixing-java-error-jcuda-cudaexception-cuda_error_invalid_context","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-java-error-jcuda-cudaexception-cuda_error_invalid_context\/","title":{"rendered":"Fixing Java error: jcuda.CudaException: CUDA_ERROR_INVALID_CONTEXT"},"content":{"rendered":"<p>If you try to use methods on a GPU with jCuda, you need to initialize a context:<\/p>\n<pre lang=\"java\">\ncuInit(0);\ncuDeviceGet(device, 0);\nCUcontext context = new CUcontext();\ncuCtxCreate(context, 0, device);\nCUdevice device = new CUdevice();\ncuDeviceGet(device, 0);\n<\/pre>\n<p>Note this gets the first GPU.<\/p>\n<p>Once you&#8217;ve done this, you can then get information from the device:<\/p>\n<pre lang=\"java\">\nlong total[] = { 0L };\nlong free[] = { 0L };\ncuMemGetInfo(total, free);\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fixing a jCUDA error<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[131,300],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5607"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=5607"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5607\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=5607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=5607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=5607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}