# Selecting lto\_70 CUDA architecture with Cmake

**URL:** https://discourse.cmake.org/t/selecting-lto-70-cuda-architecture-with-cmake/2807
**Category:** Code
**Created:** [February 20, 2021, 10:04pm UTC](https://discourse.cmake.org/t/selecting-lto-70-cuda-architecture-with-cmake/2807 "2021-02-20T22:04:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gridley](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gridley/32/1223_2.png) [@gridley](https://discourse.cmake.org/u/gridley)
#### Post date: [February 20, 2021, 10:04pm UTC](https://discourse.cmake.org/t/selecting-lto-70-cuda-architecture-with-cmake/2807/1 "2021-02-20T22:04:05Z")

</div>

The CUDA manual says that link-time device code optimization can be done on CUDA code now if we use a special architecture, e.g. 70\_lto.

> **[NVCC :: CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#ptxas-options-gpu-name)**

Previously I had been using compute\_70 for all CUDA targets in my project by the Cmake command:

`set(CMAKE_CUDA_ARCHITECTURES 70)`

It seems Cmake allows us to also put “70-virtual” above, but I’ve not found any way to use the lto\_70 architecture as described in the CUDA manual link above.

How can I use lto\_70? I have tried simply using the `-dlto` flag to enable link time optimizations, but it seems that the flags as set by CMake cause this error from nvcc:

`nvcc fatal : '-dlto' conflicts with '-gencode' to control what is generated; use 'code=lto_<arch>' with '-gencode' instead of '-dlto' to request lto intermediate `

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 21, 2021, 5:00pm UTC](https://discourse.cmake.org/t/selecting-lto-70-cuda-architecture-with-cmake/2807/2 "2021-02-21T17:00:39Z")

</div>

Cc: @robert.maynard
