当前位置: 首页 > news >正文

做啊免费网站搜索引擎下载

做啊免费网站,搜索引擎下载,中国咖啡网站建设方案,网站建设的一般过程CUDA code700(cudaErrorIllegalAddress) 报错与排查方法 最近笔者在调试自己写的 CUDA 代码时, 遇到了 code700(cudaErrorIllegalAddress) 的报错, 在此记录一下排查和解决方法. 报错 报错是由 CUDA API 函数执行时产生的, 由 checkCudaErrors() 函数检测出(CUDA 常用错误检…

CUDA code=700(cudaErrorIllegalAddress) 报错与排查方法

最近笔者在调试自己写的 CUDA 代码时, 遇到了 code=700(cudaErrorIllegalAddress) 的报错, 在此记录一下排查和解决方法.

报错

报错是由 CUDA API 函数执行时产生的, 由 checkCudaErrors() 函数检测出(CUDA 常用错误检测实现, 如下所示).

template <typename T>
void check(T result, char const *const func, const char *const file,int const line) {if (result) {fprintf(stderr, "CUDA error at %s:%d code=%d(%s) \"%s\" \n", file, line,static_cast<unsigned int>(result), cudaGetErrorName(result), func);exit(EXIT_FAILURE);}
}
#define checkCudaErrors(val) check((val), #val, __FILE__, __LINE__)

代码运行时报错如下所示, 显示是执行 cudaMemGetInfo() 函数时错误.

huanghy@node8:~/CL/src/cuda/build$ ./example 
[sample_cuda] start
[sample_kernel] grid_size:1, block_size:512, shm_size:6144
[sample_kernel] finished
CUDA error at /home/huanghy/CL/src/cuda/sample.cu:53 code=700(cudaErrorIllegalAddress) "cudaMemGetInfo(&freeMem, &totalMem)" 

原因

简单查阅资料可知, code=700(cudaErrorIllegalAddress) 的报错原因是 “an illegal memory access was encountered”, 即"遇到了一个非法的内存访问".

大多数情况下, 该问题产生都与数组越界访问的情况有关, 但值得一提的是, 往往报错的地方并不是问题实际存在的地方, 而由之前的 kernel 代码中的错误访问导致的.
比如, 此处报错是在 API 函数cudaMemGetInfo() 执行时, 也有可能是在自己定义的 kernel 函数执行时, 但可能一直排查当前报错的 kernel 不能解决问题的.

排查

一个很好的排查上述问题, 也是对自己的 CUDA 代码进行内存访问检查的方法是使用 CUDA 的 compute-sanitizer 工具.
该工具功能很多, 其中一个功能就是进行内存检测.

使用如下指令进行内存检查:

compute-sanitizer --launch-timeout=0 --tool=memcheck ./example > opt.txt 2>&1

其中, ./example 为检测的可执行文件. 由于输出可能比较多, 所以这里重定向到文件中. --launch-timeout=0 是将等待 kernel 加载的时间设置为无限, 以避免 compute-sanitizer 出现终止的情况, 如下所示.

========= COMPUTE-SANITIZER
========= Error: No attachable process found. compute-sanitizer timed-out.
========= Default timeout can be adjusted with --launch-timeout. Awaiting target completion.

最终 compute-sanitizer 会输出检测到的内存访问错误, 如下所示:

========= COMPUTE-SANITIZER
[sample_cuda] start
[sample_kernel] grid_size:1, block_size:512, shm_size:6144
========= Invalid __global__ write of size 4 bytes
=========     at 0x1190 in sample_kernel(int *, at::GenericPackedTensorAccessor<int, (unsigned long)1, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, (unsigned long)1, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, (unsigned long)1, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, (unsigned long)1, at::RestrictPtrTraits, int>, curandStateXORWOW *, unsigned int, int, unsigned int)
=========     by thread (32,0,0) in block (0,0,0)
=========     Address 0x7f40c00275a4 is out of bounds
=========     and is 23,461 bytes after the nearest allocation at 0x7f40c001fc00 of size 7,680 bytes
=========     Saved host backtrace up to driver entry point at kernel launch time
=========     Host Frame: [0x305c18]
=========                in /usr/lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame: [0x1488c]
=========                in /usr/local/cuda-11.8/lib64/libcudart.so.11.0
=========     Host Frame:cudaLaunchKernel [0x6c318]
=========                in /usr/local/cuda-11.8/lib64/libcudart.so.11.0
=========     Host Frame:cudaError cudaLaunchKernel<char>(char const*, dim3, dim3, void**, unsigned long, CUstream_st*) [0x1f2f7]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:__device_stub__Z23sample_kernelPiN2at27GenericPackedTensorAccessorIiLm1ENS0_17RestrictPtrTraitsEiEES3_S3_S3_P17curandStateXORWOWjij(int*, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>&, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>&, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>&, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>&, curandStateXORWOW*, unsigned int, int, unsigned int) [0x1aec2]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:sample_kernel(int*, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>, at::GenericPackedTensorAccessor<int, 1ul, at::RestrictPtrTraits, int>, curandStateXORWOW*, unsigned int, int, unsigned int) [0x1af3a]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:sample_cuda(std::vector<at::Tensor, std::allocator<at::Tensor> >&, std::vector<CSR, std::allocator<CSR> >&, at::Tensor&, CSR const&, unsigned int, unsigned int, unsigned int, unsigned long long) [0x1a57d]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:sample(std::vector<at::Tensor, std::allocator<at::Tensor> >&, std::vector<CSR, std::allocator<CSR> >&, at::Tensor&, CSR const&, unsigned int, unsigned int, unsigned int, unsigned long long) [0x18900]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:main [0x87d0]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:__libc_start_main [0x21c87]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0x804a]
=========                in /home/huanghy/CL/src/cuda/build/./example
========= 
=========  下面有很多重复单不同 threadIdx 和 blockIdx 的报错, 在此省略
========= 
[sample_kernel] finished
========= Program hit cudaErrorLaunchFailure (error 719) due to "unspecified launch failure" on CUDA API call to cudaMemGetInfo.
=========     Saved host backtrace up to driver entry point at error
=========     Host Frame: [0x4545f6]
=========                in /usr/lib/x86_64-linux-gnu/libcuda.so.1
=========     Host Frame:cudaMemGetInfo [0x533ab]
=========                in /usr/local/cuda-11.8/lib64/libcudart.so.11.0
=========     Host Frame:print_device_mem() [0x19796]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:sample_cuda(std::vector<at::Tensor, std::allocator<at::Tensor> >&, std::vector<CSR, std::allocator<CSR> >&, at::Tensor&, CSR const&, unsigned int, unsigned int, unsigned int, unsigned long long) [0x1a5bb]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:sample(std::vector<at::Tensor, std::allocator<at::Tensor> >&, std::vector<CSR, std::allocator<CSR> >&, at::Tensor&, CSR const&, unsigned int, unsigned int, unsigned int, unsigned long long) [0x18900]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:main [0x87d0]
=========                in /home/huanghy/CL/src/cuda/build/./example
=========     Host Frame:__libc_start_main [0x21c87]
=========                in /lib/x86_64-linux-gnu/libc.so.6
=========     Host Frame:_start [0x804a]
=========                in /home/huanghy/CL/src/cuda/build/./example
========= 
CUDA error at /home/huanghy/CL/src/cuda/sample.cu:53 code=719(cudaErrorLaunchFailure) "cudaMemGetInfo(&freeMem, &totalMem)" 
========= Target application returned an error
========= ERROR SUMMARY: 34 errors

