Skip to content

[CUDA 12] clang error: no template named 'texture' #61340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lahwaacz opened this issue Mar 11, 2023 · 14 comments
Closed

[CUDA 12] clang error: no template named 'texture' #61340

lahwaacz opened this issue Mar 11, 2023 · 14 comments
Labels
clang:headers Headers provided by Clang, e.g. for intrinsics cuda

Comments

@lahwaacz
Copy link

lahwaacz commented Mar 11, 2023

For a trivial foo.cu:

int main() {}

Running clang++ foo.cu results in:

clang-15: warning: CUDA version is newer than the latest supported version 11.5 [-Wunknown-cuda-version]
In file included from <built-in>:1:
In file included from /usr/lib/clang/15.0.7/include/__clang_cuda_runtime_wrapper.h:365:
/usr/lib/clang/15.0.7/include/__clang_cuda_texture_intrinsics.h:696:13: error: no template named 'texture'
            texture<__DataT, __TexT, cudaReadModeNormalizedFloat> __handle,
            ^
/usr/lib/clang/15.0.7/include/__clang_cuda_texture_intrinsics.h:709:13: error: no template named 'texture'
            texture<__DataT, __TexT, cudaReadModeElementType> __handle,
            ^
2 errors generated when compiling for sm_35.

The platform is Arch Linux:

$ clang++ --version
clang version 15.0.7
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Feb__7_19:32:13_PST_2023
Cuda compilation tools, release 12.1, V12.1.66
Build cuda_12.1.r12.1/compiler.32415258_0
@EugeneZelenko EugeneZelenko added cuda clang:headers Headers provided by Clang, e.g. for intrinsics and removed new issue labels Mar 11, 2023
@Artem-B
Copy link
Member

Artem-B commented Mar 13, 2023

I believe that's already been fixed in recent clang: 8173405

@Artem-B Artem-B closed this as completed Mar 13, 2023
@lahwaacz
Copy link
Author

@Artem-B Thanks for the info. Any chance of backporting it to clang 15, or do I have to wait for version 16 to be released? What is the general policy?

@Artem-B
Copy link
Member

Artem-B commented Mar 13, 2023

It's a low-risk fix which should be OK to cherry-pick, though I don't know the current state of the release process.

@Artem-B Artem-B reopened this Mar 13, 2023
@Artem-B
Copy link
Member

Artem-B commented Mar 13, 2023

/cherry-pick 8173405

@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2023

/cherry-pick 8173405

Error: Command failed due to missing milestone.

@Artem-B
Copy link
Member

Artem-B commented Mar 13, 2023

/cherry-pick 8173405

Now, with the 16.0.1 milestone. @tstellar - FYI.

@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2023

Failed to cherry-pick: 8173405

https://github.com/llvm/llvm-project/actions/runs/4409411801

Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:

/branch <user>/<repo>/<branch>

@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2023

Failed to cherry-pick: 8173405

https://github.com/llvm/llvm-project/actions/runs/4409418263

Please manually backport the fix and push it to your github fork. Once this is done, please add a comment like this:

/branch <user>/<repo>/<branch>

@Artem-B
Copy link
Member

Artem-B commented Mar 13, 2023

Oh, we don't need any cherry-picks. The change is already in 16.x.

@lahwaacz
Copy link
Author

@Artem-B What about 15.x? Or is 16.0 expected to come out soon?

@Artem-B
Copy link
Member

Artem-B commented Mar 14, 2023

16.0 should be released soon, though I don't know the exact date.
I'm not sure it's worth bothering with 15.x, cuda-12 needs other changes that would not be suitable for backporting two major releases back.

@milthorpe
Copy link

I see the same error with Clang 17.0.6 and CUDA 12.4:

~/source/chapel-2.0$ clang++ --cuda-gpu-arch=sm_60 foo.cu
clang++: warning: CUDA version is newer than the latest partially supported version 12.1 [-Wunknown-cuda-version]
In file included from <built-in>:1:
In file included from /usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_runtime_wrapper.h:365:
/usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_texture_intrinsics.h:697:13: error: no template named 'texture'
  697 |             texture<__DataT, __TexT, cudaReadModeNormalizedFloat> __handle,
      |             ^
/usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_texture_intrinsics.h:710:13: error: no template named 'texture'
  710 |             texture<__DataT, __TexT, cudaReadModeElementType> __handle,
      |             ^
2 errors generated when compiling for sm_60.
~/source/chapel-2.0$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Thu_Mar_28_02:18:24_PDT_2024
Cuda compilation tools, release 12.4, V12.4.131
Build cuda_12.4.r12.4/compiler.34097967_0
~/source/chapel-2.0$ clang++ --version
Ubuntu clang version 17.0.6 (++20231208085846+6009708b4367-1~exp1~20231208085949.74)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

@Artem-B
Copy link
Member

Artem-B commented May 7, 2024

In file included from /usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_runtime_wrapper.h:365:
/usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_texture_intrinsics.h:697:13: error: no template named 'texture'
697 | texture<__DataT, __TexT, cudaReadModeNormalizedFloat> __handle,
| ^
/usr/lib/llvm-17/lib/clang/17/include/__clang_cuda_texture_intrinsics.h:710:13: error: no template named 'texture'
710 | texture<__DataT, __TexT, cudaReadModeElementType> __handle,
| ^

That code is guarded with #if CUDA_VERSION < 12000 and should not be seen by the comiler:

My guess is that something is broken w/ CUDA installation in your setup and clang picks up wrong/inconsistent CUDA headers somehow.

Considering that you didn't specify --cuda-path explicitly, you're at the mercy of what ever CUDA packages you have installed on your system.

I would suggest running compilation with -v and check the CUDA include path clang ends up using.
You may also want to check preprocessed output and see where CUDA_VERSION comes from (compile with -dD -E --cuda-host-only)

@milthorpe
Copy link

Thanks Artem! Your suggestion to compile with -dD -E --cuda-host-only was very helpful: it showed that my system had a rogue symlink from /usr/include/cuda.h to a CUDA 11 version of the header. I removed this, after which the CUDA 12 version was included as expected, and I no longer see the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:headers Headers provided by Clang, e.g. for intrinsics cuda
Projects
None yet
Development

No branches or pull requests

6 participants