NVCC error when trying to compile FFMPEG with --enable-cuda-nvcc flag

My goal

Compile/build FFMPEG for Cuda on Ubuntu Server 22.04 for accelerated encoding/decoding using Tesla T4.


I am following the instructions Using FFmpeg with NVIDIA GPU Hardware Acceleration
At configure stage, I am getting following nvcc error.

sudo ./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/cuda-12.1/include --extra-ldflags=-L/usr/cuda-12.1/lib64 --disable-static --enable-shared
ERROR: failed checking for nvcc.

– I have checked and nvcc is installed correctly,
$ 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

– I have checked the config.log and it does not seems to be very helpful, it says
gcc -L/usr/cuda-12.1/lib64 -Wl,–as-needed -Wl,-z,noexecstack -o /tmp/ffconf.sxwnJpkq/test /tmp/ffconf.sxwnJpkq/test.o -lm
check_nvcc cuda_nvcc
BEGIN /tmp/ffconf.sxwnJpkq/test.cu
1 extern “C” {
2 global void hello(unsigned char *data) {}
3 }
END /tmp/ffconf.sxwnJpkq/test.cu
nvcc -gencode arch=compute_30,code=sm_30 -O2 -std=c++11 -m64 -ptx -c -o /tmp/ffconf.sxwnJpkq/test.o /tmp/ffconf.sxwnJpkq/test.cu
./configure: 995: nvcc: not found
ERROR: failed checking for nvcc.

– My current gcc version is 11…1.0, also tried to compile with gcc (Ubuntu 7.5.0-6ubuntu2) 7.5.0

– I have checked my Cuda installation and I can build Cuda samples.
The output of deviceQuery sample is,
CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: “Tesla T4”
CUDA Driver Version / Runtime Version 12.1 / 12.1
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 14966 MBytes (15693381632 bytes)
(040) Multiprocessors, (064) CUDA Cores/MP: 2560 CUDA Cores
GPU Max Clock rate: 1590 MHz (1.59 GHz)
Memory Clock rate: 5001 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 4194304 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 65536 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 3 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Enabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.1, CUDA Runtime Version = 12.1, NumDevs = 1
Result = PASS

– I have verified nvidia driver using
$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 530.30.02 Wed Feb 22 04:11:39 UTC 2023
GCC version: gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)

Any thoughts would be appreciated. Thanks


That’s not a typical location for a CUDA 12 install. It would typically be at /usr/local/cuda-12.1 You might want to compare that to the output of

which nvcc

to see the actual/proper location.

That shows up in several places in your posting.

CUDA 12.1 cannot/will not compile for a compute_30/sm_30 target. You are using an incorrect CUDA version (too new for the old software you are trying to build) or else you need to correct the configure script. Even if you fix the other problems here, that will not work with CUDA 12.1. Check to see if the configure script has a switch to specify the GPU target. Your T4 is a compute_75/sm_75 device, so specify that instead.

why are you running the configure script with sudo? That does not respect the PATH variable you have set up. You would need to study the configure script to see if you want to try to fix that, or alternatively if the configure script has a method (command line switch, environment variable, etc.) to identify exactly where to look for your CUDA install. But my suggestion is to run configure without sudo, which is the way the instructions you linked indicate.

I fixed the issue by adding these lines to the configure:


I also had to do the same for the terminal I ran make from, for example:

export PATH=/usr/local/cuda/bin:${PATH}
1 Like

Thanks for this!
Adding the path fixed my ffmpeg compile as well.

Exporting the CUDA path without modifying the configure script worked for me.

export PATH=/usr/local/cuda/bin:${PATH}