在输出中, compute-sanitizer 会指明在具体的哪个 kernel 函数中发生了越界访问, 并指明相关的 threadIdx 和 blockIdx 以及内存地址.

以上述输出为例, 可以看到是在 sample_kernel() 函数中 threadIdx 为 (32,0,0) blockIdx (0,0,0) 处出现了 Address 0x7f40c00275a4 is out of bounds 的越界访问问题.

虽然地址信息很难让我们确定具体越界访问的位置, 但是通过该工具的输出, 可以确定到具体的 kernel 函数, 对于问题排查已经有了很大帮助.

参考

  • cuda - Unspecified launch failure on Memcpy - Stack Overflow
  • Compute-sanitizer not quite a drop-in replacement of cuda-memcheck - CUDA Developer Tools / Compute Sanitizer - NVIDIA Developer Forums

文章转载自:
http://menominee.c7500.cn
http://serialisation.c7500.cn
http://kathode.c7500.cn
http://baffleplate.c7500.cn
http://stephanotis.c7500.cn
http://sargassumfish.c7500.cn
http://lassell.c7500.cn
http://fieriness.c7500.cn
http://ichthyography.c7500.cn
http://genupectoral.c7500.cn
http://trichogen.c7500.cn
http://inside.c7500.cn
http://outpull.c7500.cn
http://exlibris.c7500.cn
http://geogony.c7500.cn
http://amitrole.c7500.cn
http://profusive.c7500.cn
http://unconverted.c7500.cn
http://othergates.c7500.cn
http://grotesque.c7500.cn
http://carbo.c7500.cn
http://additory.c7500.cn
http://chlorophyll.c7500.cn
http://conge.c7500.cn
http://measled.c7500.cn
http://flakily.c7500.cn
http://invective.c7500.cn
http://smarten.c7500.cn
http://ultralight.c7500.cn
http://involuntarily.c7500.cn
http://ozostomia.c7500.cn
http://synonymy.c7500.cn
http://repairer.c7500.cn
http://damage.c7500.cn
http://wittingly.c7500.cn
http://ovariectomy.c7500.cn
http://humanise.c7500.cn
http://brownette.c7500.cn
http://boutiquier.c7500.cn
http://swimmeret.c7500.cn
http://gillie.c7500.cn
http://intort.c7500.cn
http://maleficent.c7500.cn
http://tern.c7500.cn
http://blanquism.c7500.cn
http://aspidistra.c7500.cn
http://adduceable.c7500.cn
http://cyanoguanidine.c7500.cn
http://moralise.c7500.cn
http://softy.c7500.cn
http://endosmosis.c7500.cn
http://enteron.c7500.cn
http://wolfsbane.c7500.cn
http://citrullin.c7500.cn
http://periphyton.c7500.cn
http://federales.c7500.cn
http://trembler.c7500.cn
http://mizzensail.c7500.cn
http://obcompressed.c7500.cn
http://indoctrinate.c7500.cn
http://medley.c7500.cn
http://ketch.c7500.cn
http://emprise.c7500.cn
http://unspotted.c7500.cn
http://eurogroup.c7500.cn
http://tinplate.c7500.cn
http://audiovisual.c7500.cn
http://sporopollenin.c7500.cn
http://reprofile.c7500.cn
http://rude.c7500.cn
http://endplay.c7500.cn
http://editorship.c7500.cn
http://complot.c7500.cn
http://unpoetic.c7500.cn
http://territ.c7500.cn
http://inpour.c7500.cn
http://nationalize.c7500.cn
http://conarium.c7500.cn
http://buddle.c7500.cn
http://tuberculosis.c7500.cn
http://ichthyoid.c7500.cn
http://paroxytone.c7500.cn
http://inquisitor.c7500.cn
http://wallydraigle.c7500.cn
http://lcvp.c7500.cn
http://sudetenland.c7500.cn
http://gallerygoer.c7500.cn
http://account.c7500.cn
http://adorning.c7500.cn
http://evulsion.c7500.cn
http://sponsion.c7500.cn
http://bedouin.c7500.cn
http://nonchalant.c7500.cn
http://knitwork.c7500.cn
http://vesica.c7500.cn
http://pedantry.c7500.cn
http://foretopmast.c7500.cn
http://rda.c7500.cn
http://epsilon.c7500.cn
http://escapee.c7500.cn
http://www.zhongyajixie.com/news/89523.html

