Ich habe einen Fehler, wenn ich versuche, CUDA mit verschiebbaren Gerätecode zu kompilieren (-rdc = wahr). Ich verwende Visual Studio 2013 als Compiler mit CUDA 7.5. Unten ist ein kleines Beispiel, das den Fehler zeigt. Um dies zu verdeutlichen, ist der folgende Code in Ordnung, wenn -rdc = false, aber wenn er auf "true" gesetzt ist, wird der Fehler angezeigt.Thrust Fehler mit CUDA separate Kompilierung
Der Fehler einfach sagt: CUDA Fehler 11 [\ cuda \ Detail \ Cub \ device \ Dispatch/device_radix_sort_dispatch.cuh, 687]: ungültiges Argument
Dann fand ich this, die sagt:
When invoked with primitive data types, thrust::sort, thrust::sort_by_key,thrust::stable_sort, thrust::stable_sort_by_key may fail to link in some cases with nvcc -rdc=true.
Gibt es eine Problemumgehung, um separate Kompilierung zu ermöglichen?
main.cpp:
#include <stdio.h>
#include <vector>
#include "cuda_runtime.h"
#include "RadixSort.h"
typedef unsigned int uint;
typedef unsigned __int64 uint64;
int main()
{
RadixSort sorter;
uint n = 10;
std::vector<uint64> test(n);
for (uint i = 0; i < n; i++)
test[i] = i + 1;
uint64 * d_array;
uint64 size = n * sizeof(uint64);
cudaMalloc(&d_array, size);
cudaMemcpy(d_array, test.data(), size, cudaMemcpyHostToDevice);
try
{
sorter.Sort(d_array, n);
}
catch (const std::exception & ex)
{
printf("%s\n", ex.what());
}
}
RadixSort.h:
#pragma once
typedef unsigned int uint;
typedef unsigned __int64 uint64;
class RadixSort
{
public:
RadixSort() {}
~RadixSort() {}
void Sort(uint64 * input, const uint n);
};
RadixSort.cu:
#include "RadixSort.h"
#include <thrust/device_vector.h>
#include <thrust/device_ptr.h>
#include <thrust/sort.h>
void RadixSort::Sort(uint64 * input, const uint n)
{
thrust::device_ptr<uint64> d_input = thrust::device_pointer_cast(input);
thrust::stable_sort(d_input, d_input + n);
cudaDeviceSynchronize();
}
In diesem Zusammenhang: 'Gibt es einen Workaround, um eine separate Kompilierung zu ermöglichen? 'Auf welcher GPU laufen Sie? –
Derzeit die GTX 760. – RobbinMarcus
Versuchen Sie, mit der Architektur zu kompilieren, die auf Ihre GTX 760, die cc3.0 sein sollte, ich glaube. –