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 语 ...
随机推荐
- Idea无法加载主类
今天重装了下电脑,运行idea发现各种问题. 直接进主题哈, 遇到三种情况 第一种: 首先查看这里是否有多个,只保留当前需要用工程路径.点击P右边的删除即可 删除后 然后运行是否能运行. 如果没有的话 ...
- win7 64位搭建Mantis 缺陷管理系统
什么是Mantis MantisBT is a free popular web-based bugtracking system (feature list). It is written in t ...
- JS---设计简易日历
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 微软企业库的 注入和依赖&nbs…
Working with ObjectBuilder This topic has not yet been rated - Rate this topic Retired Content This ...
- 条款39:明智而审慎的使用private继承
Use private inheritance judiciously. 如果classes之间的继承关系是private,编译器不会自动将一个derived class对象转换为一个base cla ...
- 35.Docker安装Mysql挂载Host Volume
连个文件系统有块区域Area,我们要做的是把两个Area做文件映射 jesse腾讯云上有个linux的环境,版本比较老了 简书的地址: https://www.jianshu.com/p/b3bf64 ...
- HDU - 6112 2017百度之星初赛A 今夕何夕
今夕何夕 Accepts: 1345 Submissions: 5533 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/ ...
- 注册美国iTunes账号步骤(跳过绑定银行卡)
步骤: 将iTunes客户端升级到最新版本 注销当前登陆的用户,随便搜索一个免费的应用 点击下载,此时会弹框提示你登陆,点击下方注册超链 跳转到注册页面,同意各种条款,点击下一步 填写邮箱(最好用gm ...
- 【异步编程】Part2:掌控SynchronizationContext避免deadlock
引言: 多线程编程/异步编程非常复杂,有很多概念和工具需要去学习,贴心的.NET提供Task线程包装类和await/async异步编程语法糖简化了异步编程方式. 相信很多开发者都看到如下异步编程实践原 ...
- 洛谷 - P1063 - 能量项链 - 区间dp
https://www.luogu.org/problemnew/show/P1063 这个并不是每次只能从两边扩展的,可以从中间断开. #include<bits/stdc++.h> u ...