PIP を使用した NNabla CUDA 拡張機能パッケージのインストール

注 : OS 固有の依存関係の設定については、 OS 別ワークフロー を参照してください。

NNabla CUDA 拡張機能パッケージである nnabla-ext-cuda をインストールすることで、 NVIDIA CUDA GPU による計算の高速化が可能です( CUDA を環境に合わせて設定する必要があります ) 。

各 CUDA バージョンとそれに対応する cuDNN バージョンに対して NNabla CUDA 拡張機能の pip パッケージが次のようにいくつか提供されています。

CUDA vs cuDNN 互換性

パッケージ名

CUDA バージョン

cuDNN バージョン

nnabla-ext-cuda100

10.0

7.6(Linux & Win)

nnabla-ext-cuda102

10.2

8.0(Linux & Win)

nnabla-ext-cuda110

11.0

8.0(Linux & Win)

お使いの GPU が対応可能であれば、常に最新の CUDA バージョンを使用することを推奨します。

Currently, for each NNabla CUDA extension package, it may be not compatible with some specific GPUs.

After nnabla-ext-cuda package is installed, you can manually check whether your GPU is usable. For example, you can check GPU with device_id 0 by:

import nnabla_ext.cudnn
device_id = '0'
nnabla_ext.cudnn.check_gpu(device_id)

Above code will run successfully if your GPU is usable, otherwise, an error will be reported.

nnabla-ext-cuda package will also try to check the compatibility of your GPUs automatically when you use 'cuda' or 'cudnn' extension. By default, it will list and check all gpus in your machine. Error will be reported if there is incompatible card.

You can set environment variable 'AVAILABLE_GPU_NAMES' to tell it which GPU is usable, 'AVAILABLE_GPU_NAMES' is a white list, GPU in 'AVAILABLE_GPU_NAMES' will not cause error. For example, if you think GeForce RTX 3070 and GeForce RTX 3090 are usable, you can set environment variable as following:

export AVAILABLE_GPU_NAMES="GeForce RTX 3070,GeForce RTX 3090"

インストール

The following is an example of installing the extension for CUDA 10.2

pip install nnabla-ext-cuda102

次に、すべて機能するか確認します。

python -c "import nnabla_ext.cuda, nnabla_ext.cudnn"
2018-06-26 15:20:36,085 [nnabla][INFO]: Initializing CPU extension...
2018-06-26 15:20:36,257 [nnabla][INFO]: Initializing CUDA extension...
2018-06-26 15:20:36,257 [nnabla][INFO]: Initializing cuDNN extension...

: 確実に最新バージョンをインストールしたい場合は、 pip uninstall -y nnabla nnabla-ext-cuda100 で以前にインストールしたバージョンをアンインストールしてください。

Multi-GPU サポートのインストール

Multi-GPU wheel package is only available on python3.6+.

CUDA vs cuDNN 互換性

以下のようにインストールできます。

pip install nnabla
pip install nnabla-ext-cuda100-nccl2-mpi2-1-1

すでに NNabla をインストールしている場合は、すべてアンインストールするか、Anaconda 、venv を使って作成したクリーンな環境から始めてください。

You should also install OpenMPI and NCCL in addition to CUDA and CuDNN.

If you are using Ubuntu18.04 and choose mpi2.1.1, you can install mpi with following command.

sudo apt install -y --no-install-recommends openmpi-bin libopenmpi-dev

Otherwise, you must install openmpi with following command.(MPIVER=3.1.6 or 2.1.1)

MPIVER=3.1.6
curl -O https://download.open-mpi.org/release/open-mpi/v${MPIVER%.*}/openmpi-${MPIVER}.tar.bz2
tar xvf openmpi-${MPIVER}.tar.bz2
cd openmpi-${MPIVER}
./configure --with-sge
make
sudo make install

FAQ

Q. どの様に CUDA をインストールしますか?

NNabla CUDA 拡張機能は、 CUDA ツールキットと cuDNN ライブラリーの両方が必要です。 CUDA デバイスの機能に応じて、適切な CUDA バージョンを選択する必要があります。 公式のインストールガイド をご覧ください。 NNabla は CUDA バージョン 8.0 以降をサポートしています。特定の CUDA バージョンとのcuDNN の互換性については、 上記の表 をご覧ください。

Q. どの様に NCCL をインストールしますか?

NCCL にアクセスして、指示に従ってください。

Q. どの様に cuDNN の適切なバージョンを確認しますか?

以下のコマンドを入力。

python -c "import nnabla_ext.cuda, nnabla_ext.cudnn"

お使いのマシン上でバージョンの不一致が発生した場合は、エラーメッセージに適切なバージョンが表示されます。以下は、エラーメッセージの例です。

[nnabla][INFO]: Initializing CPU extension...
Please install CUDA version 10.2.
  and cuDNN version 8.0
  Or install correct nnabla-ext-cuda for installed version of CUDA/cuDNN.