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 语 ...
随机推荐
- Jasper:用户指南 / 设备 / 生命周期管理 / SIM 卡状态
ylbtech-Jasper:用户指南 / 设备 / 生命周期管理 / SIM 卡状态 1.返回顶部 1. SIM 卡状态 每个设备都有一个状态,决定了它能否在网络上建立数据连接,并且会影响设备是否计 ...
- Component概念
转自:http://www.cnblogs.com/NEOCSL/archive/2012/05/06/2485227.html 1.总结 Component就是组建的意思,可以在DefaultPro ...
- Unix Timestamp
class Foundation_API DateTime /// This class represents an instant in time, expressed /// in years, ...
- Hibernate"discriminator-value"用法
转自:https://blog.csdn.net/iteye_3357/article/details/81862615 1 可能经常遇到这样的情况: 2 3 在数据库表中会有这样的一个字段用来区别记 ...
- [hdu2544]最短路spfa
解题关键:最短路模板一直没整理过,这里整理了一下spfa+链式前向星建图的最短路模板,以后网络赛省的打了. spfa算法的关键就是松弛操作,只有进行松弛操作,其后的点距离才可能被更新. #includ ...
- win764位安装mysql-5.6
1配置mysql的MYSQL_HOME和PATH 增加环境变量: MYSQL_HOME=D:\mysql-5.6.14-winx64 修改环境变脸: 在path后面增加%MYSQL_HOME%\bin ...
- 1.14不使用回车键来读取n个字符
read是一个重要的bash命令,它用于从键盘或标准输入中读取文本.可以使用read以交互的形式读取来自用户的输入,不过read能做的远不止这些.很多编程语言的输入库都是从键盘读取输入,且只有回车键按 ...
- 8. php回调后门
中国菜刀下载,基于原版中国菜刀优化版20160309. 下载地址: http://pan.baidu.com/s/1jHoJxHW China chopper http://pan.baidu.com ...
- GridView.SelectedIndex
获取或设置 GridView 控件中的选中行的索引. C#复制 [System.ComponentModel.Bindable(true)] public virtual int SelectedIn ...
- MySQL下载与安装配置
一.Windows 上安装 MySQL Windows 上安装 MySQL 相对简单,最新版本下载地址: 官网:https://dev.mysql.com/downloads/mysql/ 下载步骤: ...