最適化問題に対する超高速&安定計算

大規模最適化問題、グラフ探索、機械学習やデジタルツインなどの研究のお話が中心

ffmpeg with GPU on CentOS 7

2020年08月08日 10時41分48秒 | Weblog
CentOS 7.8 + Driver Version: 450.51.06 + CUDA Version: 11.0 の環境下で
GPU を利用可能な ffmpeg を作成してみました。



0: nasm と yasm の入手
yum -y nasm* yasm*

1: nv-codec-headers の入手
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers
make
make install

2: ffmpeg の入手
git clone https://git.ffmpeg.org/ffmpeg.git
あるいは
wget https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
tar xvjf ffmpeg-snapshot.tar.bz2
cd ffmpeg

3: ffmpeg 内の configure の書き換え
compute_30,code=sm_30 は古すぎるので、適宜に 60 などに入れ替え。
https://developer.nvidia.com/cuda-gpus を参照
4323行目
nvccflags_default="-gencode arch=compute_60,code=sm_60 -O2"
◯追記
./configureする際に --nvccflags="-gencode arch=compute_60,code=sm_60 -O2" とすると置き換えればよい。

4: ffmpeg の make
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure --enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --prefix=/usr/local
make clean;make -j4
make install

後は以下などで GPU を用いた動画変換が可能
/usr/local/bin/ffmpeg -i "movie.mp4" -vcodec h264_nvenc -s 1920x1080 "movie_1080p.mp4"
コメント (2)
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする