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 语 ...
随机推荐
- 兼容ie6,ie7,ie8,firefox,chrome浏览器的代码片段
hack实现方式和原理 #hacker{ color:red; *color:white; /*for ie6,ie7*/ *+color:blue; /*for ie7*/ _color:gray; ...
- WPF学习笔记系列之一 (布局详情)
布局:StackPanel 栈布局:控件不会拐弯且多出的不再显示.DockPanel 停靠布局 吸在上边下边或左右.WrapPanel 环绕布局 一行控件会拐弯Canvas 进行基于 ...
- PKI标准、CA采取的规范、X509、PKCS
PKI:Public Key Infrastructure 公钥基础设施 PKI标准可以分为第一代和第二代标准. 第一代PKI标准主要包括美国RSA公司的公钥加密标准(Public Key Crypt ...
- (I/O完成端口中的)995错误
在windows下,可能会出现995的错误,msdn对该错误的解释为: The I/O operation has been aborted because of either a thread ex ...
- Sharepoint2013搜索学习笔记之设置业务数据内容源(六)
Sharepoint搜索爬网组件支持爬Business Data Connectivity Service 承载的外部数据,关于Business Data Connectivity Service设置 ...
- JS实现页面刷新方法
下面介绍全页面刷新方法:有时候可能会用到 window.location.reload()刷新当前页面. parent.location.reload()刷新父亲对象(用于框架) opener.loc ...
- uva11584 Partitioning by Palindromes
题目大意: 给出一个字符串,把他划分成尽量少的回文串,问最少的回文串个数 /* 先预处理所有回文子串 dp[i]表示字符1~i划分成的最小回文串的个数 */ #include<iostream& ...
- [Xcode 实际操作]六、媒体与动画-(2)使用图形上下文转换图片为灰度图
目录:[Swift]Xcode实际操作 本文将演示如何将图片转换为灰度图. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit class V ...
- 面试大厂回来后,有一些话想对 Java 后端开发说一说
在上周,我密集面试了若干位Java后端的候选人,工作经验在3到5年间.我的标准其实不复杂:第一能干活,第二Java基础要好,第三最好熟悉些分布式框架,我相信其它公司招初级开发时,应该也照着这个标准来面 ...
- Java基础--常用API--字符串相关API
一.java.lang.String 1.string对象不可变,被final修饰,不能被继承. 2.赋值方式: (1)直接赋值.比如: String name = "rick"; ...