This chapter introduces the steps to install PG-Strom from the source code. 本章ではPG-Stromをソースコードからインストールする手順を説明します。
Choose a Linux distribution that is supported by CUDA Toolkit, and then install it according to the installation process of individual distributions. A list of supported Linux distributions is introduced at NVIDIA DEVELOPER ZONE. CUDA ToolkitのサポートするLinuxディストリビューションを選択し、個々のディストリビューションのインストールプロセスに従ってインストール作業を行ってください。 CUDA ToolkitのサポートするLinuxディストリビューションは、NVIDIA DEVELOPER ZONEにおいて紹介されています。
You may be able to choose the software packages to be installed during the operating system installation. Source installation of PostgreSQL and PG-Strom needs software development tool chains below. Please don't forget to install these packages, prior to the next step. PostgreSQLおよびPG-Stromのソースプログラムからのインストールには、下記のソフトウェア開発ツールが必要となります。次のステップに進む前に、これらのパッケージを忘れずにインストールするようにしてください。
These are usually categorized to development software. 通常、これらのパッケージは Development Software に分類されています。
Also, please don't install the PostgreSQL package provided by the distribution, if its package version is prior to 9.5. また、ディストリビューションの提供するPostgreSQLパッケージのバージョンが9.5以前の場合、これをインストールしないでください。
Once operating system gets installed on your system, a few additional packager configurations are needed for GPU driver installation on the later steps. システムへのOSのインストール後、後のステップでGPUドライバをインストールするために、少々のパッケージャー設定が必要です。
DKMS (Dynamic Kernel Module Support) is a framework that enables to build a Linux kernel module on the fly, according to the Linux kernel currently working on. NVIDIA's driver supports this framework, and we recommend setup it. DKMS (Dynamic Kernel Module Support) は、動作中のLinuxカーネル向けのLinuxカーネルモジュールをその場でビルドする事を可能にするフレームワークで、NVIDIAのドライバも対応しています。そのため、我々もDKMSのセットアップを推奨します。
PRM package of DKMS is distributed as a part of Extra Packages for Enterprise Linux (EPEL). So, get epel-release-<distribution version>.noarch.rpm from the public FTP site, then install the package. Once epel-release package gets installed, it adds extra configuration of yum to pull non-standard packages from the EPEL repository. DKMSパッケージはEPEL (Extra Packages for Enterprise Linux) の一部として配布されています。ですので、パブリックFTPサイトから epel-release-<distribution version>.noarch.rpm をダウンロードし、これをインストールしてください。 いったん epel-release パッケージがインストールされると、EPELリポジトリから非標準のパッケージを入手するためのyumシステムへの設定が追加されます。
In addition to the DKMS, the following packages are needed to build nvidia kernel module. Install them prior to the later steps. DKMSに加えて、nvidiaカーネルモジュールをビルドするには以下のパッケージが必要です。以降のステップに進む前に、これらをインストールしてください。
CUDA Toolkit needs the official nvidia driver provided by NVIDIA. However, it conflicts with nouveau driver that is a compatible open source driver. So, you need to disable the nouvean driver prior to installation of CUDA Toolkit, if OS installer already setup nouveau driver. CUDA Toolkitが動作するためにはNVIDIAの提供するnvidiaドライバが必要です。しかし、オープンソースの互換ドライバであるnouveauと競合してしまうため、OSインストーラがnouveauドライバをインストールしている場合には、CUDA Toolkitのインストールに先立ってnouveauドライバを無効化する必要があります。
Put the following configuration on the /etc/modprobe.d/blacklist-nouveau.conf, to prevent loading the nouveau driver. nouveauドライバがロードされないよう、以下の設定を/etc/modprobe.d/blacklist-nouveau.confに追加します。
blacklist nouveau options nouveau modeset=0
Then, run dracut -f /boot/initramfs-$(uname -r).img $(uname -r), to update kernel boot image correctly. その後、カーネルブートイメージを更新するために dracut -f /boot/initramfs-$(uname -r).img $(uname -r) を実行してください。
Then, restart the system, using shutdown -r now to apply this configuration. It is successfully configured, if output of lsmod contains no nouveau entries. その後、この設定を反映させるために shutdown -r now を実行してシステムを再起動します。 lsmodの出力にnouveauが含まれていなければ正しく設定されています。
$ lsmod | grep nouveau $
This section introduces the installation of CUDA Toolkit. If you already install the required version of CUDA Toolkit, you can skip this section. 本節ではCUDA Toolkitのインストールについて説明します。 既に対応バージョンのCUDA Toolkitをインストール済みであれば、本節の内容は読み飛ばして構いません
NVIDIA provides two types of installation methods for CUDA Toolkit; the first is self-executable archive (called as runfile), the other is collection of RPM packages. Our recommendation is RPM installation. PG-Strom's Makefile is designed according to the installation layout of RPM packages. NVIDIAはCUDA Toolkitのインストールに2通りの方法を提供しています。一つは自己実行型アーカイブ(runfileと呼ばれる)によるもの。もう一つはRPMパッケージによるものです。 推奨はRPMインストールであり、PG-StromのMakefileもRPMパッケージによるインストールを前提に設計されています。
You can download the CUDA Toolkit installation package from NVIDIA DEVELOPER ZONE. Please select proper operating system, architecture, distribution, version and installer type. RPM installation in this document intends to use "rpm (network)". CUDA Toolkitのインストール用パッケージはNVIDIA DEVELOPER ZONEからダウンロードする事ができます。 適切なOS、アーキテクチャ、ディストリビューション、バージョン、およびインストータライプを選択してください。 本節におけるRPMインストールは『rpm(network)』の使用を意図しています。
The "rpm (network)" package contains only definition of the yum repository that distributes CUDA Toolkit. It is similar method when we add definition of the EPEL repository on %%%PGSTROM_MANUAL_XLINK:install-os%%%. So, you need to obtain and install the related RPM packages over the network. Run the commands below. 『rpm(network)』パッケージにはCUDA Toolkitを配布するyumリポジトリの定義情報が含まれているだけです。これは %%%PGSTROM_MANUAL_XLINK:install-os%%% においてシステムにEPELリポジトリの定義を追加したのと同様の方法です。 したがって、cudaリポジトリを登録した後、関連したRPMパッケージをネットワークインストールする必要があります。 下記のコマンドを実行してください。
$ sudo rpm -i cuda-repo-<distribution>-<version>.x86_64.rpm $ sudo yum clean all $ sudo yum install cuda
Once installation gets completed, CUDA Toolkit shall be deployed under the /usr/local/cuda.
正常にインストールが完了すると、/usr/local/cuda配下にCUDA Toolkitが導入されています。
$ ls /usr/local/cuda
LICENSE bin extras lib64 libnvvp samples src tools
README doc include libnsight nvvm share targets
The self executable archive, called "runfile", contains full-set of the CUDA Toolkit. Download the runfile, then execute it under the root user privillege. Runfileと呼ばれる自己実行型アーカイブにはCUDA Toolkitのフルセットが格納されています。 Runfileのダウンロード後、rootユーザの権限でこれを実行してください。
$ sudo sh cuda_<version>_linux.run
The script prompts to answer several questions during installation, please answer "yes" basically. Especially, ensure the toolkit location is /usr/local/cuda-<version> and makes a symbolic link to the location on /usr/local/cuda.
インストール中、スクリプトが質問に対して入力を促す場面が何個かありますが、基本的に "yes" と回答するようにしてください。 また、特にCUDA Toolkitのインストールパスが/usr/local/cuda-<version>である事、このパスに対するシンボリックリンクを/usr/local/cudaに作成する事を確認してください。We have a known problem about linkage of NVRTC that is used by PG-Strom, on CUDA-7.0 and CUDA-7.5, at least. Add the following configuration as a workaround. 少なくともCUDA-7.0およびCUDA-7.5において、PG-Stromの使用するNVRTCライブラリのリンケージに関して問題がある事が分かっており、これを回避するため、ワークアラウンドとして以下の設定を行ってください。
い# echo /usr/local/cuda/lib64 > /etc/ld.so.conf.d/cuda-lib64.conf # ldconfig
Once installation of CUDA and nvidia
driver gets completed, ensure the GPU devices are ready to use.
The nvidia-smi
command will print information about GPU devices installed on the system, like the example below.
CUDAおよびnvidia
ドライバのインストールが完了したら、GPUが正しく認識されている事を確認してください。
nvidia-smi
コマンドを実行すると、以下の出力例のように、システムに搭載されているGPUの情報が表示されます。
$ nvidia-smi Sat May 14 21:17:35 2016 +------------------------------------------------------+ | NVIDIA-SMI 352.68 Driver Version: 352.68 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 980 Off | 0000:02:00.0 Off | N/A | | 33% 33C P0 41W / 180W | 15MiB / 4095MiB | 0% Default | +-------------------------------+----------------------+----------------------+ | 1 Tesla K20c Off | 0000:04:00.0 Off | Off | | 30% 36C P0 42W / 225W | 12MiB / 5119MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
This section introduces the installation of PostgreSQL from the source code. You can skip this section if you already installed required version of PostgreSQL on your system. If your preference is RPM installation, see the %%%PGSTROM_MANUAL_XLINK:install-postgresql-rpm%%% below. 本節ではソースコードからPostgreSQLをインストールについて説明します。 既に対応バージョンのPostgreSQLがインストール済みであれば、本節の内容は読み飛ばして構いません。 RPMインストールに関しては、下記の %%%PGSTROM_MANUAL_XLINK:install-postgresql-rpm%%% を参照してください。
PostgreSQL Global Development Group distributes both source and binary form of the PostgreSQL at http://www.postgresql.org/ftp/source/. You can choose a tarball of PostgreSQL 9.5.0 or later, and download the archive. http://www.postgresql.org/ftp/source/にて、PostgreSQL Global Development GroupはPostgreSQLのバイナリおよびソースコードを配布しています。 PostgreSQL 9.5.0以降のtarballを選択し、これをダウンロードしてください。
Extract the tarball you downloaded, then run the configure
as follows.
You can specify an arbitrary directory on the --prefix
option. Ensure $PATH environment variable contains the /path/to/install/bin.
You can omit --enable-debug
and --enable-cassert
options. On the other hands, note that PG-Strom is a software with short history, thus, people expect these options are valuable to find out or analyze unknown bugs.
ダウンロードしたtarballを展開し、以下の通りconfigure
スクリプトを実行してください。
--prefix
には任意のディレクトリを指定する事ができますが、/path/to/install/binが$PATH環境変数に含まれている事を確認してください。
--enable-debug
と--enable-cassert
は省略する事も可能ですが、PG-Stromは歴史の短いソフトウェアであり、これらのオプションは未知のバグを発見・解析するために役立つ事が期待されています。
$ ./configure --prefix=/path/to/install --enable-debug --enable-cassert
Build the source tree as usual. いつも通りにソースコードをビルドします。
$ make -j <num of parallels> $ sudo make install
Ensure pg_config is runnable and its path is correct. pg_configが実行可能であり、パスが正しい事を確認してください。
$ which pg_config /usr/local/pgsql/bin/pg_config $ pg_config --pgxs /usr/local/pgsql/lib/pgxs/src/makefiles/pgxs.mk
PG-Strom does not have its own configure script because it has to share all the configuration stuff with the target PostgreSQL, not to have any inconsistency. Thus, its build chain relies on the pg_config that provides information when PostgreSQL was built. PG-Stromは固有のconfigureスクリプトを持ちません、なぜなら、対象のPostgreSQLと全く同一のコンフィグを持つ必要があり、不整合が許されないからです。 したがって、PG-Stromのビルドチェインは、PostgreSQLがビルドされた時の情報を提供するpg_configを全面的に信頼しています。
PostgreSQL Global Development Group also provides a yum repository to distribute the latest and supported PostgreSQL and related software. You can install a small package to setup definition of the yum repository, like EPEL configuration, and then install PostgreSQL and other software. 最新およびサポート中のPostgreSQLと関連ソフトウェアの配布のため、PostgreSQL Global Development Groupはyumリポジトリを提供しています。 EPELの設定のように、yumリポジトリの設定を行うだけの小さなパッケージをインストールし、その後、PostgreSQLやその他のソフトウェアをインストールします。
The list of yum repository definition is here: http://yum.postgresql.org/repopackages.php. You can find many repository definitions for each PostgreSQL major version and Linux distribution. You need to choose one of PostgreSQL 9.5 or later on your Linux distribution. yumリポジトリ定義の一覧は http://yum.postgresql.org/repopackages.php です。 PostgreSQLメジャーバージョンとLinuxディストリビューションごとに多くのリポジトリ定義がありますが、あなたのLinuxディストリビューション向けのPostgreSQL 9.5以降のものを選択する必要があります。
All you need to do are installation of yum repository definition, then install PostgreSQL package. 以下のように、yumリポジトリの定義をインストールし、次いで、PostgreSQLパッケージをインストールすれば完了です。 The packages below are needed to build and run PG-Strom. PG-Stromのビルドおよび実行には以下のパッケージが必要です。
$ sudo rpm -ivh pgdg-redhat95-9.5-2.noarch.rpm $ sudo yum install postgresql95-server postgresql95-devel : ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgresql95-devel x86_64 9.5.1-1PGDG.rhel7 pgdg95 1.7 M postgresql95-server x86_64 9.5.1-1PGDG.rhel7 pgdg95 4.1 M Installing for dependencies: postgresql95 x86_64 9.5.1-1PGDG.rhel7 pgdg95 1.3 M postgresql95-libs x86_64 9.5.1-1PGDG.rhel7 pgdg95 218 k Transaction Summary ================================================================================ Install 2 Packages (+2 Dependent packages) Total download size: 7.4 M Installed size: 32 M Is this ok [y/d/N]:y : Installed: postgresql95-devel.x86_64 0:9.5.1-1PGDG.rhel7 postgresql95-server.x86_64 0:9.5.1-1PGDG.rhel7 Dependency Installed: postgresql95.x86_64 0:9.5.1-1PGDG.rhel7 postgresql95-libs.x86_64 0:9.5.1-1PGDG.rhel7 Complete!
You can check out the master branch of the Git repository (https://github.com/pg-strom/devel.git) to get source code of PG-Strom. PG-Stromのソースコードを入手するには、Gitリポジトリ (https://github.com/pg-strom/devel.git) のmasterブランチをチェックアウトします。
$ git clone https://github.com/pg-strom/devel.git pg_strom Cloning into 'pg_strom'... remote: Counting objects: 8531, done. remote: Compressing objects: 100% (14/14), done. remote: Total 8531 (delta 1), reused 0 (delta 0), pack-reused 8517 Receiving objects: 100% (8531/8531), 6.50 MiB | 3.40 MiB/s, done. Resolving deltas: 100% (6427/6427), done.
By the feature of GitHub, you can also download the latest source tree as a zip file. However, it is not convenient to follow the update of PG-Strom, so we don't recommend using the package unless you don't have particular reason; the server cannot connect to the internet for example. GitHubの機能により、最新版のソースツリーをZIPファイルとして入手する事もできますが、PG-Stromが更新された時の追従が不便ですので、サーバからインターネットに接続できないなどの事情がない限り、あまりお勧めはしません。
The configuration when you build PG-Strom has to be strictly identical with the target PostgreSQL. For example, if a particular structure would have different layout on PG-Strom from the PostgreSQL by the configuration on build, it may lead a bug which is hard to find. Thus, PG-Strom has no own configure script; that may produce inconsistency. It uses pg_config to reference the configuration of PostgreSQL on its build. PG-Stromをビルドする時のコンフィグは、インストール先のPostgreSQLと厳密に一致していなければいけません。例えば、同じ構造体がビルド時のコンフィグによりPostgreSQLとPG-Stromで異なったレイアウトを持ってしまったとすれば、非常に発見の難しいバグを生み出してしまうかもしれません。 したがって、(一貫性のない状態を避けるため)PG-Stromは独自にconfigureスクリプトを走らせたりはせず、pg_configを使ってPostgreSQLのビルド時設定を参照します。
Run make then make install with no extra configuration, if PATH environment variable is configured to pg_config of the target PostgreSQL correctly. pg_configにパスが通っており、それがインストール先のPostgreSQLのものであれば、そのままmake、make installを実行してください。
$ which pg_config /usr/local/pgsql/bin/pg_config $ pg_config --pgxs /usr/local/pgsql/lib/pgxs/src/makefiles/pgxs.mk $ cd pg_strom $ make $ sudo make install
$ make CUDA_PATH=/path/to/cuda/installation/base
This section introduces post-installation setup stuffs. 本章ではPG-Stromインストール後の設定項目について説明します。
If you don't create a database cluster, run initdb command to create initial database of PostgreSQL データベースの初期化が済んでいない場合は、initdbコマンドを実行してPostgreSQLの初期データベースを作成します。
$ initdb -D /path/to/database
$PGDATA/postgresql.conf is a file to descript configuration parameters of PostgreSQL. This section introduces the minimum required configuration to work PG-Strom. $PGDATA/postgresql.confはPostgreSQLの設定パラメータを記述するファイルです。 本節では、PG-Stromを動作させるために最低限必要な設定パラメータについて説明します。
shared_preload_libraries = '$libdir/pg_strom'
shared_buffers = 10GB
work_mem = 10GB
See %%%PGSTROM_MANUAL_XLINK:reference_configs%%% for the configuration parameters provided by PG-Strom. これ以外にPG-Stromが提供する設定パラメータについては %%%PGSTROM_MANUAL_XLINK:reference_configs%%% を参照してください。
The prior configuration enables to load PG-Strom on startup of PostgreSQL, and get ready to use GPU devices installed on the syste. Once you start PostgreSQL using pg_ctl, PG-Strom generates log messages related to GPU or CUDA, as follows. (Although it made a warning because of 2 GPU models in different generation...) ここまでの設定で、PostgreSQL起動時にPG-Stromをロードし、システムに搭載されているGPUを使用する準備ができました。 pg_ctlコマンドを使用してPostgreSQLを起動すると、以下のようにPG-StromやGPU、CUDAに関連したログが出力されます。 (ここでは世代の異なる2つのGPUを搭載しているために警告が出力されていますが)
$ pg_ctl -D /opt/pgsql/data start server starting LOG: PG-Strom version 1.0devel built for PostgreSQL 9.5 LOG: CUDA Runtime version: 7.5.0 LOG: NVIDIA driver version: 352.79 LOG: GPU0 GeForce GTX 980 (2048 CUDA cores, 1253MHz), L2 2048KB, RAM 4095MB (256bits, 3505MHz), capability 5.2 LOG: GPU1 Tesla K20c (2496 CUDA cores, 705MHz), L2 1280KB, RAM 4799MB (320bits, 2600MHz), capability 3.5 WARNING: Mixture of multiple GPU device capabilities LOG: NVRTC - CUDA Runtime Compilation vertion 7.5 LOG: database system was shut down at 2016-03-13 21:56:29 JST LOG: MultiXact member wraparound protections are now enabled LOG: database system is ready to accept connections LOG: autovacuum launcher started
インストールの最終ステップは、PostgreSQLデータベースにログオンして、スキーマやSQL関数などPG-Strom関連のデータベースオブジェクトを作成する事です。 一連のステップはPostgreSQLのExtensionメカニズムにより自動化されているため、ユーザが行う必要があるのは以下のコマンドを実行する事のみです。
postgres=# CREATE EXTENSION pg_strom; CREATE EXTENSION
You need to run the above commands. Once you run CREATE EXTENSION pg_strom; command towards the special database template1, the database newly created shall already have PG-Strom setup on the initial state. 全てのデータベースに対して上記のコマンドを実行する必要がありますが、特別なデータベースtemplate1に対して一度CREATE EXTENSION pg_strom;を実行すれば、今後作成されるデータベースに対しては、初期状態で既にPG-Strom用のセットアップが完了した状態になっています。
template1=# CREATE EXTENSION pg_strom; CREATE EXTENSION
That is all of the installation process of PG-Strom 以上でPG-Stromのインストールは完了です。