It may have been unsuccessful.
- Please use the available tools to format your code. this thread has a description. (I have already fixed it.)
- Error 700 means a kernel made an illegal memory access. That is unlikely to come about via texturing, due to the characteristics of the texture engine.
- It may not be obvious to you, but the presence or absence of the error in your code should not depend on the data you are loading from the file. Therefore eliminating this will help for simplicity and focus.
- As will be evident below, texture references are deprecated. It’s not the source of any problem here, but you may want to be aware of it for future code maintainability. The suggested solution is to use texture objects instead.
When I run this reduced version of your code, I get no errors:
$ cat t31.cu
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <cstdio>
using namespace std;
texture <int, 1, cudaReadModeElementType> tex;
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char* file, int line, bool abort = true)
{
if (code != cudaSuccess)
{
fprintf(stderr, "GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
if (abort) exit(code);
}
}
__global__ void kernel() {
printf(" (tex1Dfetch(tex, IndexingReceive): %d \n", (tex1Dfetch(tex, 100)));
}
int main (){
int* Dir;
int* Device_Dir;
int Dir_Size = 512 * 256;
int ArrayByteSize_Dir = sizeof(int) * (96* Dir_Size);
cudaMallocHost((int**)&Dir, ArrayByteSize_Dir); // pinned memory
for (int i = 0; i < 96*Dir_Size; i++) Dir[i] = i;
gpuErrchk(cudaMalloc((void**)&Device_Dir, ArrayByteSize_Dir));
gpuErrchk(cudaMemcpy(Device_Dir, Dir, ArrayByteSize_Dir, cudaMemcpyHostToDevice));
gpuErrchk(cudaBindTexture(NULL, tex, Device_Dir, ArrayByteSize_Dir));
kernel << <1, 1 >> > ();
gpuErrchk(cudaPeekAtLastError());
gpuErrchk(cudaFree(Device_Dir));
gpuErrchk(cudaUnbindTexture(tex));
return 0;
}
$ nvcc -o t31 t31.cu
t31.cu: In function ‘int main()’:
t31.cu:32:71: warning: ‘cudaError_t cudaBindTexture(size_t*, const texture<T, dim, readMode>&, const void*, size_t) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError; size_t = long unsigned int]’ is deprecated [-Wdeprecated-declarations]
gpuErrchk(cudaBindTexture(NULL, tex, Device_Dir, ArrayByteSize_Dir));
^
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1339:53: note: declared here
static __CUDA_DEPRECATED __inline__ __host__ cudaError_t cudaBindTexture(
^~~~~~~~~~~~~~~
t31.cu:39:34: warning: ‘cudaError_t cudaUnbindTexture(const texture<T, dim, readMode>&) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError]’ is deprecated [-Wdeprecated-declarations]
gpuErrchk(cudaUnbindTexture(tex));
^
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1661:53: note: declared here
static __CUDA_DEPRECATED __inline__ __host__ cudaError_t cudaUnbindTexture(
^~~~~~~~~~~~~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h: In instantiation of ‘cudaError_t cudaBindTexture(size_t*, const texture<T, dim, readMode>&, const void*, size_t) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError; size_t = long unsigned int]’:
t31.cu:32:71: required from here
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1346:23: warning: ‘cudaError_t cudaBindTexture(size_t*, const texture<T, dim, readMode>&, const void*, const cudaChannelFormatDesc&, size_t) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError; size_t = long unsigned int]’ is deprecated [-Wdeprecated-declarations]
return cudaBindTexture(offset, tex, devPtr, tex.channelDesc, size);
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1293:53: note: declared here
static __CUDA_DEPRECATED __inline__ __host__ cudaError_t cudaBindTexture(
^~~~~~~~~~~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h: In instantiation of ‘cudaError_t cudaUnbindTexture(const texture<T, dim, readMode>&) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError]’:
t31.cu:39:34: required from here
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1665:27: warning: ‘cudaError_t cudaUnbindTexture(const textureReference*)’ is deprecated [-Wdeprecated-declarations]
return ::cudaUnbindTexture(&tex);
~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime_api.h:8060:46: note: declared here
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaUnbindTexture(const struct textureReference *texref);
^~~~~~~~~~~~~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h: In instantiation of ‘cudaError_t cudaBindTexture(size_t*, const texture<T, dim, readMode>&, const void*, const cudaChannelFormatDesc&, size_t) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError; size_t = long unsigned int]’:
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1346:23: required from ‘cudaError_t cudaBindTexture(size_t*, const texture<T, dim, readMode>&, const void*, size_t) [with T = int; int dim = 1; cudaTextureReadMode readMode = (cudaTextureReadMode)0; cudaError_t = cudaError; size_t = long unsigned int]’
t31.cu:32:71: required from here
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime.h:1301:25: warning: ‘cudaError_t cudaBindTexture(size_t*, const textureReference*, const void*, const cudaChannelFormatDesc*, size_t)’ is deprecated [-Wdeprecated-declarations]
return ::cudaBindTexture(offset, &tex, devPtr, &desc, size);
~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/cuda/bin/../targets/x86_64-linux/include/cuda_runtime_api.h:7897:46: note: declared here
extern __CUDA_DEPRECATED __host__ cudaError_t CUDARTAPI cudaBindTexture(size_t *offset, const struct textureReference *texref, const void *devPtr, const struct cudaChannelFormatDesc *desc, size_t size __dv(UINT_MAX));
^~~~~~~~~~~~~~~
$ cuda-memcheck ./t31
========= CUDA-MEMCHECK
(tex1Dfetch(tex, IndexingReceive): 100
========= ERROR SUMMARY: 0 errors
$
Therefore I suspect the code you have shown is not what is actually causing the error. You might wish to use the method described here to start the debug.