ptxas fatal : Unresolved extern function Error 255
This question already has an answer here:
I am trying to understand how to decouple CUDA __device__
codes in separate header files.
I have three files.
File: : int2.cuh #ifndef INT2_H_
#define INT2_H_ #include "cuda.h"
#include "cuda_runtime.h"
#include "device_launch_parameters.h" __global__ void kernel();
__device__ int k2(int k); int launchKernel(int dim); #endif /* INT2_H_ */
File : int2.cu #include "int2.cuh"
#include "cstdio" __global__ void kernel() {
int tid = threadIdx.x;
printf("%d\n", k2(tid));
} __device__ int k2(int i) {
return i * i;
} int launchKernel(int dim) {
kernel<<<, dim>>>();
cudaDeviceReset();
return ;
}
File : CUDASample.cu include <stdio.h>
#include <stdlib.h>
#include "int2.cuh"
#include "iostream" using namespace std; static const int WORK_SIZE = ; __global__ void sampleCuda() {
int tid = threadIdx.x;
// printf("%d\n", k2(tid)); //Can not call k2
printf("%d\n", tid * tid);
} int main(void) { int var;
var = launchKernel(); kernel<<<, >>>();
cudaDeviceReset(); sampleCuda<<<, >>>();
cudaDeviceReset(); return ;
}
The code works file. I can call the sampleCuda()
kernel (in same file), call the C function launchKernel()
(in other file), and call kernel()
directly (in other file).
The problem I am facing is calling the __device__
function from sampleCuda()
kernel. then it shows the following error. However, the same function is callable in kernel()
.
:: **** Incremental Build of configuration Debug for project CUDASample ****
make all
Building file: ../src/CUDASample.cu
Invoking: NVCC Compiler
/Developer/NVIDIA/CUDA-6.5/bin/nvcc -G -g -O0 -gencode arch=compute_20,code=sm_20 -odir "src" -M -o "src/CUDASample.d" "../src/CUDASample.cu"
/Developer/NVIDIA/CUDA-6.5/bin/nvcc -G -g -O0 --compile --relocatable-device-code=false -gencode arch=compute_20,code=compute_20 -gencode arch=compute_20,code=sm_20 -x cu -o "src/CUDASample.o" "../src/CUDASample.cu"
../src/CUDASample.cu(): warning: variable "var" was set but never used ../src/CUDASample.cu(): warning: variable "WORK_SIZE" was declared but never referenced ../src/CUDASample.cu(): warning: variable "var" was set but never used ../src/CUDASample.cu(): warning: variable "WORK_SIZE" was declared but never referenced ptxas fatal : Unresolved extern function '_Z2k2i'
make: *** [src/CUDASample.o] Error :: Build Finished (took 2s.388ms)
上面这个错误的解决方法都是:需要分开编译文件,对应的编译参数为--relocatable-device-code={true,false}将false 改为 true
nsight 的设置的位置为:
In Nsight Eclipse, the option is available as the radio button "Separate compilation" under Project > Properties > Build > Settings > CUDA > switch to advanced mode 里面勾选就可以了。
VS的设置位置为:刚才突然想写。。找不到了。。具体google 搜索吧,best wishes....
ptxas fatal : Unresolved extern function Error 255的更多相关文章
- Qt error ------ no matching function for call to QObject::connect(QSpinBox*&, <unresolved overloaded function type>, QSlider*&, void (QAbstractSlider::*)(int))
connect(ui->spinBox_luminosity,&QSpinBox::valueChanged, ui->horizontalSlider_luminosity, & ...
- SourceTree不出现用户登录窗口,提示错误fatal: unable to access'...'; error setting certificate verify locations
SourceTree不出现用户登录窗口,提示错误fatal: unable to access'...'; error setting certificate verify locations; .. ...
- error #10234-D: unresolved symbols remain error #10010: errors encountered during linking;
error #10234-D: unresolved symbols remain error #10010: errors encountered during linking;: include ...
- nodejs -- fs模块 ---> readFile 函数 1) fs.readFile(filename, "binary", function(error, file) 2) response.write(file, "binary");
一:代码: 1.1 入口文件: index.js var server = require('./server'); var router = require("./router" ...
- 在新版linux上编译老版本的kernel出现kernel/timeconst.h] Error 255
在使用ubuntu16.4编译Linux-2.6.31内核时出现这样的错误 可以修改timeconst.pl的内容后正常编译. 以下是编译错误提示的内容: Can't use 'defined(@ar ...
- vector排序问题<unresolved overloaded function type>
要对vector中的自定义类型进行排序,首先需要提供一个函数bool comp(const Interval & a, const Interval & b) 来定义类型的排序准则 然 ...
- vue & arrow function error
vue & arrow function error <template> <div class="home"> <img alt=" ...
- mysql innodb init function error
150414 16:23:07 [ERROR] Plugin 'InnoDB' init function returned error. 150414 16:23:07 [ERROR] Plugin ...
- Unresolved import *** (models) error on Eclipse
Eclipse version: Oxygen.2 Release (4.7.2) Python version: 3.6 问题:系统提示:from django.db import models 语 ...
随机推荐
- Azure一个Cloud Service支持多个公网地址
Azure刚刚发布在同一个Cloud Service下支持多个公网IP地址的功能. 这个功能主要是用于: 当相同的端口需要公用相同的LoadBalance时. 比如: 一种使用场景是多组Web服务器被 ...
- .NETFramework-Timers:Timer
ylbtech-.NETFramework-Timers:Timer 1.程序集 System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b7 ...
- Elasticsearch集成ik分词器
1.插件地址https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.0.0/elasticsearch-anal ...
- Arduino 元件
http://www.rs-online.com/designspark/electronics/
- java之二叉树--未完待续
参考http://how2j.cn/k/collection/collection-tree/476.html#nowhere 二叉树概念 二叉树由各种节点组成二叉树特点:每个节点都可以有左子节点,右 ...
- Laravel框架中使用邮件发送功能
这里是演示的用户注册之后,进行邮件激活的功能. 点击注册之后,系统会自动发送一个份邮件到注册者的邮箱,注册者点击链接激活账号. 先配置laravel中的(.env)文件 MAIL_DRIVER=smt ...
- charles关于手机APP抓包
这里相比其他抓包软件来说要简单的多了,具体步骤如下: 1 使手机和电脑在一个局域网内,不一定非要是一个ip段,只要是同一个漏油器下就可以了,比如电脑连接的有线网ip为192.168.16.12,然后手 ...
- 重启centOS丢失nginx.pid导致无法启动nginx的解决方法
目录 找到nginx 找到nginx的配置文件 拼接命令,启动nginx Nginx指令拓展知识(中英对照): tags: centOS linux nginx categories: 服务器 找到n ...
- JS数组去重精简版
看了很多人写的好几个去重方法,我在这里精简组合下,适用于已排序与未排序的数组. 废话不多说,上代码. <!DOCTYPE html> <html> <head> & ...
- Leetcode:单调数列
题目 如果数组是单调递增或单调递减的,那么它是单调的. 如果对于所有 i <= j,A[i] <= A[j],那么数组 A 是单调递增的. 如果对于所有 i <= j,A[i]> ...