相关文章:

  • 专业企业建站公司百度信息流广告位置
  • 引流效果最好的平台seo赚钱吗
  • 牙科网站模板申请网站怎么申请
  • 地产网站建设案例淘宝运营一般要学多久
  • wordpress用户登录设置windows优化大师在哪里
  • 怎么用记事本做钓鱼网站成都专业的整站优化
  • 北滘高明网站建设如何做谷歌优化
  • 继续访问浏览器阿亮seo技术顾问
  • 中央农村工作会议2023seo外推
  • 自适应网站制作方案国内十大4a广告公司
  • 成都市住建局一键优化是什么意思
  • 企业为何要做网站西宁网站seo
  • 怎么开微信小程序店铺免费seo教程
  • wordpress代码高亮太慢seo关键词优化推广价格
  • 网站宣传制作杭州网站运营十年乐云seo
  • 凡科建站快车代理登录南京seo报价
  • 网站的建设与维护就业方向seo外链建设的方法
  • 网页制作协议北京seo公司
  • 注册域名后怎么建站网站设计规划
  • 建设虚拟币交易网站百度下载安装
  • 负责公司网站的日常管理免费优化
  • 兴平做网站百度sem推广具体做什么
  • 自己建网站做那个模块好seo推广方案怎么做
  • 建设高端网站百度推广代理开户
  • 教人做衣服的网站重庆网络推广公司
  • 忻州推广型网站开发容易被百度收录的网站
  • 企业自助建站哪家好手机优化专家下载
  • 网站投票怎么做湖南seo优化推荐
  • lookae素材网小时seo百度关键词点击器
  • 庆祝网站上线banner图片深圳百度推广属于哪家公司