Software & AppsOperating SystemLinux

How To Fix “Unsupported GPU Architecture” Error When Compiling CUDA Programs with nvcc

Ubuntu 7
Quick Answer

To fix the "Unsupported GPU Architecture" error when compiling CUDA programs with nvcc, you need to modify the CUDA_ARCH variable in the Makefile.config file. Ensure that the GPU architectures specified in the variable are supported by your CUDA version. Additionally, verify that your CUDA and cuDNN installations are properly installed and compatible with each other.

Introduction

If you’re a developer or system administrator working with CUDA programs, you might have encountered the error message “Unsupported GPU Architecture” when compiling with nvcc. This error typically arises when the GPU architecture specified in your Makefile isn’t supported by the CUDA version you’re using. This article will guide you through the process of resolving this issue.

Understanding the Error

Before we delve into the solution, it’s important to understand the error. The error message “nvcc fatal: Unsupported gpu architecture ‘compute_20′” usually occurs when you’re trying to compile a program using CUDA, but the specified GPU architecture isn’t supported by your CUDA version. For instance, if you’re using CUDA 8.0, the “compute_20” architecture isn’t supported.

Modifying the CUDA_ARCH Variable

The primary solution to this error involves modifying the CUDA_ARCH variable in the Makefile.config file. This variable should only include the GPU architectures that are supported by your CUDA version.

Here is an example of how the updated CUDA_ARCH variable should look for CUDA 8.0:

CUDA_ARCH := -gencode arch=compute_50,code=sm_50 \
 -gencode arch=compute_52,code=sm_52 \
 -gencode arch=compute_60,code=sm_60 \
 -gencode arch=compute_61,code=sm_61 \
 -gencode arch=compute_61,code=compute_61

In this command:

  • arch specifies the name of the NVIDIA GPU architecture.
  • code specifies the name of the specific GPU.

The gencode parameter is used to generate code for specified architectures. Each architecture is specified using the arch and code parameters.

After modifying the CUDA_ARCH variable, you should try running the make pycaffe command again. This should compile your program without the “Unsupported gpu architecture” error.

Verifying CUDA and cuDNN Installations

If you’re still encountering issues after modifying the CUDA_ARCH variable, you should verify your CUDA and cuDNN installations. Make sure that CUDA 8.0 and cuDNN 6.0 are properly installed on your system and that they are compatible with each other.

For more information on installing and verifying CUDA, you can refer to the official CUDA installation guide. For cuDNN, refer to the official cuDNN installation guide.

Conclusion

The “Unsupported GPU Architecture” error when compiling CUDA programs with nvcc can be resolved by modifying the CUDA_ARCH variable in the Makefile.config file and verifying your CUDA and cuDNN installations. Always ensure that your CUDA and cuDNN versions are compatible with each other and with your GPU architecture to avoid such errors.

What is nvcc?

nvcc is the NVIDIA CUDA Compiler. It is used to compile CUDA programs and generate executable files that can run on NVIDIA GPUs.

How can I check my CUDA version?

You can check your CUDA version by running the nvcc --version command in the terminal. This will display the version number of your CUDA installation.

How can I check my cuDNN version?

To check your cuDNN version, you can navigate to the cuDNN installation directory and open the cudnn_version.h file. This file contains the version information for cuDNN.

Can I use multiple GPU architectures in the CUDA_ARCH variable?

Yes, you can specify multiple GPU architectures in the CUDA_ARCH variable by using multiple -gencode parameters in the Makefile. Each -gencode parameter should specify a different architecture using the arch and code parameters.

What should I do if I’m still encountering the “Unsupported GPU Architecture” error after modifying the CUDA_ARCH variable?

If you’re still encountering the error after modifying the CUDA_ARCH variable, you should verify your CUDA and cuDNN installations. Make sure that they are properly installed and compatible with each other. Also, ensure that your GPU architecture is supported by your CUDA version.

Leave a Comment

Your email address will not be published. Required fields are marked *