matlab - 如何使用 MATLAB 在 GPU 上评估一个非常复杂的函数
问题描述
我在 Matlab 中有一个非常复杂的符号函数,我想在 GPU 上对其进行评估。
当我搜索时,为了评估,我们需要使用gpuArray
,但是当我尝试使用以下代码在 GPU matlab 上评估函数时:
joint_pdf_function_handle = @(x1,x2)sqrt(1.99e+2).*1.0./pi.^2.*exp(2.4e+1./2.5e+1).*exp(sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x1).*2.0).*(sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x1).*2.0).*4.925125628140704e+1-sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x2).*2.0).*4.974874371859296e+1).*(-1.0./2.0)+(sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x2).*2.0).*(sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x1).*2.0).*4.974874371859296e+1-sqrt(2.0).*erfcinv(integral(@(x)(1.0./sqrt(x.^2+9.0).*besselk(1,sqrt(x.^2+9.0).*(4.0./2.5e+1)).*7.757157130525889e-1)./pi,-Inf,x2).*2.0).*4.925125628140704e+1))./2.0).*1.0./sqrt(x1.^2+9.0).*1.0./sqrt(x2.^2+9.0).*besselk(1,sqrt(x1.^2+9.0).*(4.0./2.5e+1)).*besselk(1,sqrt(x2.^2+9.0).*(4.0./2.5e+1)).*1.157788944723618e-1
x1_space = gpuArray.linspace(-10,10,25) ;
x2_space = gpuArray.linspace(-10,10,25) ;
[X Y] = meshgrid(x1_space,x2_space) ;
F = arrayfun(joint_pdf_function_handle ,X, Y) ;
然后我收到以下错误:
The function 'symengine' cannot be executed because it has resolved to the P-code file:
C:\Program Files\Polyspace\R2019a\toolbox\symbolic\symbolic\symengine.p
问题是如果我像这样在 CPU 上运行代码,它工作正常:
x1_space = linspace(-10,10,25) ;
x2_space = linspace(-10,10,25) ;
[X Y] = meshgrid(x1_space,x2_space) ;
F = arrayfun(joint_pdf_function_handle ,X, Y) ;
我将不胜感激您能提供的任何帮助。
解决方案
推荐阅读
- c++ - 通过 C 中的偏移量调用函数
- google-provisioning-api - 如何获得 Provisioning API 的邀请?
- ios - 如何减少MKOverlay圈的厚度?
- xamarin.forms - Xamarin Forms - 指向可见的标签
- spring-integration - Spring集成:是否可以让发送者等到任务执行器队列/线程空闲。
- javascript - Phonegap Framework7后退按钮不起作用
- rx-java - 如何让 RetryWhen 重试抛出异常的流
- python - Selenium ChromeDriver 在 python3.5 ubuntu 中不起作用
- java - 如何通过java反射为setter方法设置变量
- git - 在声明性 Jenkins 管道中从私有 Git 存储库下载单个文件